diff --git a/.github/workflows/push-tag.yaml b/.github/workflows/push-tag.yaml new file mode 100644 index 000000000..e34bb11d7 --- /dev/null +++ b/.github/workflows/push-tag.yaml @@ -0,0 +1,43 @@ +name: Push Tag on VERSION change + +on: + push: + branches: + - release-* + paths: + - VERSION + +jobs: + push_tag: + runs-on: ubuntu-latest + + steps: + - name: Checkout source code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Read version from VERSION file + run: | + VERSION=$(cat VERSION) + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Check if tag exists + run: | + git fetch --tags + if git tag -l | grep -q "^${VERSION}$"; then + echo "TAG_EXISTS=true" >> $GITHUB_ENV + else + echo "TAG_EXISTS=false" >> $GITHUB_ENV + fi + + - name: Create and push tag + if: env.TAG_EXISTS == 'false' + run: | + git tag -a "$VERSION" -m "Release $VERSION" + git push origin "$VERSION"