-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d14746a
commit a7b8b67
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |