cherry-pick publishing changes from next
#94
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: Release | |
on: | |
push: | |
branches: | |
- main | |
- next | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
publish: | |
if: github.repository == 'apollographql/apollo-client-nextjs' | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
pull-requests: write | |
steps: | |
# Create an access token for the Github Actions Bot app. This one has permissions | |
# to push directly to this repository (only!) without required status checks. | |
- uses: actions/create-github-app-token@v1 | |
id: github-actions-bot-app-token | |
with: | |
app-id: 819772 | |
private-key: ${{ secrets.APOLLO_GITHUB_ACTIONS_BOT_PRIVATE_KEY }} | |
# Check out the repository, using the Github Actions Bot app's token so that we | |
# can push later and override required statuses. | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.github-actions-bot-app-token.outputs.token }} | |
# Fetch entire git history so Changesets can generate changelogs | |
# with the correct commits | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20.11.0" | |
registry-url: "https://registry.npmjs.org" | |
cache: "yarn" | |
- run: yarn install --immutable --mode=skip-build | |
- name: Alpha branch - 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: github.ref_name == 'next' && !contains(github.event.head_commit.message, 'Exit prerelease') | |
run: | | |
if ! test -f ".changeset/pre.json"; then | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
npx changeset pre enter alpha | |
git add -A | |
git commit -m 'Enter prerelease mode' | |
git push | |
fi | |
- name: Append NPM token to .npmrc | |
run: | | |
cat << EOF > "$NPM_CONFIG_USERCONFIG" | |
provenance=true | |
//registry.npmjs.org/:_authToken=$NPM_TOKEN | |
EOF | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
version: yarn changeset-version | |
publish: yarn changeset publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |