name: Release on: push: branches: - main # Canary: publish a snapshot of the dispatched branch to the `next` dist-tag. # It lives in this file because npm trusted publishing is tied to one # workflow file (see scripts/npm-trust.sh). workflow_dispatch: # Reset permissions and grant them per job, so `id-token: write` only exists on # the jobs that publish. permissions: {} concurrency: ${{ github.workflow }}-${{ github.ref }} env: TURBO_TELEMETRY_DISABLED: 1 jobs: select-mode: name: Select mode if: github.event_name == 'push' runs-on: ubuntu-latest outputs: mode: ${{ steps.select-mode.outputs.mode }} publish-plan-artifact-id: ${{ steps.select-mode.outputs.publish-plan-artifact-id }} permissions: contents: read # to check out repo (actions/checkout) steps: - uses: actions/checkout@v7 with: persist-credentials: false - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - uses: actions/setup-node@v7 with: node-version-file: ".nvmrc" package-manager-cache: false # avoid cache poisoning - run: pnpm install --frozen-lockfile - name: Select Changesets mode id: select-mode uses: changesets/action/select-mode@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 version: name: Version packages if: needs.select-mode.outputs.mode == 'version' needs: select-mode runs-on: ubuntu-latest permissions: contents: write # to commit version changes (changesets/action/version) pull-requests: write # to open the "Version Packages" PR steps: - uses: actions/checkout@v7 with: persist-credentials: false # Full history so the changelog can link each entry to the PR that # added its changeset. fetch-depth: 0 - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - uses: actions/setup-node@v7 with: node-version-file: ".nvmrc" package-manager-cache: false # avoid cache poisoning - run: pnpm install --frozen-lockfile - name: Version packages uses: changesets/action/version@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 with: # `changeset version`, then refresh the lockfile in the same commit. script: pnpm run version # NOTE: CI runs on PRs opened or updated with the default # GITHUB_TOKEN are held for approval. After the PR's latest update, # a maintainer clicks "Approve and run". Or pass a fine-grained # token / GitHub App token here (see #3093). env: # For the changelog plugin (scripts/changelog.js), which looks up the # PR for each changeset's commit through the GitHub API. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} pack: name: Pack tarballs if: needs.select-mode.outputs.mode == 'publish' needs: select-mode runs-on: ubuntu-latest outputs: pack-dir-artifact-id: ${{ steps.pack.outputs.pack-dir-artifact-id }} permissions: contents: read # to check out repo (actions/checkout) steps: - uses: actions/checkout@v7 with: persist-credentials: false - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - uses: actions/setup-node@v7 with: node-version-file: ".nvmrc" package-manager-cache: false # avoid cache poisoning - run: pnpm install --frozen-lockfile # Packages have no `prepack` build, so build before packing. - run: pnpm run build - name: Pack packages id: pack uses: changesets/action/pack@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 with: publish-plan-artifact-id: ${{ needs.select-mode.outputs.publish-plan-artifact-id }} publish: name: Publish to npm needs: pack runs-on: ubuntu-latest # The environment limits which branches can publish, and is what npm # trusted publishing is bound to. If it has required reviewers, the job # also waits for approval before anything reaches npm. environment: npm-publish permissions: contents: write # to create the git tag and GitHub release id-token: write # for npm trusted publishing (OIDC) steps: - uses: actions/checkout@v7 with: persist-credentials: false - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - uses: actions/setup-node@v7 with: node-version-file: ".nvmrc" registry-url: "https://registry.npmjs.org" package-manager-cache: false # avoid cache poisoning - run: pnpm install --frozen-lockfile - name: Publish packages id: publish uses: changesets/action/publish@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 with: pack-dir-artifact-id: ${{ needs.pack.outputs.pack-dir-artifact-id }} # One `v{version}` tag and one aggregate release (next step), not one # per package. create-github-releases: false push-git-tags: false - name: Create GitHub release if: steps.publish.outputs.published == 'true' run: | VERSION="$(node -p "require('./packages/victory/package.json').version")" gh release create "v${VERSION}" \ --repo "${GITHUB_REPOSITORY}" \ --target "${GITHUB_SHA}" \ --title "v${VERSION}" \ --generate-notes env: GH_TOKEN: ${{ github.token }} canary: name: Canary (next) if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest # Same environment as publish: trusted publishing is configured for it, and # its branch rules decide which branches may publish a canary. environment: npm-publish permissions: contents: read # to check out repo (actions/checkout) pull-requests: read # for the changelog plugin's PR lookups id-token: write # for npm trusted publishing (OIDC) steps: - uses: actions/checkout@v7 with: persist-credentials: false - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - uses: actions/setup-node@v7 with: node-version-file: ".nvmrc" registry-url: "https://registry.npmjs.org" package-manager-cache: false # avoid cache poisoning - run: pnpm install --frozen-lockfile # Versions like `37.4.0-canary-` (snapshot.useCalculatedVersion). # Needs at least one pending changeset; otherwise nothing is versioned. - run: pnpm changeset version --snapshot canary env: # For the changelog plugin, which looks up each changeset's PR through # the GitHub API (snapshot versioning still writes changelogs). GITHUB_TOKEN: ${{ github.token }} - run: pnpm run build - run: pnpm changeset publish --tag next --no-git-tag