|
| 1 | +name: 'Release' |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Runs every day at midnight UTC for the nightly release. |
| 6 | + - cron: '0 0 * * *' |
| 7 | + # Runs every Tuesday at 23:59 UTC for the preview release. |
| 8 | + - cron: '59 23 * * 2' |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'The version to release (e.g., v0.1.11). Required for manual patch releases.' |
| 13 | + required: false # Not required for scheduled runs |
| 14 | + type: 'string' |
| 15 | + ref: |
| 16 | + description: 'The branch or ref (full git sha) to release from.' |
| 17 | + required: true |
| 18 | + type: 'string' |
| 19 | + default: 'main' |
| 20 | + dry_run: |
| 21 | + description: 'Run a dry-run of the release process; no branches, npm packages or GitHub releases will be created.' |
| 22 | + required: true |
| 23 | + type: 'boolean' |
| 24 | + default: true |
| 25 | + create_nightly_release: |
| 26 | + description: 'Auto apply the nightly release tag, input version is ignored.' |
| 27 | + required: false |
| 28 | + type: 'boolean' |
| 29 | + default: false |
| 30 | + create_preview_release: |
| 31 | + description: 'Auto apply the preview release tag, input version is ignored.' |
| 32 | + required: false |
| 33 | + type: 'boolean' |
| 34 | + default: false |
| 35 | + force_skip_tests: |
| 36 | + description: 'Select to skip the "Run Tests" step in testing. Prod releases should run tests' |
| 37 | + required: false |
| 38 | + type: 'boolean' |
| 39 | + default: false |
| 40 | + |
| 41 | +jobs: |
| 42 | + release: |
| 43 | + runs-on: 'ubuntu-latest' |
| 44 | + environment: |
| 45 | + name: 'production-release' |
| 46 | + url: '${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.version.outputs.RELEASE_TAG }}' |
| 47 | + if: |- |
| 48 | + ${{ github.repository == 'google-gemini/gemini-cli' }} |
| 49 | + permissions: |
| 50 | + contents: 'write' |
| 51 | + packages: 'write' |
| 52 | + id-token: 'write' |
| 53 | + issues: 'write' # For creating issues on failure |
| 54 | + outputs: |
| 55 | + RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }}' |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: 'Checkout' |
| 59 | + uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5 |
| 60 | + with: |
| 61 | + ref: '${{ github.event.inputs.ref || github.sha }}' |
| 62 | + fetch-depth: 0 |
| 63 | + |
| 64 | + - name: 'Set booleans for simplified logic' |
| 65 | + env: |
| 66 | + CREATE_NIGHTLY_RELEASE: '${{ github.event.inputs.create_nightly_release }}' |
| 67 | + CREATE_PREVIEW_RELEASE: '${{ github.event.inputs.create_preview_release }}' |
| 68 | + EVENT_NAME: '${{ github.event_name }}' |
| 69 | + CRON: '${{ github.event.schedule }}' |
| 70 | + DRY_RUN_INPUT: '${{ github.event.inputs.dry_run }}' |
| 71 | + id: 'vars' |
| 72 | + run: |- |
| 73 | + is_nightly="false" |
| 74 | + if [[ "${CRON}" == "0 0 * * *" || "${CREATE_NIGHTLY_RELEASE}" == "true" ]]; then |
| 75 | + is_nightly="true" |
| 76 | + fi |
| 77 | + echo "is_nightly=${is_nightly}" >> "${GITHUB_OUTPUT}" |
| 78 | +
|
| 79 | + is_preview="false" |
| 80 | + if [[ "${CRON}" == "59 23 * * 2" || "${CREATE_PREVIEW_RELEASE}" == "true" ]]; then |
| 81 | + is_preview="true" |
| 82 | + fi |
| 83 | + echo "is_preview=${is_preview}" >> "${GITHUB_OUTPUT}" |
| 84 | +
|
| 85 | + is_dry_run="false" |
| 86 | + if [[ "${DRY_RUN_INPUT}" == "true" ]]; then |
| 87 | + is_dry_run="true" |
| 88 | + fi |
| 89 | + echo "is_dry_run=${is_dry_run}" >> "${GITHUB_OUTPUT}" |
| 90 | +
|
| 91 | + - name: 'Setup Node.js' |
| 92 | + uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4 |
| 93 | + with: |
| 94 | + node-version-file: '.nvmrc' |
| 95 | + cache: 'npm' |
| 96 | + |
| 97 | + - name: 'Install Dependencies' |
| 98 | + run: |- |
| 99 | + npm ci |
| 100 | +
|
| 101 | + - name: 'Get the version' |
| 102 | + id: 'version' |
| 103 | + env: |
| 104 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 105 | + IS_NIGHTLY: '${{ steps.vars.outputs.is_nightly }}' |
| 106 | + IS_PREVIEW: '${{ steps.vars.outputs.is_preview }}' |
| 107 | + MANUAL_VERSION: '${{ inputs.version }}' |
| 108 | + run: |- |
| 109 | + VERSION_JSON="$(node scripts/get-release-version.js)" |
| 110 | + echo "RELEASE_TAG=$(echo "${VERSION_JSON}" | jq -r .releaseTag)" >> "${GITHUB_OUTPUT}" |
| 111 | + echo "RELEASE_VERSION=$(echo "${VERSION_JSON}" | jq -r .releaseVersion)" >> "${GITHUB_OUTPUT}" |
| 112 | + echo "NPM_TAG=$(echo "${VERSION_JSON}" | jq -r .npmTag)" >> "${GITHUB_OUTPUT}" |
| 113 | + echo "PREVIOUS_TAG=$(echo "${VERSION_JSON}" | jq -r .previousReleaseTag)" >> "${GITHUB_OUTPUT}" |
| 114 | +
|
| 115 | + - name: 'Run Tests' |
| 116 | + if: |- |
| 117 | + ${{ github.event.inputs.force_skip_tests != 'true' }} |
| 118 | + env: |
| 119 | + GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}' |
| 120 | + run: |- |
| 121 | + npm run preflight |
| 122 | + npm run test:integration:sandbox:none |
| 123 | + npm run test:integration:sandbox:docker |
| 124 | +
|
| 125 | + - name: 'Configure Git User' |
| 126 | + run: |- |
| 127 | + git config user.name "gemini-cli-robot" |
| 128 | + git config user.email "[email protected]" |
| 129 | +
|
| 130 | + - name: 'Create and switch to a release branch' |
| 131 | + id: 'release_branch' |
| 132 | + env: |
| 133 | + RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }}' |
| 134 | + run: |- |
| 135 | + BRANCH_NAME="release/${RELEASE_TAG}" |
| 136 | + git switch -c "${BRANCH_NAME}" |
| 137 | + echo "BRANCH_NAME=${BRANCH_NAME}" >> "${GITHUB_OUTPUT}" |
| 138 | +
|
| 139 | + - name: 'Update package versions' |
| 140 | + env: |
| 141 | + RELEASE_VERSION: '${{ steps.version.outputs.RELEASE_VERSION }}' |
| 142 | + run: |- |
| 143 | + npm run release:version "${RELEASE_VERSION}" |
| 144 | +
|
| 145 | + - name: 'Commit and Conditionally Push package versions' |
| 146 | + env: |
| 147 | + BRANCH_NAME: '${{ steps.release_branch.outputs.BRANCH_NAME }}' |
| 148 | + IS_DRY_RUN: '${{ steps.vars.outputs.is_dry_run }}' |
| 149 | + RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }}' |
| 150 | + run: |- |
| 151 | + git add package.json package-lock.json packages/*/package.json |
| 152 | + git commit -m "chore(release): ${RELEASE_TAG}" |
| 153 | + if [[ "${IS_DRY_RUN}" == "false" ]]; then |
| 154 | + echo "Pushing release branch to remote..." |
| 155 | + git push --set-upstream origin "${BRANCH_NAME}" --follow-tags |
| 156 | + else |
| 157 | + echo "Dry run enabled. Skipping push." |
| 158 | + fi |
| 159 | +
|
| 160 | + - name: 'Build and Prepare Packages' |
| 161 | + run: |- |
| 162 | + npm run build:packages |
| 163 | + npm run prepare:package |
| 164 | +
|
| 165 | + - name: 'Configure npm for publishing' |
| 166 | + uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4 |
| 167 | + with: |
| 168 | + node-version-file: '.nvmrc' |
| 169 | + registry-url: 'https://wombat-dressing-room.appspot.com' |
| 170 | + scope: '@google' |
| 171 | + |
| 172 | + - name: 'Publish @google/gemini-cli-core' |
| 173 | + env: |
| 174 | + IS_DRY_RUN: '${{ steps.vars.outputs.is_dry_run }}' |
| 175 | + NODE_AUTH_TOKEN: '${{ secrets.WOMBAT_TOKEN_CORE }}' |
| 176 | + NPM_TAG: '${{ steps.version.outputs.NPM_TAG }}' |
| 177 | + run: |- |
| 178 | + npm publish \ |
| 179 | + --dry-run="${IS_DRY_RUN}" \ |
| 180 | + --workspace="@google/gemini-cli-core" \ |
| 181 | + --tag="${NPM_TAG}" |
| 182 | +
|
| 183 | + - name: 'Install latest core package' |
| 184 | + if: |- |
| 185 | + ${{ steps.vars.outputs.is_dry_run == 'false' }} |
| 186 | + env: |
| 187 | + RELEASE_VERSION: '${{ steps.version.outputs.RELEASE_VERSION }}' |
| 188 | + run: |- |
| 189 | + npm install "@google/gemini-cli-core@${RELEASE_VERSION}" \ |
| 190 | + --workspace="@google/gemini-cli" \ |
| 191 | + --save-exact |
| 192 | +
|
| 193 | + - name: 'Publish @google/gemini-cli' |
| 194 | + env: |
| 195 | + IS_DRY_RUN: '${{ steps.vars.outputs.is_dry_run }}' |
| 196 | + NODE_AUTH_TOKEN: '${{ secrets.WOMBAT_TOKEN_CLI }}' |
| 197 | + NPM_TAG: '${{ steps.version.outputs.NPM_TAG }}' |
| 198 | + run: |- |
| 199 | + npm publish \ |
| 200 | + --dry-run="${IS_DRY_RUN}" \ |
| 201 | + --workspace="@google/gemini-cli" \ |
| 202 | + --tag="${NPM_TAG}" |
| 203 | +
|
| 204 | + - name: 'Create GitHub Release and Tag' |
| 205 | + if: |- |
| 206 | + ${{ steps.vars.outputs.is_dry_run == 'false' }} |
| 207 | + env: |
| 208 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 209 | + RELEASE_BRANCH: '${{ steps.release_branch.outputs.BRANCH_NAME }}' |
| 210 | + RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }}' |
| 211 | + PREVIOUS_TAG: '${{ steps.version.outputs.PREVIOUS_TAG }}' |
| 212 | + run: |- |
| 213 | + gh release create "${RELEASE_TAG}" \ |
| 214 | + bundle/gemini.js \ |
| 215 | + --target "$RELEASE_BRANCH" \ |
| 216 | + --title "Release ${RELEASE_TAG}" \ |
| 217 | + --notes-start-tag "$PREVIOUS_TAG" \ |
| 218 | + --generate-notes |
| 219 | +
|
| 220 | + - name: 'Create Issue on Failure' |
| 221 | + if: |- |
| 222 | + ${{ failure() }} |
| 223 | + env: |
| 224 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 225 | + RELEASE_TAG: '${{ steps.version.outputs.RELEASE_TAG }} || "N/A"' |
| 226 | + DETAILS_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
| 227 | + run: |- |
| 228 | + gh issue create \ |
| 229 | + --title "Release Failed for ${RELEASE_TAG} on $(date +'%Y-%m-%d')" \ |
| 230 | + --body "The release workflow failed. See the full run for details: ${DETAILS_URL}" \ |
| 231 | + --label "kind/bug,release-failure,priority/p0" |
0 commit comments