name: 'Publish Release' description: 'Builds, prepares, and publishes the gemini-cli packages to npm and creates a GitHub release.' inputs: release-version: description: 'The version to release (e.g., 0.1.11).' required: true npm-tag: description: 'The npm tag to publish with (e.g., latest, preview, nightly).' required: true wombat-token-core: description: 'The npm token for the @google/gemini-cli-core package.' required: true wombat-token-cli: description: 'The npm token for the @google/gemini-cli package.' required: true github-token: description: 'The GitHub token for creating the release.' required: true dry-run: description: 'Whether to run in dry-run mode.' type: 'boolean' required: true release-tag: description: 'The release tag for the release (e.g., v0.1.11).' required: true previous-tag: description: 'The previous tag to use for generating release notes.' required: true working-directory: description: 'The working directory to run the steps in.' required: false default: '.' runs: using: 'composite' steps: - name: 'Configure Git User' working-directory: '${{ inputs.working-directory }}' shell: 'bash' run: |- git config user.name "gemini-cli-robot" git config user.email "gemini-cli-robot@google.com" - name: 'Create and switch to a release branch' working-directory: '${{ inputs.working-directory }}' id: 'release_branch' shell: 'bash' run: | BRANCH_NAME="release/${{ inputs.release-tag }}" git switch -c "${BRANCH_NAME}" echo "BRANCH_NAME=${BRANCH_NAME}" >> "${GITHUB_OUTPUT}" - name: 'Update package versions' working-directory: '${{ inputs.working-directory }}' shell: 'bash' run: 'npm run release:version "${{ inputs.release-version }}"' - name: 'Commit and Conditionally Push package versions' working-directory: '${{ inputs.working-directory }}' shell: 'bash' env: BRANCH_NAME: '${{ steps.release_branch.outputs.BRANCH_NAME }}' DRY_RUN: '${{ inputs.dry-run }}' RELEASE_TAG: '${{ inputs.release-tag }}' run: |- git add package.json npm-shrinkwrap.json packages/*/package.json git commit -m "chore(release): ${RELEASE_TAG}" if [[ "${DRY_RUN}" == "false" ]]; then echo "Pushing release branch to remote..." git push --set-upstream origin "${BRANCH_NAME}" --follow-tags else echo "Dry run enabled. Skipping push." fi - name: 'Build and Prepare Packages' working-directory: '${{ inputs.working-directory }}' run: |- npm run build:packages npm run prepare:package shell: 'bash' - name: 'Configure npm for publishing' uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' with: node-version-file: '${{ inputs.working-directory }}/.nvmrc' registry-url: 'https://wombat-dressing-room.appspot.com' scope: '@google' - name: 'Publish @google/gemini-cli-core' working-directory: '${{ inputs.working-directory }}' env: NODE_AUTH_TOKEN: '${{ inputs.wombat-token-core }}' run: |- npm publish \ --dry-run="${{ inputs.dry-run }}" \ --workspace="@google/gemini-cli-core" \ --tag="${{ inputs.npm-tag }}" shell: 'bash' - name: 'Install latest core package' working-directory: '${{ inputs.working-directory }}' if: '${{ inputs.dry-run == false }}' run: |- npm install "@google/gemini-cli-core@${{ inputs.release-version }}" \ --workspace="@google/gemini-cli" \ --save-exact shell: 'bash' - name: 'Publish @google/gemini-cli' working-directory: '${{ inputs.working-directory }}' env: NODE_AUTH_TOKEN: '${{ inputs.wombat-token-cli }}' run: |- npm publish \ --dry-run="${{ inputs.dry-run }}" \ --workspace="@google/gemini-cli" \ --tag="${{ inputs.npm-tag }}" shell: 'bash' - name: 'Bundle' working-directory: '${{ inputs.working-directory }}' run: 'npm run bundle' shell: 'bash' - name: 'Create GitHub Release' working-directory: '${{ inputs.working-directory }}' if: '${{ inputs.dry-run == false }}' env: GITHUB_TOKEN: '${{ inputs.github-token }}' run: |- gh release create "${{ inputs.release-tag }}" \ bundle/gemini.js \ --target "${{ steps.release_branch.outputs.BRANCH_NAME }}" \ --title "Release ${{ inputs.release-tag }}" \ --notes-start-tag "${{ inputs.previous-tag }}" \ --generate-notes shell: 'bash' - name: 'Create Issue on Failure' if: |- ${{ failure() }} env: GITHUB_TOKEN: '${{ inputs.github-token }}' RELEASE_TAG: '${{ inputs.release-tag }} || "N/A"' DETAILS_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' run: |- gh issue create \ --title "Release Failed for ${RELEASE_TAG} on $(date +'%Y-%m-%d')" \ --body "The release workflow failed. See the full run for details: ${DETAILS_URL}" \ --label "kind/bug,release-failure,priority/p0" shell: 'bash'