@@ -210,10 +210,50 @@ jobs:
210210 essex-${{ matrix.target }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}.sha256
211211 retention-days : 5
212212
213+ create-tag :
214+ name : create-tag
215+ # Only run on main branch when Cargo.toml version changes
216+ if : github.ref == 'refs/heads/main'
217+ runs-on : ubuntu-latest
218+ outputs :
219+ version : ${{ steps.check-version.outputs.version }}
220+ should_tag : ${{ steps.check-version.outputs.should_tag }}
221+ permissions :
222+ contents : write
223+ steps :
224+ - uses : actions/checkout@v4
225+ with :
226+ fetch-depth : 0
227+
228+ - name : Check version change
229+ id : check-version
230+ run : |
231+ # Get the current version from Cargo.toml
232+ CURRENT_VERSION=$(grep '^version = ' Cargo.toml | cut -d '"' -f2)
233+ echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
234+
235+ # Check if this version is already tagged
236+ if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then
237+ echo "Version v$CURRENT_VERSION is already tagged"
238+ echo "should_tag=false" >> $GITHUB_OUTPUT
239+ else
240+ echo "Version v$CURRENT_VERSION needs to be tagged"
241+ echo "should_tag=true" >> $GITHUB_OUTPUT
242+ fi
243+
244+ - name : Create and push tag
245+ if : steps.check-version.outputs.should_tag == 'true'
246+ run : |
247+ VERSION=${{ steps.check-version.outputs.version }}
248+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
249+ git config --local user.name "github-actions[bot]"
250+ git tag -a "v$VERSION" -m "Release v$VERSION"
251+ git push origin "v$VERSION"
252+
213253 release :
214254 name : release
215- needs : [build-and-test, lint]
216- if : startsWith(github.ref, 'refs/tags/')
255+ needs : [build-and-test, lint, create-tag ]
256+ if : needs.create-tag.outputs.should_tag == 'true'
217257 runs-on : ubuntu-latest
218258 timeout-minutes : 10
219259 permissions :
0 commit comments