Refactor Github Action per b/485167538 (#19295)

Co-authored-by: Ben Knutson <benknutson@google.com>
This commit is contained in:
Google Admin
2026-02-17 21:36:19 -05:00
committed by GitHub
parent 49abf1fe16
commit e98f41fe86
2 changed files with 40 additions and 17 deletions

View File

@@ -57,16 +57,19 @@ jobs:
id: vars
run: |
is_nightly="false"
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event.inputs.create_nightly_release }}" == "true" ]]; then
if [[ "${{ github.event_name }}" == "schedule" || "${GITHUB_EVENT_INPUTS_CREATE_NIGHTLY_RELEASE}" == "true" ]]; then
is_nightly="true"
fi
echo "is_nightly=${is_nightly}" >> $GITHUB_OUTPUT
is_dry_run="false"
if [[ "${{ github.event.inputs.dry_run }}" == "true" ]]; then
if [[ "${GITHUB_EVENT_INPUTS_DRY_RUN}" == "true" ]]; then
is_dry_run="true"
fi
echo "is_dry_run=${is_dry_run}" >> $GITHUB_OUTPUT
env:
GITHUB_EVENT_INPUTS_CREATE_NIGHTLY_RELEASE: ${{ github.event.inputs.create_nightly_release }}
GITHUB_EVENT_INPUTS_DRY_RUN: ${{ github.event.inputs.dry_run }}
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
@@ -110,24 +113,32 @@ jobs:
- name: Create and switch to a release branch
id: release_branch
run: |
BRANCH_NAME="release/${{ steps.version.outputs.RELEASE_TAG }}"
BRANCH_NAME="release/${STEPS_VERSION_OUTPUTS_RELEASE_TAG}"
git switch -c $BRANCH_NAME
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
env:
STEPS_VERSION_OUTPUTS_RELEASE_TAG: ${{ steps.version.outputs.RELEASE_TAG }}
- name: Update package versions
run: |
npm run release:version ${{ steps.version.outputs.RELEASE_VERSION }}
npm run release:version ${STEPS_VERSION_OUTPUTS_RELEASE_VERSION}
env:
STEPS_VERSION_OUTPUTS_RELEASE_VERSION: ${{ steps.version.outputs.RELEASE_VERSION }}
- name: Commit and Conditionally Push package versions
run: |
git add package.json package-lock.json packages/*/package.json
git commit -m "chore(release): ${{ steps.version.outputs.RELEASE_TAG }}"
if [[ "${{ steps.vars.outputs.is_dry_run }}" == "false" ]]; then
git commit -m "chore(release): ${STEPS_VERSION_OUTPUTS_RELEASE_TAG}"
if [[ "${STEPS_VARS_OUTPUTS_IS_DRY_RUN}" == "false" ]]; then
echo "Pushing release branch to remote..."
git push --set-upstream origin ${{ steps.release_branch.outputs.BRANCH_NAME }} --follow-tags
git push --set-upstream origin ${STEPS_RELEASE_BRANCH_OUTPUTS_BRANCH_NAME} --follow-tags
else
echo "Dry run enabled. Skipping push."
fi
env:
STEPS_VERSION_OUTPUTS_RELEASE_TAG: ${{ steps.version.outputs.RELEASE_TAG }}
STEPS_VARS_OUTPUTS_IS_DRY_RUN: ${{ steps.vars.outputs.is_dry_run }}
STEPS_RELEASE_BRANCH_OUTPUTS_BRANCH_NAME: ${{ steps.release_branch.outputs.BRANCH_NAME }}
- name: Build and Prepare Packages
run: |
@@ -145,30 +156,35 @@ jobs:
scope: '@google'
- name: Publish @google/gemini-cli-core
run: npm publish --workspace=@google/gemini-cli-core --tag=${{ steps.version.outputs.NPM_TAG }} ${{ steps.vars.outputs.is_dry_run == 'true' && '--dry-run' || '' }}
run: npm publish --workspace=@google/gemini-cli-core --tag=${STEPS_VERSION_OUTPUTS_NPM_TAG} ${{ steps.vars.outputs.is_dry_run == 'true' && '--dry-run' || '' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.WOMBAT_TOKEN_CORE }}
STEPS_VERSION_OUTPUTS_NPM_TAG: ${{ steps.version.outputs.NPM_TAG }}
- name: Install latest core package
if: steps.vars.outputs.is_dry_run == 'false'
run: npm install @google/gemini-cli-core@${{ steps.version.outputs.RELEASE_VERSION }} --workspace=@google/gemini-cli --save-exact
run: npm install @google/gemini-cli-core@${STEPS_VERSION_OUTPUTS_RELEASE_VERSION} --workspace=@google/gemini-cli --save-exact
env:
STEPS_VERSION_OUTPUTS_RELEASE_VERSION: ${{ steps.version.outputs.RELEASE_VERSION }}
- name: Publish @google/gemini-cli
run: npm publish --workspace=@google/gemini-cli --tag=${{ steps.version.outputs.NPM_TAG }} ${{ steps.vars.outputs.is_dry_run == 'true' && '--dry-run' || '' }}
run: npm publish --workspace=@google/gemini-cli --tag=${STEPS_VERSION_OUTPUTS_NPM_TAG} ${{ steps.vars.outputs.is_dry_run == 'true' && '--dry-run' || '' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.WOMBAT_TOKEN_CLI }}
STEPS_VERSION_OUTPUTS_NPM_TAG: ${{ steps.version.outputs.NPM_TAG }}
- name: Create GitHub Release and Tag
if: ${{ steps.vars.outputs.is_dry_run == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_BRANCH: ${{ steps.release_branch.outputs.BRANCH_NAME }}
STEPS_VERSION_OUTPUTS_RELEASE_TAG: ${{ steps.version.outputs.RELEASE_TAG }}
run: |
gh release create ${{ steps.version.outputs.RELEASE_TAG }} \
gh release create ${STEPS_VERSION_OUTPUTS_RELEASE_TAG} \
bundle/gemini.js \
bundle/binaries/* \
--target "$RELEASE_BRANCH" \
--title "Release ${{ steps.version.outputs.RELEASE_TAG }}" \
--title "Release ${STEPS_VERSION_OUTPUTS_RELEASE_TAG}" \
--generate-notes
- name: Create Issue on Failure