# Push: four-phase zx-bulk-release flow. # receive — trusted, runs before deps install: consumes rebuild signals, resolves versions, emits the context # pack — untrusted: installs deps, builds, tests and packs parcels; holds no write token and no OIDC # deliver — trusted, clean runner: verifies parcels against the context, delivers them, pushes coverage # PR: build, test and compat checks only. name: CI on: push: branches: [master] tags: ['zbr-rebuild.*'] pull_request: permissions: {} env: ZBR: zx-bulk-release@4.0.0 # one version for every phase, keep in sync with yarn.lock jobs: receive: name: Receive if: github.event_name == 'push' runs-on: ubuntu-24.04 permissions: contents: write # consume zbr-rebuild.* tags outputs: status: ${{ steps.receive.outputs.status }} context: ${{ steps.receive.outputs.context }} fetch-depth: ${{ steps.depth.outputs.value }} steps: - name: Fetch depth id: depth env: COMMITS_JSON: ${{ toJSON(github.event.commits) }} run: echo "value=$(echo "$COMMITS_JSON" | jq 'length | if . < 20 then . + 1 else 0 end')" >> "$GITHUB_OUTPUT" - name: Checkout uses: actions/checkout@v6 # zizmor: ignore[artipacked] zbr deletes rebuild tags via `origin`; no deps are installed in this job with: fetch-depth: ${{ steps.depth.outputs.value }} - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: 24 package-manager-cache: false # explicit opt-out: setup-node v6 auto-enables cache when `packageManager` is set in package.json - name: Receive id: receive env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # also puts the gh-release channel into the context run: | npx "$ZBR" --receive echo "context=$(jq -c . zbr-context.json)" >> "$GITHUB_OUTPUT" pack: name: Pack needs: receive runs-on: ubuntu-24.04 permissions: contents: read steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: ${{ needs.receive.outputs.fetch-depth }} persist-credentials: false - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: 24 package-manager-cache: false - name: Cache yarn (restore+save) uses: actions/cache@v4 # zizmor: ignore[cache-poisoning] runs only on master and zbr-rebuild pushes (gated by `receive`) with: path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }} restore-keys: | yarn-${{ runner.os }}- - name: Setup Bun Runtime uses: antongolub/action-setup-bun@38d526c08108ece77f46bf61e78988c7fc0ce5ab # v1.9.1 - uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2.0.4 with: deno-version: v1.x - name: Fetch deps run: yarn --silent --immutable - name: Build run: | yarn warmup yarn build env: VERBOSE: true - name: Coverage run: yarn cov - name: Save coverage uses: actions/upload-artifact@v7 with: name: coverage-${{ github.run_id }} path: | lcov.info lcov-sum.json retention-days: 1 - name: Restore context if: needs.receive.outputs.status == 'proceed' env: ZBR_CONTEXT: ${{ needs.receive.outputs.context }} run: echo "$ZBR_CONTEXT" > zbr-context.json - name: Pack if: needs.receive.outputs.status == 'proceed' run: npx "$ZBR" --pack --no-build --no-test - name: Upload parcels if: needs.receive.outputs.status == 'proceed' uses: actions/upload-artifact@v7 with: name: parcels-${{ github.run_id }} path: parcels retention-days: 1 deliver: name: Deliver needs: [receive, pack] runs-on: ubuntu-24.04 environment: release permissions: contents: write # git tags, gh releases, `lcov` release assets id-token: write # npm trusted publishing steps: - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: 24 package-manager-cache: false # Taken from `receive` outputs: unlike run artifacts, a compromised `pack` cannot replace them - name: Restore context env: ZBR_CONTEXT: ${{ needs.receive.outputs.context }} run: echo "$ZBR_CONTEXT" > zbr-context.json - name: Download parcels if: needs.receive.outputs.status == 'proceed' uses: actions/download-artifact@v8 with: name: parcels-${{ github.run_id }} path: parcels-unverified - name: Verify if: needs.receive.outputs.status == 'proceed' run: npx "$ZBR" --verify parcels-unverified/:parcels/ - name: Deliver if: needs.receive.outputs.status == 'proceed' env: NPM_OIDC: true GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GIT_COMMITTER_NAME: ${{ vars.GIT_COMMITTER_NAME }} GIT_COMMITTER_EMAIL: ${{ vars.GIT_COMMITTER_EMAIL }} run: npx "$ZBR" --deliver - name: Update delivery status if: needs.receive.outputs.status == 'proceed' uses: actions/upload-artifact@v7 with: name: parcels-${{ github.run_id }} path: parcels overwrite: true retention-days: 1 # Coverage goes out on every push, regardless of the delivery outcome - name: Download coverage if: ${{ !cancelled() }} uses: actions/download-artifact@v8 with: name: coverage-${{ github.run_id }} - name: Push coverage if: ${{ !cancelled() }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh release upload lcov lcov.info lcov-sum.json --clobber --repo "$GITHUB_REPOSITORY" # Not in deliver: qlty-action runs a CLI downloaded at runtime with the whole job env qlty: name: Qlty needs: pack runs-on: ubuntu-24.04 permissions: contents: read steps: - name: Checkout uses: actions/checkout@v6 with: persist-credentials: false - name: Download coverage uses: actions/download-artifact@v8 with: name: coverage-${{ github.run_id }} - name: Qlty.sh (codeclimate) uses: qltysh/qlty-action/coverage@a19242102d17e497f437d7466aa01b528537e899 # v2.2.0 with: token: ${{ secrets.QLTY_TOKEN }} files: ${{github.workspace}}/lcov.info pr: if: github.event_name == 'pull_request' name: PR runs-on: ubuntu-24.04 permissions: contents: read steps: # https://github.com/actions/checkout/issues/552 - name: Fetch depth env: PR_COMMITS: ${{ github.event.pull_request.commits }} run: echo "PR_FETCH_DEPTH=$(( PR_COMMITS + 1 ))" >> "${GITHUB_ENV}" - name: Checkout uses: actions/checkout@v6 with: ref: ${{ github.event.pull_request.head.ref }} fetch-depth: ${{ env.PR_FETCH_DEPTH }} persist-credentials: false - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: 24 package-manager-cache: false - name: Cache yarn (restore-only) uses: actions/cache/restore@v4 # zizmor: ignore[cache-poisoning] read-only restore, cannot poison shared cache with: path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }} restore-keys: | yarn-${{ runner.os }}- - name: Setup Bun Runtime uses: antongolub/action-setup-bun@38d526c08108ece77f46bf61e78988c7fc0ce5ab # v1.9.1 - name: Setup Deno uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2.0.4 with: deno-version: v1.x - name: Fetch deps run: yarn --silent --immutable - name: Build run: | yarn warmup yarn build - name: Save artifacts uses: actions/upload-artifact@v7 with: name: target path: | package.json packages/**/target/esm/**/* packages/**/target/cjs/**/* packages/**/target/dts/**/* packages/**/target/coverage/lcov.info pr-compat: needs: pr name: Compat test (Node v${{ matrix.node-version }}, OS ${{ matrix.os }}) permissions: contents: read strategy: matrix: os: [ ubuntu-24.04, windows-latest ] node-version: [ 18, 24 ] runs-on: ${{ matrix.os }} steps: # https://github.com/actions/checkout/issues/552 - name: Fetch depth shell: bash env: PR_COMMITS: ${{ github.event.pull_request.commits }} run: echo "PR_FETCH_DEPTH=$(( PR_COMMITS + 1 ))" >> "${GITHUB_ENV}" - name: Checkout uses: actions/checkout@v6 with: ref: ${{ github.event.pull_request.head.ref }} fetch-depth: ${{ env.PR_FETCH_DEPTH }} persist-credentials: false - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} package-manager-cache: false - name: Cache yarn (restore-only) uses: actions/cache/restore@v4 # zizmor: ignore[cache-poisoning] read-only restore, cannot poison shared cache with: path: .yarn/cache key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }} restore-keys: | yarn-${{ runner.os }}- - name: Download artifacts uses: actions/download-artifact@v8 with: name: target - name: Fetch deps run: yarn --silent --immutable - name: Integration test run: yarn test --testCmd="yarn test:it"