chore(ci): build on release (#177) #72
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 | |
- uses: ./.github/actions/pnpm | |
- name: Build | |
run: pnpm run build | |
- 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: Publish to NPM | |
run: npm publish --tag latest --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |