From a6c9eaabf6fa7229c0385814e036b3648491958c Mon Sep 17 00:00:00 2001 From: mkorwel Date: Tue, 21 Oct 2025 21:08:37 -0700 Subject: [PATCH] Feat: Implement dynamic versioning and PR-based tagging for CI builds --- .github/workflows/build-and-publish.yml | 28 +++++++++++++++---------- .github/workflows/ci.yml | 4 ++-- .github/workflows/e2e.yml | 16 +++----------- .github/workflows/orchestrator.yml | 4 ++-- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index d1079be5be..f2b6dcd58c 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -4,16 +4,16 @@ name: 'Build and Publish Bundle' on: workflow_call: outputs: - tag: - description: 'The tag of the published package' - value: '${{ jobs.publish-bundle.outputs.tag }}' + version: + description: 'The version of the published package' + value: '${{ jobs.publish-bundle.outputs.version }}' jobs: publish-bundle: name: 'Publish Bundle' runs-on: 'gemini-cli-ubuntu-16-core' outputs: - tag: '${{ steps.get_tag.outputs.tag }}' + version: '${{ steps.version.outputs.version }}' permissions: contents: 'read' packages: 'write' @@ -44,12 +44,18 @@ jobs: - name: 'Bundle' run: 'npm run bundle' - - name: 'Get tag' - id: 'get_tag' - shell: 'bash' - env: - SHA: 'ci-${{ github.sha }}' - run: 'echo "tag=$SHA" >> $GITHUB_OUTPUT' + - name: 'Set CI Version' + id: 'version' + run: | + CURRENT_VERSION=$(node -p "require('./package.json').version") + NEW_VERSION="${CURRENT_VERSION}-ci.${{ github.run_number }}.${{ github.sha }}" + echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT + npm version --no-git-tag-version "${NEW_VERSION}" - name: 'Publish to GitHub Packages' - run: 'npm publish --tag="${{ steps.get_tag.outputs.tag }}"' + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + npm publish --tag="pr-${{ github.event.pull_request.number }}" + else + npm publish --tag="ci" + fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 285d00e7a6..8836b3ccaa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,8 @@ name: 'Testing: CI' on: workflow_call: inputs: - tag: - description: 'The tag of the published package' + version: + description: 'The version of the published package' required: true type: 'string' diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 6cb583826c..f638f1355e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,8 +1,8 @@ on: workflow_call: inputs: - tag: - description: 'The tag of the published package' + version: + description: 'The version of the published package' required: true type: 'string' @@ -58,18 +58,8 @@ jobs: with: ref: '${{ github.event.inputs.branch_ref || github.ref }}' - - name: 'Set up Node.js ${{ matrix.node-version }}' - uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions-node@v4 - with: - node-version: '${{ matrix.node-version }}' - - - name: 'Configure npm for GitHub Packages' - run: | - echo "@google-gemini:registry=https://npm.pkg.github.com/" > .npmrc - echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc - - name: 'Install dependencies' - run: 'npm install @google-gemini/gemini-cli@${{ inputs.tag }}' + run: 'npm install @google-gemini/gemini-cli@${{ inputs.version }}' - name: 'Set up Docker' if: "matrix.sandbox == 'sandbox:docker'" diff --git a/.github/workflows/orchestrator.yml b/.github/workflows/orchestrator.yml index b7e73c43fa..da6bcb6039 100644 --- a/.github/workflows/orchestrator.yml +++ b/.github/workflows/orchestrator.yml @@ -35,11 +35,11 @@ jobs: needs: 'build-and-publish' uses: './.github/workflows/ci.yml' with: - tag: '${{ needs.build-and-publish.outputs.tag }}' + version: '${{ needs.build-and-publish.outputs.version }}' e2e: name: 'E2E Checks' needs: 'build-and-publish' uses: './.github/workflows/e2e.yml' with: - tag: '${{ needs.build-and-publish.outputs.tag }}' + version: '${{ needs.build-and-publish.outputs.version }}'