name: Release on: push: branches: - main - version-3.x - "release-*" concurrency: ${{ github.workflow }}-${{ github.ref }} permissions: {} jobs: release: name: Changesets Release # Prevents action from creating a PR on forks if: github.repository == 'apollographql/apollo-client' runs-on: ubuntu-latest # Permissions necessary for Changesets to push a new branch and open PRs # (for automated Version Packages PRs), and request an id-token for provenance. # More info: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings permissions: contents: write pull-requests: write id-token: write outputs: published: ${{ steps.changesets.outputs.published || steps.changesets-prerelease.outputs.published }} publishedPackages: ${{ steps.changesets.outputs.publishedPackages || steps.changesets-prerelease.outputs.publishedPackages }} steps: - name: Checkout repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: # Fetch entire git history so Changesets can generate changelogs # with the correct commits fetch-depth: 0 persist-credentials: false - name: Check for pre.json file existence id: check_files uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0 with: files: ".changeset/pre.json" - name: Setup Node.js uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 with: node-version: "24.x" registry-url: "https://registry.npmjs.org" # deliberately not using a cache for action with elevated permissions, see https://tanstack.com/blog/npm-supply-chain-compromise-postmortem package-manager-cache: false # `npm stage publish` (https://docs.npmjs.com/staged-publishing) requires # npm >= 11.15.0. Node 24.x currently bundles at most 11.13.0, so upgrade. - run: npm install -g npm@11.15.0 - run: npm ci - name: "[main] Create release PR or publish to npm + GitHub" id: changesets if: contains(fromJSON('["main", "version-3.x"]'), github.ref_name) && steps.check_files.outputs.files_exists == 'false' uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1 with: version: npm run changeset-version publish: npm run changeset-publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: "" - name: "[prerelease] Publish to npm + GitHub" id: changesets-prerelease # Only run publish if we're still in pre mode and the last commit was # via an automatically created Version Packages PR if: github.ref_name != 'main' && github.ref_name != 'version-3.x' && steps.check_files.outputs.files_exists == 'true' && startsWith(github.event.head_commit.message, 'Version Packages') uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1 with: version: echo "This step should never version" publish: npm run changeset-publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: "" devtools-errorcodes: name: Trigger Devtools Error Code Update needs: release if: needs.release.result == 'success' && needs.release.outputs.published == 'true' runs-on: ubuntu-latest permissions: {} steps: - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3 id: github-actions-bot-app-token with: app-id: 819772 private-key: ${{ secrets.APOLLO_GITHUB_ACTIONS_BOT_PRIVATE_KEY }} repositories: apollo-client-devtools - uses: benc-uk/workflow-dispatch@7a027648b88c2413826b6ddd6c76114894dc5ec4 # v1 with: workflow: update-errorcodes.yml repo: apollographql/apollo-client-devtools ref: main token: ${{ steps.github-actions-bot-app-token.outputs.token }}