Merge remote-tracking branch 'origin/main' into release-3.9 #206
This file contains 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: Prerelease | |
on: | |
push: | |
branches: | |
# Target release-x.x branches | |
- "release-*" | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
prerelease: | |
name: Changesets Prerelease | |
# Prevents changesets 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 the JWT 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 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
# Fetch entire git history so Changesets can generate changelogs | |
# with the correct commits | |
fetch-depth: 0 | |
- name: Append NPM token to .npmrc | |
run: | | |
cat << EOF > "$HOME/.npmrc" | |
provenance=true | |
//registry.npmjs.org/:_authToken=$NPM_TOKEN | |
EOF | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Setup Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: Install dependencies with cache | |
uses: bahmutov/npm-install@v1 | |
- name: Check for pre.json file existence | |
id: check_files | |
uses: andstor/[email protected] | |
with: | |
files: ".changeset/pre.json" | |
- name: Enter prerelease mode (alpha by default) | |
# If .changeset/pre.json does not exist and we did not recently exit | |
# prerelease mode, enter prerelease mode with tag alpha | |
if: steps.check_files.outputs.files_exists == 'false' && !contains(github.event.head_commit.message, 'Exit prerelease') | |
run: npx changeset pre enter alpha | |
- name: Create prerelease PR | |
uses: changesets/action@v1 | |
with: | |
version: npm run changeset-version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to npm + GitHub | |
id: changesets | |
# Only run publish if we're still in pre mode and the last commit was | |
# via an automatically created Version Packages PR | |
if: steps.check_files.outputs.files_exists == 'true' && startsWith(github.event.head_commit.message, 'Version Packages') | |
uses: changesets/action@v1 | |
with: | |
version: echo "This step should never version" | |
publish: npm run changeset-publish # by default, this will publish to npm and GitHub | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Tag release with next on npm | |
if: steps.changesets.outcome == 'success' | |
run: npm dist-tag add @apollo/client@${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }} next | |
- name: Send a Slack notification on publish | |
if: steps.changesets.outcome == 'success' | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
# Slack channel id, channel name, or user id to post message | |
# See also: https://api.slack.com/methods/chat.postMessage#channels | |
# You can pass in multiple channels to post to by providing | |
# a comma-delimited list of channel IDs | |
channel-id: "C01PS0CB41G" | |
payload: | | |
{ | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "A new version of `@apollo/client` was released: <https://github.com/apollographql/apollo-client/releases/tag/v${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}|v${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}> :rocket:" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |