Skip to content

Commit a83e266

Browse files
mattKorwelnagendrareddy10
authored andcommitted
Releasing: Patching and Rollback (google-gemini#8673)
1 parent 4ae5671 commit a83e266

14 files changed

Lines changed: 379 additions & 475 deletions

.github/workflows/patch-release.yml

Lines changed: 0 additions & 94 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: 'Release: Change Tags'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'The package version to tag (e.g., 0.5.0-preview-2). This version must already exist on the npm registry.'
8+
required: true
9+
type: 'string'
10+
channel:
11+
description: 'The npm dist-tag to apply (e.g., preview, stable).'
12+
required: true
13+
type: 'choice'
14+
options:
15+
- 'stable'
16+
- 'preview'
17+
- 'nightly'
18+
dry_run:
19+
description: 'Whether to run in dry-run mode.'
20+
required: false
21+
type: 'boolean'
22+
default: true
23+
24+
jobs:
25+
change-tags:
26+
runs-on: 'ubuntu-latest'
27+
permissions:
28+
packages: 'write'
29+
issues: 'write'
30+
steps:
31+
- name: 'Setup Node.js'
32+
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020'
33+
with:
34+
node-version-file: '.nvmrc'
35+
registry-url: 'https://wombat-dressing-room.appspot.com'
36+
scope: '@google'
37+
38+
- name: 'Change tag for @google/gemini-cli-core'
39+
if: 'github.event.inputs.dry_run == false'
40+
env:
41+
NODE_AUTH_TOKEN: '${{ secrets.WOMBAT_TOKEN_CORE }}'
42+
run: |
43+
npm dist-tag add @google/gemini-cli-core@${{ github.event.inputs.version }} ${{ github.event.inputs.channel }}
44+
45+
- name: 'Change tag for @google/gemini-cli'
46+
if: 'github.event.inputs.dry_run == false'
47+
env:
48+
NODE_AUTH_TOKEN: '${{ secrets.WOMBAT_TOKEN_CLI }}'
49+
run: |
50+
npm dist-tag add @google/gemini-cli@${{ github.event.inputs.version }} ${{ github.event.inputs.channel }}
51+
52+
- name: 'Log dry run'
53+
if: 'github.event.inputs.dry_run == true'
54+
run: |
55+
echo "Dry run: Would have added tag '${{ github.event.inputs.channel }}' to version '${{ github.event.inputs.version }}' for @google/gemini-cli and @google/gemini-cli-core."
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: 'Release: Manual'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'The version to release (e.g., v0.1.11). Must be a valid semver string with a "v" prefix.'
8+
required: true
9+
type: 'string'
10+
ref:
11+
description: 'The branch, tag, or SHA to release from.'
12+
required: true
13+
type: 'string'
14+
npm_channel:
15+
description: 'The npm channel to publish to.'
16+
required: true
17+
type: 'choice'
18+
options:
19+
- 'stable'
20+
- 'preview'
21+
- 'dev'
22+
dry_run:
23+
description: 'Run a dry-run of the release process; no branches, npm packages or GitHub releases will be created.'
24+
required: true
25+
type: 'boolean'
26+
default: true
27+
force_skip_tests:
28+
description: 'Select to skip the "Run Tests" step in testing. Prod releases should run tests'
29+
required: false
30+
type: 'boolean'
31+
default: false
32+
33+
jobs:
34+
release:
35+
runs-on: 'ubuntu-latest'
36+
permissions:
37+
contents: 'write'
38+
packages: 'write'
39+
issues: 'write'
40+
steps:
41+
- name: 'Checkout'
42+
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8'
43+
with:
44+
ref: '${{ github.event.inputs.ref }}'
45+
fetch-depth: 0
46+
47+
- name: 'Setup Node.js'
48+
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020'
49+
with:
50+
node-version-file: '.nvmrc'
51+
cache: 'npm'
52+
53+
- name: 'Install Dependencies'
54+
run: 'npm ci'
55+
56+
- name: 'Prepare Release Info'
57+
id: 'release_info'
58+
run: |
59+
RELEASE_VERSION="${{ github.event.inputs.version }}"
60+
echo "RELEASE_VERSION=${RELEASE_VERSION#v}" >> "${GITHUB_OUTPUT}"
61+
echo "PREVIOUS_TAG=$(git describe --tags --abbrev=0)" >> "${GITHUB_OUTPUT}"
62+
63+
- name: 'Run Tests'
64+
if: |-
65+
${{ github.event.inputs.force_skip_tests != true }}
66+
uses: './.github/actions/run-tests'
67+
with:
68+
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
69+
70+
- name: 'Publish Release'
71+
uses: './.github/actions/publish-release'
72+
with:
73+
release-version: '${{ steps.release_info.outputs.RELEASE_VERSION }}'
74+
release-tag: '${{ github.event.inputs.version }}'
75+
npm-tag: '${{ github.event.inputs.npm_channel }}'
76+
wombat-token-core: '${{ secrets.WOMBAT_TOKEN_CORE }}'
77+
wombat-token-cli: '${{ secrets.WOMBAT_TOKEN_CLI }}'
78+
github-token: '${{ secrets.GITHUB_TOKEN }}'
79+
dry-run: '${{ github.event.inputs.dry_run }}'
80+
previous-tag: '${{ steps.release_info.outputs.PREVIOUS_TAG }}'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'Nightly Release'
1+
name: 'Release: Nightly'
22

33
on:
44
schedule:

.github/workflows/create-patch-pr.yml renamed to .github/workflows/release-patch-1-create-pr.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'Create Patch PR'
1+
name: 'Release: Patch (1) Create PR'
22

33
on:
44
workflow_dispatch:
@@ -19,6 +19,11 @@ on:
1919
required: false
2020
type: 'boolean'
2121
default: false
22+
ref:
23+
description: 'The branch, tag, or SHA to test from.'
24+
required: false
25+
type: 'string'
26+
default: 'main'
2227

2328
jobs:
2429
create-patch:
@@ -30,6 +35,7 @@ jobs:
3035
- name: 'Checkout'
3136
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
3237
with:
38+
ref: '${{ github.event.inputs.ref }}'
3339
fetch-depth: 0
3440

3541
- name: 'Setup Node.js'
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: 'Release: Patch (2) Trigger'
2+
3+
on:
4+
pull_request:
5+
types:
6+
- 'closed'
7+
workflow_dispatch:
8+
inputs:
9+
ref:
10+
description: 'The head ref of the merged hotfix PR to trigger the release for (e.g. hotfix/v1.2.3/cherry-pick-abc).'
11+
required: true
12+
type: 'string'
13+
workflow_id:
14+
description: 'The workflow to trigger. Defaults to patch-release.yml'
15+
required: false
16+
type: 'string'
17+
default: 'release-patch-3-release.yml'
18+
dry_run:
19+
description: 'Whether this is a dry run.'
20+
required: false
21+
type: 'boolean'
22+
default: false
23+
24+
jobs:
25+
trigger-patch-release:
26+
if: "(github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'hotfix/')) || github.event_name == 'workflow_dispatch'"
27+
runs-on: 'ubuntu-latest'
28+
permissions:
29+
actions: 'write'
30+
steps:
31+
- name: 'Trigger Patch Release'
32+
uses: 'actions/github-script@00f12e3e20659f42342b1c0226afda7f7c042325'
33+
with:
34+
script: |
35+
let body = '';
36+
let headRef = '';
37+
38+
if (context.eventName === 'pull_request') {
39+
body = context.payload.pull_request.body;
40+
headRef = context.payload.pull_request.head.ref;
41+
} else { // workflow_dispatch
42+
body = ${{ github.event.inputs.dry_run }} ? '[DRY RUN]' : '';
43+
headRef = '${{ github.event.inputs.ref }}';
44+
}
45+
46+
const isDryRun = body.includes('[DRY RUN]');
47+
const version = headRef.split('/')[1];
48+
const channel = version.includes('preview') ? 'preview' : 'stable';
49+
const ref = `release/${version}`;
50+
const workflow_id = context.eventName === 'pull_request'
51+
? 'release-patch-3-release.yml'
52+
: '${{ github.event.inputs.workflow_id }}';
53+
54+
github.rest.actions.createWorkflowDispatch({
55+
owner: context.repo.owner,
56+
repo: context.repo.repo,
57+
workflow_id: workflow_id,
58+
ref: 'mk-patch-releases',
59+
inputs: {
60+
type: channel,
61+
dry_run: isDryRun.toString(),
62+
version: version,
63+
release_ref: ref
64+
}
65+
})

0 commit comments

Comments
 (0)