From 23295a049d4bc34436b44f856650f824589aaa56 Mon Sep 17 00:00:00 2001 From: dacrab Date: Fri, 27 Dec 2024 12:51:16 +0200 Subject: [PATCH] ci: add automatic version tagging workflow --- .github/workflows/auto-tag.yml | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/auto-tag.yml diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml new file mode 100644 index 0000000..8056e18 --- /dev/null +++ b/.github/workflows/auto-tag.yml @@ -0,0 +1,42 @@ +name: Auto Tag + +on: + push: + branches: + - master + - main + paths-ignore: + - '**.md' + - '.gitignore' + - '.github/**' + +jobs: + auto-tag: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get latest tag + id: get_latest_tag + run: | + git fetch --tags + latest_tag=$(git tag -l 'v*' --sort=-v:refname | head -n 1) + if [ -z "$latest_tag" ]; then + echo "version=v0.1.0" >> $GITHUB_OUTPUT + else + major=$(echo $latest_tag | cut -d. -f1) + minor=$(echo $latest_tag | cut -d. -f2) + patch=$(echo $latest_tag | cut -d. -f3) + new_patch=$((patch + 1)) + echo "version=$major.$minor.$new_patch" >> $GITHUB_OUTPUT + fi + + - name: Create new tag + run: | + new_tag=${{ steps.get_latest_tag.outputs.version }} + git tag $new_tag + git push origin $new_tag \ No newline at end of file