name: Release on: push: branches: - main concurrency: group: ${{ github.workflow }} cancel-in-progress: false permissions: contents: read jobs: release-please: name: Release Please runs-on: ubuntu-latest timeout-minutes: 10 permissions: contents: write pull-requests: write outputs: releases_created: ${{ steps.release.outputs.releases_created }} tag_name: ${{ steps.release.outputs.tag_name }} version: ${{ steps.release.outputs.version }} steps: - name: Run Release Please id: release uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 with: token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }} config-file: release-please-config.json manifest-file: .release-please-manifest.json publish-npm: name: Publish to npm runs-on: ubuntu-latest timeout-minutes: 10 needs: [release-please] if: needs.release-please.outputs.releases_created == 'true' permissions: contents: read id-token: write steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ needs.release-please.outputs.tag_name }} persist-credentials: false - name: Setup pnpm uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 # No registry-url here: setup-node would write an .npmrc with a token # placeholder, which can take precedence over OIDC trusted publishing. - name: Setup Node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version-file: .node-version cache: "pnpm" - name: Install dependencies run: pnpm install --frozen-lockfile - name: Build package run: pnpm build # Authenticates through npm trusted publishing (OIDC via id-token: write); # the trusted publisher on npmjs.com is bound to this workflow file. - name: Publish to npm run: pnpm publish --access public --provenance --no-git-checks build-binaries: name: Build Binary needs: [release-please] if: needs.release-please.outputs.releases_created == 'true' permissions: contents: read uses: ./.github/workflows/build-binaries.yml with: ref: ${{ needs.release-please.outputs.tag_name }} upload: true upload-release-assets: name: Upload Release Assets runs-on: ubuntu-latest timeout-minutes: 10 needs: [release-please, build-binaries] if: needs.release-please.outputs.releases_created == 'true' permissions: contents: write steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ needs.release-please.outputs.tag_name }} persist-credentials: false - name: Setup pnpm uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 - name: Setup Node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version-file: .node-version cache: "pnpm" - name: Install dependencies run: pnpm install --frozen-lockfile - name: Generate third-party licenses file run: pnpm build:licenses - name: Download all binary artifacts uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: binary-* path: dist/all-binaries merge-multiple: true - name: Package release archives and checksums run: | pnpm package:release dist/all-binaries dist/release-assets ls -lh dist/release-assets - name: Upload assets to GitHub Release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | TARGET_TAG="${{ needs.release-please.outputs.tag_name }}" echo "Uploading release assets for tag: $TARGET_TAG" gh release upload "$TARGET_TAG" dist/release-assets/* --clobber NODE_VERSION="$(node -v)" CURRENT_NOTES="$(gh release view "$TARGET_TAG" --json body -q .body 2>/dev/null || true)" if ! echo "$CURRENT_NOTES" | grep -q "Bundled Standalone Binary Environment"; then echo "Annotating release notes with Node.js runtime version: $NODE_VERSION" NOTE_FILE="$(mktemp)" printf "%s\n\n### Bundled Standalone Binary Environment\n\n* **Node.js Runtime**: \`%s\` (Single Executable Application)\n" "$CURRENT_NOTES" "$NODE_VERSION" > "$NOTE_FILE" gh release edit "$TARGET_TAG" --notes-file "$NOTE_FILE" rm -f "$NOTE_FILE" fi