--- # npm pins a workflow filename per trusted publisher, and every package in this # repository is registered against `ci.yml`. The publishing lane therefore owns # that filename and the pull-request lane is `verify.yml`, so renaming this file # silently breaks OIDC publishing for all of them at once. name: Release npm packages on: push: branches: [main] paths: - .github/npm-release-plan.json permissions: contents: read concurrency: group: npm-production cancel-in-progress: false jobs: # its own job so the actionlint download and shellcheck run never sit in # front of the pack; `publish` needs it, so it still gates the release lint-workflows: name: Lint workflows runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Check out the exact release revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} persist-credentials: false - name: Lint GitHub Actions workflows uses: ./.github/actions/lint-workflows pack: name: Verify and pack the exact release runs-on: ubuntu-latest # the shared gates now include coverage enforcement on top of packing timeout-minutes: 90 outputs: package_node_matrix: ${{ steps.verify.outputs.package-node-matrix }} release_artifact_id: ${{ steps.release_artifacts.outputs.artifact-id }} steps: - name: Require main run: test "$GITHUB_REF" = refs/heads/main - name: Check out the exact release revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} fetch-depth: 0 persist-credentials: false # the same shared action CI runs, so the publish path can never enforce # less than the pull-request path; the tests job runs the examples # against the archived build instead of repeating them here, and the # workflow lint is its own job that `publish` waits on - name: Verify the repository id: verify uses: ./.github/actions/verify-repository with: examples: "false" # Nothing published to npm comes out of a cache. The job installs and # builds cold, then seeds later main/PR caches only after validation. cache: "save-only" - name: Upload repository verification telemetry if: always() && steps.verify.outputs.telemetry-file != '' uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: release-verification-telemetry path: ${{ steps.verify.outputs.telemetry-file }} if-no-files-found: error overwrite: true retention-days: 30 - name: Archive built test inputs run: >- tar --create --gzip --file "${{ runner.temp }}/built-packages.tar.gz" packages/*/dist packages/*/types data/dist - name: Pack immutable npm artifacts run: >- node ops/scripts/npm-release.js pack --plan .github/npm-release-plan.json --output npm-release-artifacts - name: Rebuild and verify reproducible npm artifacts run: | npm run build -- '--filter=./packages/**' --force npm run build -- '--filter=./data/**' --force node ops/scripts/npm-release.js pack \ --plan .github/npm-release-plan.json \ --output "${{ runner.temp }}/npm-release-reproducibility" \ --reference npm-release-artifacts/manifest.json - name: Verify isolated consumers of the exact publish artifacts run: >- node ops/scripts/npm-release.js verify-consumers --manifest npm-release-artifacts/manifest.json --concurrency 8 - name: Pack all Node compatibility artifacts run: >- node ops/scripts/package-node-compatibility.js pack --output "${{ runner.temp }}/package-node-artifacts" - name: Upload built test inputs uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: release-built-packages path: ${{ runner.temp }}/built-packages.tar.gz compression-level: 0 if-no-files-found: error overwrite: true retention-days: 1 - name: Upload immutable npm artifacts id: release_artifacts uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: npm-release-artifacts path: npm-release-artifacts/ compression-level: 0 if-no-files-found: error overwrite: true retention-days: 30 - name: Upload all Node compatibility artifacts uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: release-package-node-artifacts path: ${{ runner.temp }}/package-node-artifacts/ compression-level: 0 if-no-files-found: error overwrite: true retention-days: 1 tests: name: Release ${{ matrix.name }} needs: pack runs-on: ubuntu-latest timeout-minutes: 30 strategy: fail-fast: false matrix: include: - name: examples command: examples steps: - name: Check out the exact release revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} fetch-depth: 1 persist-credentials: false - name: Set up Node and npm uses: ./.github/actions/setup-node - name: Install dependencies run: npm ci - name: Download built test inputs uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: release-built-packages path: ${{ runner.temp }}/built-packages - name: Restore built test inputs run: tar --extract --gzip --file "${{ runner.temp }}/built-packages/built-packages.tar.gz" - name: Run ${{ matrix.name }} run: npm run turbo -- run "${{ matrix.command }}" --filter='./packages/**' --only package-node-compatibility: name: All packages / Node ${{ matrix.node-major }} needs: pack runs-on: ubuntu-latest timeout-minutes: 60 strategy: fail-fast: false matrix: ${{ fromJSON(needs.pack.outputs.package_node_matrix) }} steps: - name: Check out the exact release revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} fetch-depth: 1 persist-credentials: false - name: Set up package runtime uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: ${{ matrix.node-version }} - name: Report the isolated runtime run: | node --version npm --version - name: Restore package-test npm downloads uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ${{ runner.temp }}/package-node-npm-cache key: package-node-downloads-v1-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('package-lock.json', 'ops/helpers/packageNodeCompatibility.js', 'ops/scripts/package-node-compatibility.js') }} - name: Download package compatibility artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: release-package-node-artifacts path: ${{ runner.temp }}/package-node-artifacts - name: Install, import, smoke-test and unit-test every eligible package run: >- node ops/scripts/package-node-compatibility.js verify --artifacts "${{ runner.temp }}/package-node-artifacts" --node-major "${{ matrix.node-major }}" --npm-cache "${{ runner.temp }}/package-node-npm-cache" --unit-concurrency 4 browser-iife-compatibility: name: All browser IIFEs / Chromium 58 needs: pack runs-on: ubuntu-22.04 timeout-minutes: 20 steps: - name: Check out the exact release revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} fetch-depth: 1 persist-credentials: false - name: Set up the pinned root toolchain uses: ./.github/actions/setup-node # the static half of the browser gate parses every bundle with TypeScript, # so this job needs the root dependencies even though the IIFEs it loads # are prebuilt - name: Install audit dependencies run: npm ci - name: Download built release inputs uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: release-built-packages path: ${{ runner.temp }}/built-packages - name: Restore built browser IIFEs run: >- tar --extract --gzip --file "${{ runner.temp }}/built-packages/built-packages.tar.gz" --wildcards 'packages/*/dist/*.umd.js' - name: Set up the minimum IIFE browser id: browser uses: ./.github/actions/setup-iife-browser - name: Load and smoke-test every IIFE in Chromium 58 run: >- xvfb-run --auto-servernum --server-args="-screen 0 1280x720x24 -nolisten tcp" node ops/scripts/verify-browser-iifes.js --browser "${{ steps.browser.outputs.browser-path }}" windows-smoke: name: Build scripts, packed CLIs and codsen-glob / Windows needs: pack runs-on: windows-latest timeout-minutes: 30 steps: - name: Check out the exact release revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} fetch-depth: 1 persist-credentials: false - name: Set up the pinned root toolchain uses: ./.github/actions/setup-node - name: Install build dependencies run: npm ci - name: Restore packed-smoke npm downloads uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ${{ runner.temp }}/package-node-npm-cache key: package-node-downloads-v1-${{ runner.os }}-root-${{ hashFiles('.node-version', 'package-lock.json', 'ops/helpers/packageNodeCompatibility.js', 'ops/scripts/package-node-compatibility.js') }} - name: Smoke-test the generated production build script run: npm run build --workspace=ast-contains-only-empty-space - name: Smoke-test the generated development build script run: npm run dev --workspace=ast-contains-only-empty-space - name: Smoke-test the examples runner run: npm run test:examples-runner - name: Download package compatibility artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: release-package-node-artifacts path: ${{ runner.temp }}/package-node-artifacts - name: Smoke-test packed CLIs and codsen-glob run: >- node ops/scripts/package-node-compatibility.js smoke --artifacts "${{ runner.temp }}/package-node-artifacts" --npm-cache "${{ runner.temp }}/package-node-npm-cache" publish: name: Publish to npm needs: - lint-workflows - pack - tests - package-node-compatibility - browser-iife-compatibility - windows-smoke runs-on: ubuntu-latest # npm can scan each of the nine dependency layers for 20 minutes before # their published metadata becomes readable; leave headroom for setup and # registry operations around that 180-minute verification ceiling. timeout-minutes: 240 environment: npm-production permissions: contents: read id-token: write steps: - name: Check out the exact release revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} fetch-depth: 0 persist-credentials: false - name: Set up Node and npm uses: ./.github/actions/setup-node with: cache: "false" - name: Download immutable npm artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: # A replaced artifact has a different ID. An absent output must also # fail instead of selecting every artifact in this run. artifact-ids: ${{ needs.pack.outputs.release_artifact_id || 'missing-artifact-id' }} path: npm-release-artifacts - name: Publish and verify every planned package env: NPM_CONFIG_PROVENANCE: "true" run: >- node ops/scripts/npm-release.js publish --manifest npm-release-artifacts/manifest.json --concurrency 8 tags: name: Push package tags needs: - pack - publish runs-on: ubuntu-latest timeout-minutes: 15 permissions: contents: write steps: - name: Check out the exact release revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} fetch-depth: 0 - name: Set up Node and npm uses: ./.github/actions/setup-node with: cache: "false" - name: Download the published manifest uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: artifact-ids: ${{ needs.pack.outputs.release_artifact_id || 'missing-artifact-id' }} path: npm-release-artifacts - name: Configure the tag author run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - name: Tag the verified release run: >- node ops/scripts/npm-release.js tags --manifest npm-release-artifacts/manifest.json --push --remote origin timing-summary: name: Release timing summary if: always() needs: - lint-workflows - pack - tests - package-node-compatibility - browser-iife-compatibility - windows-smoke - publish - tags runs-on: ubuntu-latest timeout-minutes: 5 permissions: actions: read contents: read steps: - name: Check out the exact release revision uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} fetch-depth: 1 persist-credentials: false - name: Set up the pinned Node runtime uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version-file: .node-version - name: Report compute and approval timings env: GITHUB_TOKEN: ${{ github.token }} run: node ops/scripts/summarize-github-run.js release