|
5 | 5 | # Release Types: |
6 | 6 | # - Stable: Push a tag (git tag v4.0.6 && git push origin v4.0.6) |
7 | 7 | # - Nightly: Automatic on every push to main branch (rolling release) |
8 | | -# - Manual: Actions -> Release -> Run workflow -> Enter version (e.g., v4.0.6) |
9 | | -# |
10 | | -# IMPORTANT for Manual Releases: |
11 | | -# The tag MUST exist before triggering the workflow. Create it first: |
12 | | -# git tag v4.0.7 && git push origin v4.0.7 |
13 | | -# Then trigger the workflow with the same version. |
| 8 | +# - Manual: Actions -> Release -> Run workflow -> Enter version (e.g., v4.0.7) |
| 9 | +# The tag will be auto-created on the current HEAD if it doesn't exist. |
14 | 10 |
|
15 | 11 | name: Release |
16 | 12 |
|
@@ -79,30 +75,36 @@ jobs: |
79 | 75 | echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT |
80 | 76 | echo "Release version: $VERSION" |
81 | 77 |
|
82 | | - - name: Verify tag exists (manual trigger) |
| 78 | + - name: Setup Git for tagging (manual trigger) |
83 | 79 | if: github.event_name == 'workflow_dispatch' |
84 | 80 | run: | |
85 | | - VERSION="${{ steps.version.outputs.version }}" |
86 | | - # Fetch all tags to ensure we have the latest |
87 | | - git fetch --tags --force |
88 | | - if ! git rev-parse "refs/tags/$VERSION" >/dev/null 2>&1; then |
89 | | - echo "::error::Tag '$VERSION' does not exist in the repository." |
90 | | - echo "::error::Please create the tag first using:" |
91 | | - echo "::error:: git tag $VERSION && git push origin $VERSION" |
92 | | - echo "" |
93 | | - echo "Available tags:" |
94 | | - git tag --list 'v*' | tail -20 |
95 | | - exit 1 |
96 | | - fi |
97 | | - echo "✓ Tag $VERSION exists and is valid" |
| 81 | + git config user.name "github-actions[bot]" |
| 82 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
98 | 83 |
|
99 | | - - name: Checkout tag (manual trigger) |
| 84 | + - name: Create or verify tag (manual trigger) |
100 | 85 | if: github.event_name == 'workflow_dispatch' |
101 | 86 | run: | |
102 | 87 | VERSION="${{ steps.version.outputs.version }}" |
103 | | - echo "Checking out tag: $VERSION" |
104 | | - git checkout "refs/tags/$VERSION" |
105 | | - echo "✓ Successfully checked out $VERSION" |
| 88 | + # Fetch all tags to ensure we have the latest |
| 89 | + git fetch --tags --force |
| 90 | + |
| 91 | + if git rev-parse "refs/tags/$VERSION" >/dev/null 2>&1; then |
| 92 | + echo "✓ Tag $VERSION already exists" |
| 93 | + echo "Checking out existing tag..." |
| 94 | + git checkout "refs/tags/$VERSION" |
| 95 | + else |
| 96 | + echo "Tag $VERSION does not exist, creating it on current HEAD..." |
| 97 | + CURRENT_SHA=$(git rev-parse HEAD) |
| 98 | + echo "Creating tag $VERSION at commit $CURRENT_SHA" |
| 99 | + |
| 100 | + # Create the tag locally |
| 101 | + git tag -a "$VERSION" -m "Release $VERSION" |
| 102 | + |
| 103 | + # Push the tag to remote |
| 104 | + git push origin "$VERSION" |
| 105 | + |
| 106 | + echo "✓ Tag $VERSION created and pushed successfully" |
| 107 | + fi |
106 | 108 |
|
107 | 109 | - name: Generate changelog |
108 | 110 | id: changelog |
|
0 commit comments