From 4a019b3aa81fe2470dc6263e18964ec65d9af93e Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sun, 7 Sep 2025 14:26:42 +1000 Subject: [PATCH] ci(v3-nightly): tag after committing version/changelog so tag points to updated commit --- .github/workflows/nightly-release-v3.yml | 146 ++++++++++++----------- 1 file changed, 74 insertions(+), 72 deletions(-) diff --git a/.github/workflows/nightly-release-v3.yml b/.github/workflows/nightly-release-v3.yml index 54649f518..950cb5abd 100644 --- a/.github/workflows/nightly-release-v3.yml +++ b/.github/workflows/nightly-release-v3.yml @@ -320,75 +320,10 @@ jobs: echo "has_release_errors=false" >> $GITHUB_OUTPUT fi - - name: Create and push git tag - id: git_tag - if: | - (steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true') && - steps.check_tag.outputs.has_tag == 'false' && - github.event.inputs.dry_run != 'true' && - steps.release.outputs.success == 'true' && - steps.release.outputs.version_changed == 'true' - env: - GITHUB_TOKEN: ${{ github.token }} - run: | - echo "🏷️ Creating and pushing git tag: ${{ steps.release.outputs.tag }}" - - # Initialize error tracking - GIT_ERRORS="" - GIT_SUCCESS=true - - # Create git tag with error handling - if git tag -a "${{ steps.release.outputs.tag }}" -m "Release ${{ steps.release.outputs.version }}" 2>&1; then - echo "✅ Successfully created git tag: ${{ steps.release.outputs.tag }}" - else - echo "❌ Failed to create git tag" - GIT_ERRORS="$GIT_ERRORS\n- Failed to create git tag: ${{ steps.release.outputs.tag }}" - GIT_SUCCESS=false - fi - - # Push tag with retry logic and error handling - if [ "$GIT_SUCCESS" == "true" ]; then - RETRY_COUNT=0 - MAX_RETRIES=3 - PUSH_SUCCESS=false - - while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ "$PUSH_SUCCESS" == "false" ]; do - RETRY_COUNT=$((RETRY_COUNT + 1)) - echo "🔄 Attempting to push tag (attempt $RETRY_COUNT/$MAX_RETRIES)..." - - if git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" "${{ steps.release.outputs.tag }}" 2>&1; then - echo "✅ Successfully pushed git tag to origin" - PUSH_SUCCESS=true - else - echo "❌ Failed to push git tag (attempt $RETRY_COUNT/$MAX_RETRIES)" - if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then - echo "⏳ Waiting 5 seconds before retry..." - sleep 5 - fi - fi - done - - if [ "$PUSH_SUCCESS" == "false" ]; then - echo "❌ Failed to push git tag after $MAX_RETRIES attempts" - GIT_ERRORS="$GIT_ERRORS\n- Failed to push git tag after $MAX_RETRIES attempts" - GIT_SUCCESS=false - fi - fi - - # Set outputs for later steps - echo "success=$GIT_SUCCESS" >> $GITHUB_OUTPUT - - if [ -n "$GIT_ERRORS" ]; then - echo "git_tag_errors<> $GITHUB_OUTPUT - echo -e "$GIT_ERRORS" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - echo "has_git_errors=true" >> $GITHUB_OUTPUT - else - echo "has_git_errors=false" >> $GITHUB_OUTPUT - fi + - - name: Commit and push changes - id: git_commit + - name: Commit and push changes + id: git_commit if: | (steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true') && github.event.inputs.dry_run != 'true' && @@ -465,9 +400,76 @@ jobs: echo -e "$COMMIT_ERRORS" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT echo "has_commit_errors=true" >> $GITHUB_OUTPUT - else - echo "has_commit_errors=false" >> $GITHUB_OUTPUT - fi + else + echo "has_commit_errors=false" >> $GITHUB_OUTPUT + fi + + - name: Create and push git tag + id: git_tag + if: | + (steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true') && + steps.check_tag.outputs.has_tag == 'false' && + github.event.inputs.dry_run != 'true' && + steps.release.outputs.success == 'true' && + steps.release.outputs.version_changed == 'true' + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + echo "🏷️ Creating and pushing git tag: ${{ steps.release.outputs.tag }}" + + # Initialize error tracking + GIT_ERRORS="" + GIT_SUCCESS=true + + # Create git tag with error handling (post-commit so tag points to the right commit) + if git tag -a "${{ steps.release.outputs.tag }}" -m "Release ${{ steps.release.outputs.version }}" 2>&1; then + echo "✅ Successfully created git tag: ${{ steps.release.outputs.tag }}" + else + echo "❌ Failed to create git tag" + GIT_ERRORS="$GIT_ERRORS\n- Failed to create git tag: ${{ steps.release.outputs.tag }}" + GIT_SUCCESS=false + fi + + # Push tag with retry logic and error handling + if [ "$GIT_SUCCESS" == "true" ]; then + RETRY_COUNT=0 + MAX_RETRIES=3 + PUSH_SUCCESS=false + + while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ "$PUSH_SUCCESS" == "false" ]; do + RETRY_COUNT=$((RETRY_COUNT + 1)) + echo "🔄 Attempting to push tag (attempt $RETRY_COUNT/$MAX_RETRIES)..." + + if git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" "${{ steps.release.outputs.tag }}" 2>&1; then + echo "✅ Successfully pushed git tag to origin" + PUSH_SUCCESS=true + else + echo "❌ Failed to push git tag (attempt $RETRY_COUNT/$MAX_RETRIES)" + if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then + echo "⏳ Waiting 5 seconds before retry..." + sleep 5 + fi + fi + done + + if [ "$PUSH_SUCCESS" == "false" ]; then + echo "❌ Failed to push git tag after $MAX_RETRIES attempts" + GIT_ERRORS="$GIT_ERRORS\n- Failed to push git tag after $MAX_RETRIES attempts" + GIT_SUCCESS=false + fi + fi + + # Set outputs for later steps + echo "success=$GIT_SUCCESS" >> $GITHUB_OUTPUT + + if [ -n "$GIT_ERRORS" ]; then + echo "git_tag_errors<> $GITHUB_OUTPUT + echo -e "$GIT_ERRORS" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + echo "has_git_errors=true" >> $GITHUB_OUTPUT + else + echo "has_git_errors=false" >> $GITHUB_OUTPUT + fi - name: Read release notes id: read_notes @@ -760,4 +762,4 @@ jobs: if [ "${{ steps.error_summary.outputs.overall_success }}" != "true" ]; then echo "⚠️ Workflow completed with errors. Check the summary above for details." exit 1 - fi \ No newline at end of file + fi