@@ -52,41 +52,77 @@ jobs:
5252 - name : Create temporary branch and commit
5353 id : commit
5454 run : |
55- # Always create temporary branch - will merge to main only if draft release succeeds
56- TEMP_BRANCH="tmp-version-${{ inputs.version }}"
57- echo "📦 Creating temporary branch: $TEMP_BRANCH"
58-
5955 git config user.name "github-actions[bot]"
6056 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
61- git checkout -b "$TEMP_BRANCH"
6257 git add package.json release/app/package.json
63- git commit -m "chore: bump version to v${{ inputs.version }}
58+
59+ # Check if there are changes to commit
60+ if git diff --staged --quiet; then
61+ echo "⚠️ No changes detected - version already set to v${{ inputs.version }}"
62+ echo "Using current branch: ${{ github.ref_name }}"
63+
64+ # Delete existing tag if present
65+ if git tag -l "v${{ inputs.version }}" | grep -q "v${{ inputs.version }}"; then
66+ git tag -d "v${{ inputs.version }}"
67+ git push origin --delete "v${{ inputs.version }}" 2>/dev/null || true
68+ fi
69+
70+ # Create tag on current commit
71+ git tag -a "v${{ inputs.version }}" \
72+ -m "Release v${{ inputs.version }}" \
73+ -m "Workflow: ${{ github.workflow }}" \
74+ -m "Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
75+
76+ git push origin "v${{ inputs.version }}"
77+
78+ echo "branch_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
79+ echo "✅ Using existing branch: ${{ github.ref_name }}"
80+ else
81+ # Changes detected - create temporary branch
82+ TEMP_BRANCH="tmp-version-${{ inputs.version }}"
83+ echo "📦 Creating temporary branch: $TEMP_BRANCH"
84+
85+ git checkout -b "$TEMP_BRANCH"
86+ git commit -m "chore: bump version to v${{ inputs.version }}
6487
6588 ⚠️ TEMPORARY BRANCH - builds will use this
6689 Will merge to main only if draft release succeeds.
6790
6891 🤖 Generated by GitHub Actions
6992 Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
7093
71- git tag -a "v${{ inputs.version }}" \
72- -m "Release v${{ inputs.version }}" \
73- -m "Branch: $TEMP_BRANCH (temporary)" \
74- -m "Workflow: ${{ github.workflow }}" \
75- -m "Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
94+ git tag -a "v${{ inputs.version }}" \
95+ -m "Release v${{ inputs.version }}" \
96+ -m "Branch: $TEMP_BRANCH (temporary)" \
97+ -m "Workflow: ${{ github.workflow }}" \
98+ -m "Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
7699
77- git push origin "$TEMP_BRANCH"
78- git push origin "v${{ inputs.version }}"
100+ git push origin "$TEMP_BRANCH"
101+ git push origin "v${{ inputs.version }}"
79102
80- echo "branch_name=$TEMP_BRANCH" >> $GITHUB_OUTPUT
81- echo "✅ Temporary branch created: $TEMP_BRANCH"
103+ echo "branch_name=$TEMP_BRANCH" >> $GITHUB_OUTPUT
104+ echo "✅ Temporary branch created: $TEMP_BRANCH"
105+ fi
82106
83107 - name : Summary
84108 run : |
85- echo "### ✅ Version Bumped (Temporary Branch)" >> $GITHUB_STEP_SUMMARY
86- echo "" >> $GITHUB_STEP_SUMMARY
87- echo "- **Version**: v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
88- echo "- **Branch**: ${{ steps.commit.outputs.branch_name }}" >> $GITHUB_STEP_SUMMARY
89- echo "- **Commit**: $(git rev-parse HEAD)" >> $GITHUB_STEP_SUMMARY
90- echo "- **Tag**: v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
91- echo "" >> $GITHUB_STEP_SUMMARY
92- echo "⚠️ **Note**: Temporary branch - will merge to main if draft release succeeds" >> $GITHUB_STEP_SUMMARY
109+ BRANCH_NAME="${{ steps.commit.outputs.branch_name }}"
110+
111+ if [[ "$BRANCH_NAME" == tmp-version-* ]]; then
112+ echo "### ✅ Version Bumped (Temporary Branch)" >> $GITHUB_STEP_SUMMARY
113+ echo "" >> $GITHUB_STEP_SUMMARY
114+ echo "- **Version**: v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
115+ echo "- **Branch**: $BRANCH_NAME" >> $GITHUB_STEP_SUMMARY
116+ echo "- **Commit**: $(git rev-parse HEAD)" >> $GITHUB_STEP_SUMMARY
117+ echo "- **Tag**: v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
118+ echo "" >> $GITHUB_STEP_SUMMARY
119+ echo "⚠️ **Note**: Temporary branch - will merge to main if draft release succeeds" >> $GITHUB_STEP_SUMMARY
120+ else
121+ echo "### ✅ Version Tag Created" >> $GITHUB_STEP_SUMMARY
122+ echo "" >> $GITHUB_STEP_SUMMARY
123+ echo "- **Version**: v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
124+ echo "- **Branch**: $BRANCH_NAME (no changes needed)" >> $GITHUB_STEP_SUMMARY
125+ echo "- **Tag**: v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
126+ echo "" >> $GITHUB_STEP_SUMMARY
127+ echo "ℹ️ **Note**: Version already set - using existing branch" >> $GITHUB_STEP_SUMMARY
128+ fi
0 commit comments