feat: added autotagger workflow
Some checks failed
Autotagger / Autotagger (push) Failing after 7s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 22s
Actions / Build Documentation (MkDocs) (push) Successful in 20s

This commit is contained in:
SeaswimmerTheFsh 2024-03-29 07:59:59 -04:00
parent bd7b445705
commit 81e643b21a
Signed by: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -0,0 +1,66 @@
name: Autotagger
on:
push:
branches:
- 'main'
jobs:
Autotagger:
runs-on: docker
container: catthehacker/ubuntu:act-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "SeaswimmerTheFsh"
git config --global user.email "seaswimmerthefsh@gmail.com"
- name: Import GPG key
uses: actions/gpg@v4
with:
gpg_private_key : ${{ secrets.GPG_PRIVATE_KEY }}
passphrase : ${{ secrets.GPG_PASSPHRASE }}
- name: Extract commit message
id: extract_commit_message
run: echo "::set-output name=message::$(git log --format=%B -n 1 $GITHUB_SHA)
- name: Get new version
id: get_version
run: ::set-output name=version::$(awk -F '=' '/^ *version/ {gsub(/[[:space:]]/, "", $2); print $2}' pyproject.toml)
- name: Get latest tag
id: get_latest_tag
run: |
git fetch --tags
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "::set-output name=latest_tag::$LATEST_TAG"
- name: Compare version and latest tag
id: compare
run: |
VERSION=${{ steps.get_version.outputs.version }}
LATEST_TAG=${{ steps.get_latest_tag.outputs.latest_tag }}
if [ "$VERSION" = "$LATEST_TAG" ]; then
echo "::set-output name=latest_tag::$LATEST_TAG"
fi
echo "::set-output name=version::$VERSION"
- name: Create tag
if: steps.compare.outputs.version
run: |
VERSION=${{ steps.get_version.outputs.version }}
git tag -s $VERSION -m "version bumped to $VERSION"
git push origin $VERSION
- name: Update latest tag
if: steps.compare.outputs.latest_tag
run: |
MESSAGE=${{ steps.extract_commit_message.outputs.message }}
LATEST_TAG=${{ steps.compare.outputs.latest_tag }}
git tag -fs $LATEST_TAG -m "$MESSAGE"
git push origin $LATEST_TAG --force