Skip to content

Commit 984415f

Browse files
feat(ci): Update release to use github env variables. (#11068)
1 parent 203bad7 commit 984415f

File tree

13 files changed

+351
-109
lines changed

13 files changed

+351
-109
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: 'NPM Auth Token'
2+
description: 'Generates an NPM auth token for publishing a specific package'
3+
4+
inputs:
5+
package-name:
6+
description: 'The name of the package to publish'
7+
required: true
8+
github-token:
9+
description: 'the github token'
10+
required: true
11+
wombat-token-core:
12+
description: 'The npm token for the cli-core package.'
13+
required: true
14+
wombat-token-cli:
15+
description: 'The npm token for the cli package.'
16+
required: true
17+
wombat-token-a2a-server:
18+
description: 'The npm token for the a2a package.'
19+
required: true
20+
21+
outputs:
22+
auth-token:
23+
description: 'The generated NPM auth token'
24+
value: '${{ steps.npm_auth_token.outputs.auth-token }}'
25+
26+
runs:
27+
using: 'composite'
28+
steps:
29+
- name: 'Generate NPM Auth Token'
30+
id: 'npm_auth_token'
31+
shell: 'bash'
32+
run: |
33+
AUTH_TOKEN="${{ inputs.github-token }}"
34+
PACKAGE_NAME="${{ inputs.package-name }}"
35+
PRIVATE_REPO="@google-gemini/"
36+
if [[ "$PACKAGE_NAME" == "$PRIVATE_REPO"* ]]; then
37+
AUTH_TOKEN="${{ inputs.github-token }}"
38+
elif [[ "$PACKAGE_NAME" == "@google/gemini-cli" ]]; then
39+
AUTH_TOKEN="${{ inputs.wombat-token-cli }}"
40+
elif [[ "$PACKAGE_NAME" == "@google/gemini-cli-core" ]]; then
41+
AUTH_TOKEN="${{ inputs.wombat-token-core }}"
42+
elif [[ "$PACKAGE_NAME" == "@google/gemini-cli-a2a-server" ]]; then
43+
AUTH_TOKEN="${{ inputs.wombat-token-a2a-server }}"
44+
fi
45+
echo "auth-token=$AUTH_TOKEN" >> $GITHUB_OUTPUT

.github/actions/publish-release/action.yml

Lines changed: 79 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ inputs:
99
description: 'The npm tag to publish with (e.g., latest, preview, nightly).'
1010
required: true
1111
wombat-token-core:
12-
description: 'The npm token for the @google/gemini-cli-core package.'
12+
description: 'The npm token for the cli-core package.'
1313
required: true
1414
wombat-token-cli:
15-
description: 'The npm token for the @google/gemini-cli package.'
15+
description: 'The npm token for the cli package.'
1616
required: true
1717
wombat-token-a2a-server:
18-
description: 'The npm token for the @google/gemini-cli-a2a-server package.'
18+
description: 'The npm token for the a2a package.'
1919
required: true
2020
github-token:
2121
description: 'The GitHub token for creating the release.'
@@ -51,10 +51,24 @@ inputs:
5151
gemini_api_key:
5252
description: 'The API key for running integration tests.'
5353
required: true
54-
registry:
55-
description: 'The registry to publish to.'
56-
required: false
57-
default: 'npm-wombat'
54+
npm-registry-publish-url:
55+
description: 'npm registry publish url'
56+
required: true
57+
npm-registry-url:
58+
description: 'npm registry url'
59+
required: true
60+
npm-registry-scope:
61+
description: 'npm registry scope'
62+
required: true
63+
cli-package-name:
64+
description: 'The name of the cli package.'
65+
required: true
66+
core-package-name:
67+
description: 'The name of the core package.'
68+
required: true
69+
a2a-package-name:
70+
description: 'The name of the a2a package.'
71+
required: true
5872
runs:
5973
using: 'composite'
6074
steps:
@@ -117,126 +131,125 @@ runs:
117131
run: |
118132
npm run bundle
119133
134+
# TODO: Refactor this github specific publishing script to be generalized based upon inputs.
120135
- name: '📦 Prepare for GitHub release'
121-
if: "inputs.registry == 'github'"
136+
if: "inputs.npm-registry-url == 'https://npm.pkg.github.com/'"
122137
working-directory: '${{ inputs.working-directory }}'
123138
shell: 'bash'
124139
run: |
125140
node ${{ github.workspace }}/scripts/prepare-github-release.js
126141
127142
- name: 'Configure npm for publishing to npm'
128-
if: "inputs.registry != 'github'"
129143
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020'
130144
with:
131145
node-version-file: '${{ inputs.working-directory }}/.nvmrc'
132-
registry-url: 'https://wombat-dressing-room.appspot.com'
133-
scope: '@google'
146+
registry-url: '${{inputs.npm-registry-publish-url}}'
147+
scope: '${{inputs.npm-registry-scope}}'
134148

135-
- name: 'Configure npm for publishing to GitHub'
136-
if: "inputs.registry == 'github'"
137-
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020'
149+
- name: 'Get core Token'
150+
uses: './.github/actions/npm-auth-token'
151+
id: 'core-token'
138152
with:
139-
node-version-file: '${{ inputs.working-directory }}/.nvmrc'
140-
registry-url: 'https://npm.pkg.github.com'
141-
scope: '@google-gemini'
142-
143-
- name: '📦 Publish @google/gemini-cli-core to npm'
144-
if: "inputs.registry != 'github'"
145-
working-directory: '${{ inputs.working-directory }}'
146-
env:
147-
NODE_AUTH_TOKEN: '${{ inputs.wombat-token-core }}'
148-
shell: 'bash'
149-
run: |
150-
if [ "${{ inputs.dry-run }}" == "true" ]; then
151-
npm publish --dry-run --workspace="@google/gemini-cli-core" --no-tag
152-
else
153-
npm publish --workspace="@google/gemini-cli-core" --no-tag
154-
fi
153+
package-name: '${{ inputs.core-package-name }}'
154+
github-token: '${{ inputs.github-token }}'
155+
wombat-token-core: '${{ inputs.wombat-token-core }}'
156+
wombat-token-cli: '${{ inputs.wombat-token-cli }}'
157+
wombat-token-a2a-server: '${{ inputs.wombat-token-a2a-server }}'
155158

156-
- name: '📦 Publish @google-gemini/gemini-cli-core to GitHub'
157-
if: "inputs.registry == 'github'"
159+
- name: '📦 Publish CORE to NPM'
158160
working-directory: '${{ inputs.working-directory }}'
159161
env:
160-
NODE_AUTH_TOKEN: '${{ inputs.github-token }}'
162+
NODE_AUTH_TOKEN: '${{ steps.core-token.outputs.auth-token }}'
161163
shell: 'bash'
162164
run: |
163165
npm publish \
164166
--dry-run="${{ inputs.dry-run }}" \
165-
--workspace="@google-gemini/gemini-cli-core" \
167+
--workspace="${{ inputs.core-package-name }}" \
166168
--no-tag
167169
168170
- name: '🔗 Install latest core package'
169171
working-directory: '${{ inputs.working-directory }}'
170-
if: "${{ inputs.dry-run != 'true' && inputs.registry != 'github' }}"
172+
if: "${{ inputs.dry-run != 'true' }}"
171173
shell: 'bash'
172174
run: |
173-
npm install "@google/gemini-cli-core@${{ inputs.release-version }}" \
174-
--workspace="@google/gemini-cli" \
175-
--workspace="@google/gemini-cli-a2a-server" \
175+
npm install "${{ inputs.core-package-name }}@${{ inputs.release-version }}" \
176+
--workspace="${{ inputs.cli-package-name }}" \
177+
--workspace="${{ inputs.a2a-package-name }}" \
176178
--save-exact
177179
178-
- name: '📦 Publish @google/gemini-cli to npm'
179-
if: "inputs.registry != 'github'"
180-
working-directory: '${{ inputs.working-directory }}'
181-
env:
182-
NODE_AUTH_TOKEN: '${{ inputs.wombat-token-cli }}'
183-
shell: 'bash'
184-
run: |
185-
if [ "${{ inputs.dry-run }}" == "true" ]; then
186-
npm publish --dry-run --workspace="@google/gemini-cli" --no-tag
187-
else
188-
npm publish --workspace="@google/gemini-cli" --no-tag
189-
fi
180+
- name: 'Get CLI Token'
181+
uses: './.github/actions/npm-auth-token'
182+
id: 'cli-token'
183+
with:
184+
package-name: '${{ inputs.cli-package-name }}'
185+
github-token: '${{ inputs.github-token }}'
186+
wombat-token-core: '${{ inputs.wombat-token-core }}'
187+
wombat-token-cli: '${{ inputs.wombat-token-cli }}'
188+
wombat-token-a2a-server: '${{ inputs.wombat-token-a2a-server }}'
190189

191-
- name: '📦 Publish @google-gemini/gemini-cli to GitHub'
192-
if: "inputs.registry == 'github'"
190+
- name: '📦 Publish CLI'
193191
working-directory: '${{ inputs.working-directory }}'
194192
env:
195-
NODE_AUTH_TOKEN: '${{ inputs.github-token }}'
193+
NODE_AUTH_TOKEN: '${{ steps.cli-token.outputs.auth-token }}'
196194
shell: 'bash'
197195
run: |
198196
npm publish \
199197
--dry-run="${{ inputs.dry-run }}" \
200-
--workspace="@google-gemini/gemini-cli" \
198+
--workspace="${{ inputs.cli-package-name }}" \
201199
--no-tag
202200
203-
- name: '📦 Publish @google/gemini-cli-a2a-server'
204-
if: "inputs.registry != 'github'"
201+
- name: 'Get a2a-server Token'
202+
uses: './.github/actions/npm-auth-token'
203+
id: 'a2a-token'
204+
with:
205+
package-name: '${{ inputs.a2a-package-name }}'
206+
github-token: '${{ inputs.github-token }}'
207+
wombat-token-core: '${{ inputs.wombat-token-core }}'
208+
wombat-token-cli: '${{ inputs.wombat-token-cli }}'
209+
wombat-token-a2a-server: '${{ inputs.wombat-token-a2a-server }}'
210+
211+
- name: '📦 Publish a2a'
205212
working-directory: '${{ inputs.working-directory }}'
206213
env:
207-
NODE_AUTH_TOKEN: '${{ inputs.wombat-token-a2a-server }}'
214+
NODE_AUTH_TOKEN: '${{ steps.a2a-token.outputs.auth-token }}'
208215
shell: 'bash'
209216
# Tag staging for initial release
210217
run: |
211-
if [ "${{ inputs.dry-run }}" == "true" ]; then
212-
npm publish --dry-run --workspace="@google/gemini-cli-a2a-server" --no-tag
213-
else
214-
npm publish --workspace="@google/gemini-cli-a2a-server" --no-tag
215-
fi
218+
npm publish \
219+
--dry-run="${{ inputs.dry-run }}" \
220+
--workspace="${{ inputs.a2a-package-name }}" \
221+
--no-TARGET_TAG
216222
217223
- name: '🔬 Verify NPM release by version'
218224
uses: './.github/actions/verify-release'
219-
if: "${{ inputs.dry-run != 'true' && inputs.force-skip-tests != 'true' && inputs.registry != 'github' }}"
225+
if: "${{ inputs.dry-run != 'true' && inputs.force-skip-tests != 'true' }}"
220226
with:
221-
npm-package: '@google/gemini-cli@${{ inputs.release-version }}'
227+
npm-package: '${{ inputs.cli-package-name }}@${{ inputs.release-version }}'
222228
expected-version: '${{ inputs.release-version }}'
223229
ref: '${{ steps.release_branch.outputs.BRANCH_NAME }}'
224230
gemini_api_key: '${{ inputs.gemini_api_key }}'
231+
github-token: '${{ inputs.github-token }}'
232+
npm-registry-url: '${{ inputs.npm-registry-url }}'
233+
npm-registry-scope: '${{ inputs.npm-registry-scope }}'
225234

226235
- name: '🏷️ Tag release'
227236
uses: './.github/actions/tag-npm-release'
228-
if: "${{ inputs.dry-run != 'true' && inputs.registry != 'github' }}"
237+
if: "${{ inputs.dry-run != 'true' }}"
229238
with:
230239
channel: '${{ inputs.npm-tag }}'
231240
version: '${{ inputs.release-version }}'
232241
dry-run: '${{ inputs.dry-run }}'
242+
github-token: '${{ inputs.github-token }}'
233243
wombat-token-core: '${{ inputs.wombat-token-core }}'
234244
wombat-token-cli: '${{ inputs.wombat-token-cli }}'
235245
wombat-token-a2a-server: '${{ inputs.wombat-token-a2a-server }}'
246+
cli-package-name: '${{ inputs.cli-package-name }}'
247+
core-package-name: '${{ inputs.core-package-name }}'
248+
a2a-package-name: '${{ inputs.a2a-package-name }}'
236249

237250
- name: '🎉 Create GitHub Release'
238251
working-directory: '${{ inputs.working-directory }}'
239-
if: "${{ inputs.dry-run != 'true' && inputs.skip-github-release != 'true' && inputs.npm-tag != 'dev' && inputs.registry != 'github' }}"
252+
if: "${{ inputs.dry-run != 'true' && inputs.skip-github-release != 'true' && inputs.npm-tag != 'dev' && inputs.npm-registry-url != 'https://npm.pkg.github.com/' }}"
240253
env:
241254
GITHUB_TOKEN: '${{ inputs.github-token }}'
242255
shell: 'bash'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Setup NPMRC'
2+
description: 'Sets up NPMRC with all the correct repos for readonly access.'
3+
4+
inputs:
5+
github-token:
6+
description: 'the github token'
7+
required: true
8+
9+
outputs:
10+
auth-token:
11+
description: 'The generated NPM auth token'
12+
value: '${{ steps.npm_auth_token.outputs.auth-token }}'
13+
14+
runs:
15+
using: 'composite'
16+
steps:
17+
- name: 'Configure .npmrc'
18+
shell: 'bash'
19+
run: |-
20+
echo ""@google-gemini:registry=https://npm.pkg.github.com"" > ~/.npmrc
21+
echo ""//npm.pkg.github.com/:_authToken=${{ inputs.github-token }}"" >> ~/.npmrc
22+
echo ""@google:registry=https://wombat-dressing-room.appspot.com"" >> ~/.npmrc

0 commit comments

Comments
 (0)