22 push :
33 branches :
44 - main
5+ - release/*
56 paths :
67 - ' Cargo.toml'
78
@@ -85,11 +86,27 @@ jobs:
8586 - name : ' Build'
8687 run : cargo build --release --all-features
8788
89+ version :
90+ name : Get Version
91+ needs : build_linux
92+ runs-on : ubuntu-latest
93+ steps :
94+ - uses : actions/checkout@v3
95+ - name : Get version from Cargo.toml
96+ id : version
97+ run : |
98+ VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/' | sed 's/-.*//')
99+ echo "version=$VERSION" >> $GITHUB_OUTPUT
100+ echo "Version detected: $VERSION"
101+ echo "Release suffix detected: $RELEASE_SUFFIX"
102+ echo "Full version detected: $FULL_VERSION"
103+
88104 add_version_tag :
89105 name : Add Version Tag
90106 needs :
91107 - check_context_tokens
92108 - build_linux
109+ - version
93110
94111 runs-on : ubuntu-latest
95112 timeout-minutes : 10
@@ -104,23 +121,30 @@ jobs:
104121
105122 - name : Create Git Tag
106123 run : |
107- git config --global user.name " github-actions[bot]"
124+ git config --global user.name "github-actions[bot]"
125+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
126+
127+ TAG="v${{ steps.version.outputs.version }}"
128+
108129 # Check if tag already exists
109- if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
110- echo "Tag v${{ steps.version.outputs.version }} already exists, skipping tag creation"
111- exit 0
130+ if git rev-parse "$TAG" >/dev/null 2>&1; then
131+ echo "Tag $TAG already exists, moving it to the latest commit"
132+ # Delete the tag locally and remotely
133+ git tag -d "$TAG"
134+ git push origin ":refs/tags/$TAG" || true
112135 fi
113136
114- git config --global user.email "github-actions[bot]@users.noreply.github.com"
115- git tag "v${{ steps.version.outputs.version }} "
116- git push origin "v${{ steps.version.outputs.version }} "
137+ # Create and push the new tag
138+ git tag "$TAG "
139+ git push origin "$TAG "
117140
118141 crates_io_publish :
119142 name : Publish (crates.io)
120143 needs :
121144 - check_context_tokens
122145 - audit
123146 - build_linux
147+ - version
124148
125149 runs-on : ubuntu-latest
126150 timeout-minutes : 10
@@ -158,6 +182,8 @@ jobs:
158182 needs :
159183 - audit
160184 - build_linux
185+ - add_version_tag
186+ - version
161187
162188 runs-on : ubuntu-latest
163189 timeout-minutes : 15
0 commit comments