Release #8
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: | |
| push: | |
| branches: [master] | |
| workflow_dispatch: | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| jobs: | |
| release: | |
| if: ${{ !contains(github.event.head_commit.message, 'chore(release)') }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| env: | |
| HUSKY: "0" | |
| steps: | |
| - name: Generate GitHub App token | |
| id: app-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.RELEASE_APP_ID }} | |
| private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Setup Node (for npm publish with OIDC) | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Lint | |
| run: bun run check | |
| - name: Typecheck | |
| run: bun run typecheck | |
| - name: Build | |
| run: bun run build | |
| - name: Test | |
| run: bun test | |
| - name: Configure git identity | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| APP_SLUG="${{ steps.app-token.outputs.app-slug }}" | |
| APP_USER_ID="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)" | |
| git config user.name "${APP_SLUG}[bot]" | |
| git config user.email "${APP_USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com" | |
| - name: Bump version, write changelog, create tag | |
| id: bump | |
| run: | | |
| PREV=$(node -p "require('./package.json').version") | |
| bunx commit-and-tag-version | |
| NEXT=$(node -p "require('./package.json').version") | |
| echo "version=$NEXT" >> "$GITHUB_OUTPUT" | |
| if [ "$PREV" = "$NEXT" ]; then | |
| echo "released=false" >> "$GITHUB_OUTPUT" | |
| echo "No release-worthy changes since last tag; will only publish if ${NEXT} is missing from npm." | |
| else | |
| echo "released=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Check if current version is already on npm | |
| id: npm-check | |
| run: | | |
| VERSION="${{ steps.bump.outputs.version }}" | |
| if npm view "squel@${VERSION}" version >/dev/null 2>&1; then | |
| echo "needs_publish=false" >> "$GITHUB_OUTPUT" | |
| echo "squel@${VERSION} already on npm; skipping publish." | |
| else | |
| echo "needs_publish=true" >> "$GITHUB_OUTPUT" | |
| echo "squel@${VERSION} not on npm yet; will publish." | |
| fi | |
| - name: Push release commit and tag | |
| if: steps.bump.outputs.released == 'true' | |
| run: git push --follow-tags origin HEAD:master | |
| - name: Publish to npm | |
| if: steps.npm-check.outputs.needs_publish == 'true' | |
| run: npm publish --provenance --access public |