Release #48
This file contains hidden or 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: | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: 'Version bump type' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| release: | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Configure git | |
| run: | | |
| git config --local user.email "${{ secrets.GIT_USER_EMAIL }}" | |
| git config --local user.name "${{ secrets.GIT_USER_NAME }}" | |
| - name: Bump version and push | |
| id: version | |
| run: | | |
| npm version ${{ github.event.inputs.version_type }} --no-git-tag-version | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| echo "new_version=v$NEW_VERSION" >> $GITHUB_OUTPUT | |
| git add package.json | |
| git commit -m "🔖 v$NEW_VERSION" | |
| git push origin main | |
| git tag "v$NEW_VERSION" | |
| git push origin "v$NEW_VERSION" | |
| - name: Generate release notes | |
| id: release_notes | |
| run: | | |
| LAST_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "") | |
| if [ -n "$LAST_TAG" ]; then | |
| COMMITS=$(git log $LAST_TAG..HEAD --oneline --pretty=format:"- %s") | |
| else | |
| COMMITS=$(git log --oneline --pretty=format:"- %s" | head -10) | |
| fi | |
| echo "notes<<EOF" >> $GITHUB_OUTPUT | |
| echo "## What's Changed" >> $GITHUB_OUTPUT | |
| echo "$COMMITS" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ steps.version.outputs.new_version }} | |
| release_name: ✨ ${{ steps.version.outputs.new_version }} | |
| body: ${{ steps.release_notes.outputs.notes }} | |
| draft: false | |
| prerelease: false | |
| - name: Publish to NPM | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |