diff options
Diffstat (limited to '.github')
| -rw-r--r-- | .github/workflows/release.yml | 143 | ||||
| -rw-r--r-- | .github/workflows/scheduled-nightly-release.yml | 68 |
2 files changed, 211 insertions, 0 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1d73a74c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,143 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + workflow_dispatch: + inputs: + version: + description: 'The version to release (e.g., v0.1.11). Required for manual patch releases.' + required: true + type: string + ref: + description: 'The branch or ref to release from.' + required: true + type: string + default: 'main' + dry_run: + description: 'Whether to run the publish step in dry-run mode.' + required: true + type: boolean + default: true + +jobs: + release: + runs-on: ubuntu-latest + if: github.repository == 'google-gemini/gemini-cli' + permissions: + contents: write + packages: write + id-token: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # For manual runs, checkout the specified ref (e.g., main). For tag pushes, checkout the tag itself. + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }} + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install Dependencies + run: npm ci + + - name: Get the version + id: version + run: | + echo "Workflow triggered by: ${{ github.event_name }}" + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + echo "Input ref: ${{ inputs.ref }}" + echo "Input version: ${{ inputs.version }}" + RELEASE_TAG=${{ inputs.version }} + else + echo "Triggering ref: ${{ github.ref }}" + RELEASE_TAG=${GITHUB_REF_NAME} + fi + + echo "---" + echo "Initial RELEASE_TAG: ${RELEASE_TAG}" + + # Validate that the tag starts with 'v' and follows semver + if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?$ ]]; then + echo "Error: Version must be in the format vX.Y.Z or vX.Y.Z-prerelease" + exit 1 + fi + + RELEASE_VERSION="${RELEASE_TAG#v}" + if [[ $RELEASE_VERSION == *-* ]]; then + NPM_TAG=$(echo $RELEASE_VERSION | cut -d'-' -f2 | cut -d'.' -f1) + elif [[ $RELEASE_VERSION == *+* ]]; then + NPM_TAG=$(echo $RELEASE_VERSION | cut -d'+' -f2 | cut -d'.' -f1) + else + NPM_TAG="latest" + fi + + echo "Finalized RELEASE_VERSION: ${RELEASE_VERSION}" + echo "Finalized NPM_TAG: ${NPM_TAG}" + echo "---" + + echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_OUTPUT + echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_OUTPUT + echo "NPM_TAG=${NPM_TAG}" >> $GITHUB_OUTPUT + + - name: Create and switch to a release branch + id: release_branch + run: | + BRANCH_NAME="release/${{ steps.version.outputs.RELEASE_TAG }}" + git switch -c $BRANCH_NAME + echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT + + - name: Update package versions + run: | + npm run release:version ${{ steps.version.outputs.RELEASE_VERSION }} + + - name: Commit package versions + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add package.json package-lock.json packages/*/package.json + git commit -m "chore(release): ${{ steps.version.outputs.RELEASE_TAG }}" + git push --set-upstream origin ${{ steps.release_branch.outputs.BRANCH_NAME }} --follow-tags + + - name: Create GitHub Release and Tag + if: '!inputs.dry_run' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_BRANCH: ${{ steps.release_branch.outputs.BRANCH_NAME }} + run: | + gh release create ${{ steps.version.outputs.RELEASE_TAG }} \ + bundle/gemini.js \ + --target "$RELEASE_BRANCH" \ + --title "Release ${{ steps.version.outputs.RELEASE_TAG }}" \ + --generate-notes + + - name: Build and Prepare Packages + run: | + npm run build:packages + npm run prepare:package + + - name: Configure npm for publishing + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://wombat-dressing-room.appspot.com' + scope: '@google' + + - name: Publish @google/gemini-cli-core + run: npm publish --workspace=@google/gemini-cli-core --tag=${{ steps.version.outputs.NPM_TAG }} ${{ inputs.dry_run && '--dry-run' || '' }} + env: + NODE_AUTH_TOKEN: ${{ secrets.WOMBAT_TOKEN_CORE }} + + - name: Install latest core package + run: npm install @google/gemini-cli-core@${{ steps.version.outputs.RELEASE_VERSION }} --workspace=@google/gemini-cli --save-exact + + - name: Publish @google/gemini-cli + run: npm publish --workspace=@google/gemini-cli --tag=${{ steps.version.outputs.NPM_TAG }} ${{ inputs.dry_run && '--dry-run' || '' }} + env: + NODE_AUTH_TOKEN: ${{ secrets.WOMBAT_TOKEN_CLI }} diff --git a/.github/workflows/scheduled-nightly-release.yml b/.github/workflows/scheduled-nightly-release.yml new file mode 100644 index 00000000..f55d5570 --- /dev/null +++ b/.github/workflows/scheduled-nightly-release.yml @@ -0,0 +1,68 @@ +name: Scheduled Nightly Release + +on: + schedule: + # Runs every day at midnight UTC. + - cron: '0 0 * * *' + workflow_dispatch: + +jobs: + nightly-release: + runs-on: ubuntu-latest + permissions: + contents: write + issues: write + + steps: + - name: Checkout main branch + uses: actions/checkout@v4 + with: + ref: 'main' + fetch-depth: 0 # Fetch all history for git tags + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install Dependencies + run: npm ci + + - name: Run Preflight Checks + run: npm run preflight + + - name: Run Integration Tests (without Docker) + uses: nick-invision/retry@v2 + with: + max_attempts: 3 + retry_wait_seconds: 30 + command: npm run test:integration:sandbox:none + + - name: Run Integration Tests (with Docker) + uses: nick-invision/retry@v2 + with: + max_attempts: 3 + retry_wait_seconds: 30 + command: npm run test:integration:sandbox:docker + + - name: Configure Git User + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Create and Push Nightly Tag + if: success() + run: npm run tag:release:nightly + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Issue on Failure + if: failure() + run: | + gh issue create \ + --title "Nightly Release Failed on $(date +'%Y-%m-%d')" \ + --body "The scheduled nightly release workflow failed. See the full run for details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ + --label "bug,nightly-failure" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
