name: Create Internal Release Tag on: workflow_dispatch: inputs: base_version: description: "Base version to iterate on (e.g. 2.6.7). The next internal iteration will be created for this version." required: true dry_run: description: "If true, calculate but do not push tag" required: false default: "false" permissions: contents: write actions: write jobs: create-internal-tag: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v5 with: fetch-depth: 0 - name: Compute Tag id: tag run: | set -euo pipefail BASE='${{ inputs.base_version }}' # Find the highest existing internal tag for this base version and increment it. EXISTING=$(git tag --list "v${BASE}-internal.*" | sed -E 's/^v.*-internal\.([0-9]+)$/\1/' | sort -n | tail -1 || true) if [ -z "$EXISTING" ]; then NEXT=1; else NEXT=$((EXISTING+1)); fi FINAL_TAG="v${BASE}-internal.${NEXT}" # Check if the tag already exists for some reason (e.g. race condition). if git tag --list | grep -q "^${FINAL_TAG}$"; then echo "Tag ${FINAL_TAG} already exists." >&2 exit 1 fi echo "internal_tag=$FINAL_TAG" >> $GITHUB_OUTPUT - name: Dry Run Preview if: ${{ inputs.dry_run == 'true' }} run: | echo "DRY RUN: Would create tag ${{ steps.tag.outputs.internal_tag }} pointing to $(git rev-parse HEAD)" git log -5 --oneline - name: Configure Git User if: ${{ inputs.dry_run != 'true' }} run: | git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" - name: Create and Push Tag if: ${{ inputs.dry_run != 'true' }} run: | TAG='${{ steps.tag.outputs.internal_tag }}' MSG="Internal build iteration for ${TAG}" git tag -a "$TAG" -m "$MSG" 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