u #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: [main] | |
jobs: | |
release: | |
if: startsWith(github.event.head_commit.message, 'release') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write # for `npm publish --provenance` | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install pnpm | |
run: corepack enable | |
- name: Set node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
registry-url: 'https://registry.npmjs.org' | |
cache: pnpm | |
- name: Extract version from commit message | |
run: | | |
VERSION=$(echo "${{ github.event.head_commit.message }}" | grep -oP 'release: \Kv[0-9]+\.[0-9]+\.[0-9]+') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Create and push tag | |
run: | | |
git tag ${{ env.VERSION }} | |
git push origin ${{ env.VERSION }} | |
- run: npx changelogithub | |
continue-on-error: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Dependencies | |
run: pnpm i | |
- name: Publish to NPM | |
run: npm publish --tag latest --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |