added autotagger
This commit is contained in:
parent
aa216b2f09
commit
0381749572
1 changed files with 43 additions and 0 deletions
43
.forgejo/workflows/autotagger.yaml
Normal file
43
.forgejo/workflows/autotagger.yaml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
name: Autotagger
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Extract commit message
|
||||||
|
id: extract_commit_message
|
||||||
|
run: echo "::set-output name=message::$(git log --format=%B -n 1 $GITHUB_SHA)"
|
||||||
|
|
||||||
|
- name: Check commit message
|
||||||
|
id: check_commit_message
|
||||||
|
run: |
|
||||||
|
COMMIT_MESSAGE=$(echo "${{ steps.extract_commit_message.outputs.message }}")
|
||||||
|
if [[ $COMMIT_MESSAGE =~ ^Version\ bumped\ to\ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
|
||||||
|
echo "Found version bump in commit message."
|
||||||
|
echo "::set-output name=version::${BASH_REMATCH[1]}"
|
||||||
|
else
|
||||||
|
echo "No version bump found in commit message."
|
||||||
|
LATEST_TAG=$(git describe --tags --abbrev=0)
|
||||||
|
echo "::set-output name=latest_tag::$LATEST_TAG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create or update tag
|
||||||
|
if: steps.check_commit_message.outputs.version
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.check_commit_message.outputs.version }}
|
||||||
|
git tag -a $VERSION -m "Version bumped to $VERSION"
|
||||||
|
git push origin $VERSION
|
||||||
|
|
||||||
|
- name: Force update latest tag
|
||||||
|
if: steps.check_commit_message.outputs.latest_tag
|
||||||
|
run: |
|
||||||
|
COMMIT_MESSAGE=$(echo "${{ steps.extract_commit_message.outputs.message }}")
|
||||||
|
LATEST_TAG=${{ steps.check_commit_message.outputs.latest_tag }}
|
||||||
|
git tag -fa $LATEST_TAG -m $COMMIT_MESSAGE
|
||||||
|
git push origin $LATEST_TAG --force
|
Reference in a new issue