Skip to content

Commit 0ca8669

Browse files
authored
Update .github directory from main branch (#9155)
1 parent 4fb8dfe commit 0ca8669

23 files changed

+1514
-733
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: 'Create and Merge Pull Request'
2+
description: 'Creates a pull request and merges it automatically.'
3+
4+
inputs:
5+
branch-name:
6+
description: 'The name of the branch to create the PR from.'
7+
required: true
8+
pr-title:
9+
description: 'The title of the pull request.'
10+
required: true
11+
pr-body:
12+
description: 'The body of the pull request.'
13+
required: true
14+
base-branch:
15+
description: 'The branch to merge into.'
16+
required: true
17+
default: 'main'
18+
app-id:
19+
description: 'The ID of the GitHub App.'
20+
required: true
21+
private-key:
22+
description: 'The private key of the GitHub App.'
23+
required: true
24+
dry-run:
25+
description: 'Whether to run in dry-run mode.'
26+
required: false
27+
default: 'false'
28+
29+
runs:
30+
using: 'composite'
31+
steps:
32+
- name: 'Generate GitHub App Token'
33+
id: 'generate_token'
34+
if: "inputs.dry-run == 'false'"
35+
uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b'
36+
with:
37+
app-id: '${{ inputs.app-id }}'
38+
private-key: '${{ inputs.private-key }}'
39+
permission-pull-requests: 'write'
40+
permission-contents: 'write'
41+
42+
- name: 'Create and Approve Pull Request'
43+
if: "inputs.dry-run == 'false'"
44+
env:
45+
GH_TOKEN: '${{ steps.generate_token.outputs.token }}'
46+
shell: 'bash'
47+
run: |
48+
set -e
49+
PR_URL=$(gh pr create \
50+
--title "${{ inputs.pr-title }}" \
51+
--body "${{ inputs.pr-body }}" \
52+
--base "${{ inputs.base-branch }}" \
53+
--head "${{ inputs.branch-name }}" \
54+
--fill)
55+
gh pr merge "$PR_URL" --auto --squash

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

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@ inputs:
2727
previous-tag:
2828
description: 'The previous tag to use for generating release notes.'
2929
required: true
30+
skip-github-release:
31+
description: 'Whether to skip creating a GitHub release.'
32+
type: 'boolean'
33+
required: false
34+
default: false
3035
working-directory:
3136
description: 'The working directory to run the steps in.'
3237
required: false
3338
default: '.'
39+
force-skip-tests:
40+
description: 'Skip tests and validation'
41+
required: false
42+
default: false
3443

3544
runs:
3645
using: 'composite'
@@ -102,7 +111,7 @@ runs:
102111
npm publish \
103112
--dry-run="${{ inputs.dry-run }}" \
104113
--workspace="@google/gemini-cli-core" \
105-
--tag="${{ inputs.npm-tag }}"
114+
--no-tag
106115
107116
- name: '🔗 Install latest core package'
108117
working-directory: '${{ inputs.working-directory }}'
@@ -122,7 +131,31 @@ runs:
122131
npm publish \
123132
--dry-run="${{ inputs.dry-run }}" \
124133
--workspace="@google/gemini-cli" \
125-
--tag="${{ inputs.npm-tag }}"
134+
--no-tag
135+
136+
- name: '🔬 Verify NPM release by version'
137+
uses: './.github/actions/verify-release'
138+
if: "${{ inputs.dry-run == 'false' && inputs.force-skip-tests == 'false' }}"
139+
with:
140+
npm-package: '@google/gemini-cli@${{ inputs.release-version }}'
141+
expected-version: '${{ inputs.release-version }}'
142+
ref: '${{ steps.release_branch.outputs.BRANCH_NAME }}'
143+
144+
- name: '🏷️ Tag release'
145+
uses: './.github/actions/tag-npm-release'
146+
if: "${{ inputs.dry-run == 'false' }}"
147+
with:
148+
channel: '${{ inputs.npm-tag }}'
149+
version: '${{ inputs.release-version }}'
150+
dry-run: '${{ inputs.dry-run }}'
151+
wombat-token-core: '${{ inputs.wombat-token-core }}'
152+
wombat-token-cli: '${{ inputs.wombat-token-cli }}'
153+
154+
- name: 'Install deps'
155+
working-directory: '${{ inputs.working-directory }}'
156+
shell: 'bash'
157+
run: |
158+
npm install
126159
127160
- name: '🎁 Bundle'
128161
working-directory: '${{ inputs.working-directory }}'
@@ -132,7 +165,7 @@ runs:
132165
133166
- name: '🎉 Create GitHub Release'
134167
working-directory: '${{ inputs.working-directory }}'
135-
if: "${{ inputs.dry-run == 'false' }}"
168+
if: "${{ inputs.dry-run == 'false' && inputs.skip-github-release == 'false' && inputs.npm-tag != 'dev' }}"
136169
env:
137170
GITHUB_TOKEN: '${{ inputs.github-token }}'
138171
shell: 'bash'
@@ -143,3 +176,12 @@ runs:
143176
--title "Release ${{ inputs.release-tag }}" \
144177
--notes-start-tag "${{ inputs.previous-tag }}" \
145178
--generate-notes
179+
180+
- name: '🧹 Clean up release branch'
181+
working-directory: '${{ inputs.working-directory }}'
182+
if: "${{ inputs.dry-run == 'false' }}"
183+
continue-on-error: true
184+
shell: 'bash'
185+
run: |
186+
echo "Cleaning up release branch ${{ steps.release_branch.outputs.BRANCH_NAME }}..."
187+
git push origin --delete "${{ steps.release_branch.outputs.BRANCH_NAME }}"
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: 'Push to docker'
2+
description: 'Builds packages and pushes a docker image to GHCR'
3+
4+
inputs:
5+
github-actor:
6+
description: 'Github actor'
7+
required: true
8+
github-secret:
9+
description: 'Github secret'
10+
required: true
11+
ref-name:
12+
description: 'Github ref name'
13+
required: true
14+
github-sha:
15+
description: 'Github Commit SHA Hash'
16+
required: true
17+
18+
runs:
19+
using: 'composite'
20+
steps:
21+
- name: 'Checkout'
22+
uses: 'actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955' # ratchet:actions/checkout@v4
23+
with:
24+
ref: '${{ inputs.github-sha }}'
25+
fetch-depth: 0
26+
- name: 'Install Dependencies'
27+
shell: 'bash'
28+
run: 'npm install'
29+
- name: 'Set up Docker Buildx'
30+
uses: 'docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435' # ratchet:docker/setup-buildx-action@v3
31+
- name: 'build'
32+
shell: 'bash'
33+
run: 'npm run build'
34+
- name: 'pack @google/gemini-cli'
35+
shell: 'bash'
36+
run: 'npm pack -w @google/gemini-cli --pack-destination ./packages/cli/dist'
37+
- name: 'pack @google/gemini-cli-core'
38+
shell: 'bash'
39+
run: 'npm pack -w @google/gemini-cli-core --pack-destination ./packages/core/dist'
40+
- name: 'Log in to GitHub Container Registry'
41+
uses: 'docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1' # ratchet:docker/login-action@v3
42+
with:
43+
registry: 'ghcr.io'
44+
username: '${{ inputs.github-actor }}'
45+
password: '${{ inputs.github-secret }}'
46+
- name: 'Get branch name'
47+
id: 'branch_name'
48+
shell: 'bash'
49+
run: |
50+
REF_NAME="${{ inputs.ref-name }}"
51+
echo "name=${REF_NAME%/merge}" >> $GITHUB_OUTPUT
52+
- name: 'Build and Push the Docker Image'
53+
uses: 'docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83' # ratchet:docker/build-push-action@v6
54+
with:
55+
context: '.'
56+
file: './Dockerfile'
57+
push: true
58+
provenance: false # avoid pushing 3 images to Aritfact Registry
59+
tags: |
60+
ghcr.io/${{ github.repository }}/cli:${{ steps.branch_name.outputs.name }}
61+
ghcr.io/${{ github.repository }}/cli:${{ inputs.github-sha }}
62+
- name: 'Create issue on failure'
63+
if: |-
64+
${{ failure() }}
65+
shell: 'bash'
66+
env:
67+
GITHUB_TOKEN: '${{ inputs.github-secret }}'
68+
DETAILS_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
69+
run: |-
70+
gh issue create \
71+
--title "Docker build failed" \
72+
--body "The docker build failed. See the full run for details: ${DETAILS_URL}" \
73+
--label "kind/bug,release-failure"
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: 'Build and push sandbox docker'
2+
description: 'Pushes sandbox docker image to container registry'
3+
4+
inputs:
5+
github-actor:
6+
description: 'Github actor'
7+
required: true
8+
github-secret:
9+
description: 'Github secret'
10+
required: true
11+
github-sha:
12+
description: 'Github Commit SHA Hash'
13+
required: true
14+
github-ref-name:
15+
description: 'Github ref name'
16+
required: true
17+
dry-run:
18+
description: 'Whether this is a dry run.'
19+
required: true
20+
type: 'boolean'
21+
22+
runs:
23+
using: 'composite'
24+
steps:
25+
- name: 'Checkout'
26+
uses: 'actions/checkout@v4'
27+
with:
28+
ref: '${{ inputs.github-sha }}'
29+
fetch-depth: 0
30+
- name: 'Install Dependencies'
31+
shell: 'bash'
32+
run: 'npm install'
33+
- name: 'npm build'
34+
shell: 'bash'
35+
run: 'npm run build'
36+
- name: 'Set up Docker Buildx'
37+
uses: 'docker/setup-buildx-action@v3'
38+
- name: 'Log in to GitHub Container Registry'
39+
uses: 'docker/login-action@v3'
40+
with:
41+
registry: 'ghcr.io'
42+
username: '${{ inputs.github-actor }}'
43+
password: '${{ inputs.github-secret }}'
44+
- name: 'determine image tag'
45+
id: 'image_tag'
46+
shell: 'bash'
47+
run: |-
48+
SHELL_TAG_NAME="${{ inputs.github-ref-name }}"
49+
FINAL_TAG="${{ inputs.github-sha }}"
50+
if [[ "$SHELL_TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?$ ]]; then
51+
echo "Release detected."
52+
FINAL_TAG="${SHELL_TAG_NAME#v}"
53+
else
54+
echo "Development release detected. Using commit SHA as tag."
55+
fi
56+
echo "Determined image tag: $FINAL_TAG"
57+
echo "FINAL_TAG=$FINAL_TAG" >> $GITHUB_OUTPUT
58+
- name: 'build'
59+
id: 'docker_build'
60+
shell: 'bash'
61+
env:
62+
GEMINI_SANDBOX_IMAGE_TAG: '${{ steps.image_tag.outputs.FINAL_TAG }}'
63+
GEMINI_SANDBOX: 'docker'
64+
run: |-
65+
npm run build:sandbox -- \
66+
--image ghcr.io/${{ github.repository}}/sandbox:${{ steps.image_tag.outputs.FINAL_TAG }} \
67+
--output-file final_image_uri.txt
68+
echo "uri=$(cat final_image_uri.txt)" >> $GITHUB_OUTPUT
69+
- name: 'publish'
70+
shell: 'bash'
71+
if: "${{ inputs.dry-run == 'false' }}"
72+
run: |-
73+
docker push "${{ steps.docker_build.outputs.uri }}"
74+
- name: 'Create issue on failure'
75+
if: |-
76+
${{ failure() }}
77+
shell: 'bash'
78+
env:
79+
GITHUB_TOKEN: '${{ inputs.github-secret }}'
80+
DETAILS_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
81+
run: |-
82+
gh issue create \
83+
--title "Docker build failed" \
84+
--body "The docker build failed. See the full run for details: ${DETAILS_URL}" \
85+
--label "kind/bug,release-failure"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 'Tag an NPM release'
2+
description: 'Tags a specific npm version to a specific channel.'
3+
4+
inputs:
5+
channel:
6+
description: 'NPM Channel tag'
7+
required: true
8+
version:
9+
description: 'version'
10+
required: true
11+
dry-run:
12+
description: 'Whether to run in dry-run mode.'
13+
required: true
14+
wombat-token-core:
15+
description: 'The npm token for the wombat @google/gemini-cli-core'
16+
required: true
17+
wombat-token-cli:
18+
description: 'The npm token for wombat @google/gemini-cli'
19+
20+
runs:
21+
using: 'composite'
22+
steps:
23+
- name: 'Setup Node.js'
24+
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020'
25+
with:
26+
node-version-file: '.nvmrc'
27+
registry-url: 'https://wombat-dressing-room.appspot.com'
28+
scope: '@google'
29+
30+
- name: 'Change tag for @google/gemini-cli-core'
31+
if: |-
32+
${{ inputs.dry-run == 'false' }}
33+
env:
34+
NODE_AUTH_TOKEN: '${{ inputs.wombat-token-core }}'
35+
shell: 'bash'
36+
run: |
37+
npm dist-tag add @google/gemini-cli-core@${{ inputs.version }} ${{ inputs.channel }}
38+
39+
- name: 'Change tag for @google/gemini-cli'
40+
if: |-
41+
${{ inputs.dry-run == 'false' }}
42+
env:
43+
NODE_AUTH_TOKEN: '${{ inputs.wombat-token-cli }}'
44+
shell: 'bash'
45+
run: |
46+
npm dist-tag add @google/gemini-cli@${{ inputs.version }} ${{ inputs.channel }}
47+
48+
- name: 'Log dry run'
49+
if: |-
50+
${{ inputs.dry-run == 'true' }}
51+
shell: 'bash'
52+
run: |
53+
echo "Dry run: Would have added tag '${{ inputs.channel }}' to version '${{ inputs.version }}' for @google/gemini-cli and @google/gemini-cli-core."

0 commit comments

Comments
 (0)