Skip to content

Commit e88b641

Browse files
phryneasCopilotjerelmiller
authored
Move prerelease publishing logic into release.yml (apollographql#13062)
npm OIDC only allows publishing from one workflow file, not from multiple, so these have to combined into one. `NPM_TOKEN` shouldn't be necessary for any `npm` calls, but afaik, changesets looks for the variable to be set, so I'm setting it to an empty string. --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: phryneas <[email protected]> Co-authored-by: Jerel Miller <[email protected]> Co-authored-by: jerelmiller <[email protected]>
1 parent b639e61 commit e88b641

File tree

3 files changed

+62
-90
lines changed

3 files changed

+62
-90
lines changed

.github/workflows/prerelease.yml

Lines changed: 7 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
contents: write
2222
pull-requests: write
2323
id-token: write
24-
outputs:
25-
packages: ${{ steps.changesets.outputs.publishedPackages }}
2624
steps:
2725
- uses: actions/create-github-app-token@v1
2826
id: github-actions-bot-app-token
@@ -40,6 +38,12 @@ jobs:
4038
# with the correct commits
4139
fetch-depth: 0
4240

41+
- name: Check for pre.json file existence
42+
id: check_files
43+
uses: andstor/[email protected]
44+
with:
45+
files: ".changeset/pre.json"
46+
4347
- name: Setup Node.js
4448
uses: actions/setup-node@v6
4549
with:
@@ -48,12 +52,6 @@ jobs:
4852
- name: Install dependencies with cache
4953
uses: bahmutov/npm-install@v1
5054

51-
- name: Check for pre.json file existence
52-
id: check_files
53-
uses: andstor/[email protected]
54-
with:
55-
files: ".changeset/pre.json"
56-
5755
- name: Enter prerelease mode (alpha by default)
5856
# If .changeset/pre.json does not exist and we did not recently exit
5957
# prerelease mode, enter prerelease mode with tag alpha
@@ -73,76 +71,6 @@ jobs:
7371
uses: changesets/action@v1
7472
with:
7573
version: npm run changeset-version
74+
publish: echo "This step should never publish"
7675
env:
7776
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
79-
- name: Publish to npm + GitHub
80-
id: changesets
81-
# Only run publish if we're still in pre mode and the last commit was
82-
# via an automatically created Version Packages PR
83-
if: steps.check_files.outputs.files_exists == 'true' && startsWith(github.event.head_commit.message, 'Version Packages')
84-
uses: changesets/action@v1
85-
with:
86-
version: echo "This step should never version"
87-
publish: npm run changeset-publish
88-
env:
89-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90-
NPM_TOKEN: ""
91-
92-
postrelease:
93-
name: Postrelease
94-
runs-on: ubuntu-latest
95-
needs: prerelease
96-
if: needs.prerelease.result == 'success' && fromJSON(needs.prerelease.outputs.packages)[0] != null
97-
strategy:
98-
matrix:
99-
package: ${{ fromJSON(needs.prerelease.outputs.packages) }}
100-
steps:
101-
- uses: actions/create-github-app-token@v1
102-
id: github-actions-bot-app-token
103-
with:
104-
app-id: 819772
105-
private-key: ${{ secrets.APOLLO_GITHUB_ACTIONS_BOT_PRIVATE_KEY }}
106-
107-
- name: Checkout repo
108-
uses: actions/checkout@v5
109-
with:
110-
token: ${{ steps.github-actions-bot-app-token.outputs.token }}
111-
112-
- name: Setup Node.js
113-
uses: actions/setup-node@v6
114-
with:
115-
node-version: "24.x"
116-
117-
- name: Install dependencies with cache
118-
uses: bahmutov/npm-install@v1
119-
120-
- name: Tag release with next on npm
121-
run: |
122-
if NEXT=$(npm show ${{ matrix.package.name }}@next version) node -e 'process.exit(require("semver").gt("${{ matrix.package.version }}",process.env.NEXT)?0:1)'; then
123-
npm dist-tag add ${{ matrix.package.name }}@${{ matrix.package.version }} next;
124-
fi
125-
126-
- name: Send a Slack notification on publish
127-
id: slack
128-
uses: slackapi/[email protected]
129-
with:
130-
# Slack channel id, channel name, or user id to post message
131-
# See also: https://api.slack.com/methods/chat.postMessage#channels
132-
# You can pass in multiple channels to post to by providing
133-
# a comma-delimited list of channel IDs
134-
channel-id: "C01PS0CB41G"
135-
payload: |
136-
{
137-
"blocks": [
138-
{
139-
"type": "section",
140-
"text": {
141-
"type": "mrkdwn",
142-
"text": "A new version of `${{ matrix.package.name }}` was released: <https://github.com/apollographql/apollo-client/releases/tag/${{ matrix.package.name }}@${{ matrix.package.version }}|v${{ matrix.package.version }}> :rocket:"
143-
}
144-
}
145-
]
146-
}
147-
env:
148-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/release.yml

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- "release-*"
78

89
concurrency: ${{ github.workflow }}-${{ github.ref }}
910

@@ -21,8 +22,8 @@ jobs:
2122
pull-requests: write
2223
id-token: write
2324
outputs:
24-
published: ${{ steps.changesets.outputs.published }}
25-
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
25+
published: ${{ steps.changesets.outputs.published || steps.changesets-prerelease.outputs.published }}
26+
publishedPackages: ${{ steps.changesets.outputs.publishedPackages || steps.changesets-prerelease.outputs.publishedPackages }}
2627
steps:
2728
- name: Checkout repo
2829
uses: actions/checkout@v5
@@ -41,13 +42,14 @@ jobs:
4142
uses: actions/setup-node@v6
4243
with:
4344
node-version: "24.x"
45+
registry-url: "https://registry.npmjs.org"
4446

4547
- name: Install dependencies (with cache)
4648
uses: bahmutov/npm-install@v1
4749

48-
- name: Create release PR or publish to npm + GitHub
50+
- name: "[main] Create release PR or publish to npm + GitHub"
4951
id: changesets
50-
if: steps.check_files.outputs.files_exists == 'false'
52+
if: github.ref_name == 'main' && steps.check_files.outputs.files_exists == 'false'
5153
uses: changesets/action@v1
5254
with:
5355
version: npm run changeset-version
@@ -56,8 +58,21 @@ jobs:
5658
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5759
NPM_TOKEN: ""
5860

59-
postrelease:
60-
name: Postrelease
61+
- name: "[prerelease] Publish to npm + GitHub"
62+
id: changesets-prerelease
63+
# Only run publish if we're still in pre mode and the last commit was
64+
# via an automatically created Version Packages PR
65+
if: github.ref_name != 'main' && steps.check_files.outputs.files_exists == 'true' && startsWith(github.event.head_commit.message, 'Version Packages')
66+
uses: changesets/action@v1
67+
with:
68+
version: echo "This step should never version"
69+
publish: npm run changeset-publish
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
NPM_TOKEN: ""
73+
74+
slack-notification:
75+
name: Postrelease Slack Notification
6176
runs-on: ubuntu-latest
6277
needs: release
6378
if: needs.release.result == 'success' && needs.release.outputs.published == 'true'
@@ -93,7 +108,7 @@ jobs:
93108
},
94109
{
95110
"type": "mrkdwn",
96-
"text": "*Tag:*\n`latest`"
111+
"text": "*Tag:*\n`${{ github.ref_name == 'main' && 'latest' || 'next' }}`"
97112
},
98113
{
99114
"type": "mrkdwn",
@@ -109,3 +124,32 @@ jobs:
109124
}
110125
env:
111126
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
127+
128+
tag-next:
129+
name: Postrelease Tag Next Release
130+
runs-on: ubuntu-latest
131+
needs: release
132+
if: github.ref_name != 'main' && needs.release.result == 'success' && needs.release.outputs.published == 'true'
133+
permissions:
134+
id-token: write
135+
strategy:
136+
matrix:
137+
package: ${{ fromJSON(needs.release.outputs.publishedPackages) }}
138+
steps:
139+
- name: Checkout repo
140+
uses: actions/checkout@v5
141+
142+
- name: Setup Node.js
143+
uses: actions/setup-node@v6
144+
with:
145+
node-version: "24.x"
146+
registry-url: "https://registry.npmjs.org"
147+
148+
- name: Install dependencies with cache
149+
uses: bahmutov/npm-install@v1
150+
151+
- name: Tag release with next on npm
152+
run: |
153+
if NEXT=$(npm show ${{ matrix.package.name }}@next version) node -e 'process.exit(require("semver").gt("${{ matrix.package.version }}",process.env.NEXT)?0:1)'; then
154+
npm dist-tag add ${{ matrix.package.name }}@${{ matrix.package.version }} next;
155+
fi

.size-limits.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 44137,
3-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 38945,
4-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33597,
5-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27603
2+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 44088,
3+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 38925,
4+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33546,
5+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27621
66
}

0 commit comments

Comments
 (0)