Publish npm packages #10
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: Publish npm packages | |
| on: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: [completed] | |
| branches: [develop] | |
| concurrency: | |
| group: npm-release | |
| cancel-in-progress: false | |
| permissions: | |
| actions: read | |
| contents: read | |
| env: | |
| BUN_VERSION: "1.3.14" | |
| NODE_VERSION: "24.3.0" | |
| NPM_VERSION: "11.18.0" | |
| jobs: | |
| identity: | |
| if: >- | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && | |
| github.event.workflow_run.head_branch == 'develop' && | |
| github.event.workflow_run.head_repository.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| outputs: | |
| commit: ${{ steps.preflight.outputs.commit }} | |
| ci_run_id: ${{ steps.preflight.outputs.ci_run_id }} | |
| steps: | |
| - name: Checkout successful CI commit | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| fetch-depth: 0 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: Validate successful CI release identity | |
| id: preflight | |
| env: | |
| EXPECTED_SHA: ${{ github.event.workflow_run.head_sha }} | |
| CI_RUN_ID: ${{ github.event.workflow_run.id }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| GH_TOKEN: ${{ github.token }} | |
| run: bun scripts/release-preflight.ts | |
| publish: | |
| needs: identity | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| environment: npm-release | |
| permissions: | |
| actions: read | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| steps: | |
| - name: Checkout release commit | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| ref: ${{ needs.identity.outputs.commit }} | |
| fetch-depth: 0 | |
| - name: Setup Node and npm registry | |
| uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| registry-url: https://registry.npmjs.org | |
| - name: Install pinned npm | |
| run: npm install --global "npm@$NPM_VERSION" | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 | |
| with: | |
| bun-version: ${{ env.BUN_VERSION }} | |
| - name: Install compatibility validation dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Validate fresh compatibility test set | |
| run: bun run compatibility:validate | |
| - name: Download canonical artifacts from successful CI | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| CI_RUN_ID: ${{ needs.identity.outputs.ci_run_id }} | |
| run: gh run download "$CI_RUN_ID" --name canonical-release-artifacts --dir test-results/release-artifacts | |
| - name: Hydrate canonical package outputs | |
| run: bun scripts/hydrate-release-artifacts.ts test-results/release-artifacts | |
| - name: Verify local compatibility results | |
| run: bun run compatibility:check -- --allow-unclaimed | |
| - name: Publish unpublished package versions | |
| id: publish | |
| env: | |
| EXPECTED_SHA: ${{ needs.identity.outputs.commit }} | |
| run: bun scripts/release-publish.ts test-results/release-artifacts | |
| - name: Create verified package releases | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| EXPECTED_SHA: ${{ needs.identity.outputs.commit }} | |
| VERIFIED_PACKAGES: ${{ steps.publish.outputs.verified }} | |
| PUBLISHED_PACKAGES: ${{ steps.publish.outputs.published }} | |
| run: bun scripts/release-github.ts | |
| - name: Generate published package size history | |
| id: size-history | |
| if: steps.publish.outputs.verified != '[]' | |
| run: | | |
| VERSION="$(node -p "require('./packages/core/package.json').version")" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| bun run size:record --version="$VERSION" | |
| bun run docs:generate | |
| - name: Open package size history pull request | |
| if: steps.publish.outputs.verified != '[]' | |
| uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11 | |
| with: | |
| token: ${{ github.token }} | |
| base: develop | |
| branch: automation/package-size-history-${{ steps.size-history.outputs.version }} | |
| delete-branch: true | |
| commit-message: "chore: record v${{ steps.size-history.outputs.version }} package sizes" | |
| title: "chore: record v${{ steps.size-history.outputs.version }} package sizes" | |
| body: "Automated registry size history captured after the verified npm publication." | |
| add-paths: | | |
| scripts/size-history.json | |
| docs/src/content/docs/guides/performance-resources.md | |
| docs/src/generated/docs-contract.json |