Skip to content

Commit

Permalink
Added version auto-tag script
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-james committed Feb 7, 2024
1 parent d14746a commit a7b8b67
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/version_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create Tag on Version Change

on:
push:
branches: [ main ]
paths:
- 'pyproject.toml'
- 'DESCRIPTION'
- 'configure.ac'

jobs:
check-version-and-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Check for version changes and create tag
run: |
py_version=$(awk -F' = ' '/^version =/ {gsub(/"/, "", $2); print $2}' pyproject.toml)
ac_version=$(awk -F'[][ ,]+' '/AC_INIT\(/{gsub(/ /, "", $0); print $3 }' configure.ac)
r_version=$(awk '/^Version:/ {print $2}' DESCRIPTION)
if [ "$py_version" = "$ac_version" ] && [ "$py_version" = "$r_version" ]; then
git fetch --tags
TAG_EXISTS=$(git tag -l "${py_version}")
if [ -z "${TAG_EXISTS}" ]; then
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
git tag "${py_version}"
git push origin "${py_version}" -f
else
echo "Tag ${py_version} already exists"
fi
else
echo "Error: Version numbers are not synchronized!"
echo "pyproject.toml version: $py_version"
echo "configure.ac version: $ac_version"
echo "DESCRIPTION version: $r_version"
exit 1
fi

0 comments on commit a7b8b67

Please sign in to comment.