From cbeecd5385de562fbda3a717e0d39b2c8d589d75 Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Fri, 3 Oct 2025 13:30:40 -0500 Subject: [PATCH] ci(release): trigger release workflow from promotion and internal builds (#3315) --- .github/workflows/create-internal-release.yml | 25 +++++++++++++++++++ .github/workflows/promote-release.yml | 25 +++++++++++++++++++ .github/workflows/release.yml | 22 +++------------- 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/.github/workflows/create-internal-release.yml b/.github/workflows/create-internal-release.yml index 007876c97..044ca2745 100644 --- a/.github/workflows/create-internal-release.yml +++ b/.github/workflows/create-internal-release.yml @@ -13,6 +13,7 @@ on: permissions: contents: write + actions: write jobs: create-internal-tag: @@ -60,9 +61,33 @@ jobs: git push origin "$TAG" echo "Created and pushed $TAG" + - name: Trigger Release Workflow for Tag + if: ${{ inputs.dry_run != 'true' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + TAG='${{ steps.tag.outputs.internal_tag }}' + echo "Dispatching release workflow for $TAG" + for i in {1..5}; do + if gh api \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + repos/${{ github.repository }}/actions/workflows/release.yml/dispatches \ + -f ref="$TAG"; then + echo "Triggered release workflow for $TAG" + break + fi + echo "Retry $i/5 in 5s..." + sleep 5 + done + - name: Output Summary run: | echo "### Internal Tag Created" >> $GITHUB_STEP_SUMMARY echo "Tag: ${{ steps.tag.outputs.internal_tag }}" >> $GITHUB_STEP_SUMMARY echo "Base Version: ${{ inputs.base_version }}" >> $GITHUB_STEP_SUMMARY echo "Dry Run: ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY + if [ "${{ inputs.dry_run }}" != "true" ]; then + echo "Release workflow dispatched for tag ${{ steps.tag.outputs.internal_tag }}" >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/promote-release.yml b/.github/workflows/promote-release.yml index ae936a6e8..1d480b480 100644 --- a/.github/workflows/promote-release.yml +++ b/.github/workflows/promote-release.yml @@ -23,6 +23,7 @@ on: permissions: contents: write + actions: write jobs: promote: @@ -186,6 +187,27 @@ jobs: git push origin "$TAG" echo "Created and pushed $TAG" + - name: Trigger Release Workflow for Tag + if: ${{ inputs.dry_run != 'true' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + TAG='${{ steps.tag.outputs.new_tag }}' + echo "Dispatching release workflow for $TAG" + for i in {1..5}; do + if gh api \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + repos/${{ github.repository }}/actions/workflows/release.yml/dispatches \ + -f ref="$TAG"; then + echo "Triggered release workflow for $TAG" + break + fi + echo "Retry $i/5 in 5s..." + sleep 5 + done + - name: Promotion Summary run: | echo "### Promotion Tag Created" >> $GITHUB_STEP_SUMMARY @@ -194,3 +216,6 @@ jobs: echo "Target Stage: ${{ steps.decide.outputs.target_stage }}" >> $GITHUB_STEP_SUMMARY echo "New Tag: ${{ steps.tag.outputs.new_tag }}" >> $GITHUB_STEP_SUMMARY echo "Dry Run: ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY + if [ "${{ inputs.dry_run }}" != "true" ]; then + echo "Release workflow dispatched for tag ${{ steps.tag.outputs.new_tag }}" >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dfc6dce57..ccca09e6d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,7 +56,7 @@ jobs: - name: Extract VERSION_CODE_OFFSET from config.properties id: get_version_code_offset run: | - OFFSET=$(grep '^VERSION_CODE_OFFSET=' config.properties | cut-d'=' -f2) + OFFSET=$(grep '^VERSION_CODE_OFFSET=' config.properties | cut -d'=' -f2) echo "VERSION_CODE_OFFSET=$OFFSET" >> $GITHUB_OUTPUT - name: Calculate Version Code from Git Commit Count @@ -276,29 +276,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Determine Release Properties for Promotion - if: "!contains(github.ref_name, '-internal')" - id: release_properties - run: | - TAG_NAME="${{ github.ref_name }}" - if [[ "$TAG_NAME" == *"-closed"* ]]; then - echo "draft=false" >> $GITHUB_OUTPUT - echo "prerelease=true" >> $GITHUB_OUTPUT - elif [[ "$TAG_NAME" == *"-open"* ]]; then - echo "draft=false" >> $GITHUB_OUTPUT - echo "prerelease=true" >> $GITHUB_OUTPUT - else - echo "draft=false" >> $GITHUB_OUTPUT - echo "prerelease=false" >> $GITHUB_OUTPUT - fi - - name: Promote GitHub Release if: "!contains(github.ref_name, '-internal')" uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.prepare-build-info.outputs.BASE_TAG }} name: ${{ github.ref_name }} - draft: ${{ steps.release_properties.outputs.draft }} - prerelease: ${{ steps.release_properties.outputs.prerelease }} + draft: false + prerelease: ${{ contains(github.ref_name, '-closed') || contains(github.ref_name, '-open') }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}