46 lines
1.2 KiB
YAML
46 lines
1.2 KiB
YAML
name: Auto Tag Develop
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- develop
|
|
|
|
jobs:
|
|
tag:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
token: ${{ secrets.RELEASE_TOKEN }}
|
|
persist-credentials: true
|
|
|
|
- name: Create next tag v0.0.X
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
# Skip if current commit already has a v0.0.* tag
|
|
if git tag --points-at HEAD | grep -qE '^v0\.0\.'; then
|
|
echo "Tag already exists on this commit. Skipping."
|
|
exit 0
|
|
fi
|
|
|
|
last_tag="$(git tag -l 'v0.0.*' --sort=-v:refname | head -n1 || true)"
|
|
if [ -z "$last_tag" ]; then
|
|
next_tag="v0.0.1"
|
|
else
|
|
patch="${last_tag##v0.0.}"
|
|
if ! [[ "$patch" =~ ^[0-9]+$ ]]; then
|
|
echo "Unexpected tag format: $last_tag" >&2
|
|
exit 1
|
|
fi
|
|
next_tag="v0.0.$((patch + 1))"
|
|
fi
|
|
|
|
git config user.name "gitea-actions"
|
|
git config user.email "gitea-actions@local"
|
|
git tag "$next_tag"
|
|
git push origin "$next_tag"
|