From 2810ddf79f54a96b0ddcafb50eb304dc317a8c96 Mon Sep 17 00:00:00 2001 From: Yi Chen Date: Mon, 22 Jul 2024 10:59:09 +0800 Subject: [PATCH] Add workflow for pushing tag when VERSION file changes Signed-off-by: Yi Chen --- .github/workflows/push-tag.yaml | 44 +++++++++++++++++++++++++++++++++ VERSION | 1 + 2 files changed, 45 insertions(+) create mode 100644 .github/workflows/push-tag.yaml create mode 100644 VERSION diff --git a/.github/workflows/push-tag.yaml b/.github/workflows/push-tag.yaml new file mode 100644 index 000000000..f9329f080 --- /dev/null +++ b/.github/workflows/push-tag.yaml @@ -0,0 +1,44 @@ +name: Push Tag on VERSION change + +on: + push: + branches: + - master + - 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" diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..17da53b58 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v1beta2-1.6.2-3.5.0 \ No newline at end of file