Browse Source

ci: add automatic version tagging workflow

pull/85/head
dacrab 5 months ago
parent
commit
23295a049d
  1. 42
      .github/workflows/auto-tag.yml

42
.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
Loading…
Cancel
Save