-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ automatically tag new versions (#284)
- Loading branch information
Showing
1 changed file
with
46 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,46 @@ | ||
name: Tag Version | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tag-version: | ||
runs-on: ubuntu-latest | ||
if: "contains(github.event.head_commit.message, ':bookmark:')" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: Tag version | ||
run: | | ||
msg_start=':bookmark: Version ' | ||
version_format='[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}' | ||
version=$(git log -1 --skip=0 --pretty=%s | grep -oP "(?<=${msg_start})${version_format}") | ||
if [ -z "${version}" ]; then | ||
echo 'Version not found, aborting.' | ||
exit 1 | ||
fi | ||
echo "Found version: ${version}"; | ||
tag="v${version}"; | ||
echo "Would tag: ${tag}"; | ||
existing_tag=$(git tag -l "${tag}"); | ||
if [ "${existing_tag}" ]; then | ||
echo "Tag '${existing_tag}' already exists, aborting."; | ||
exit 1; | ||
fi | ||
git config user.name "Mindee"; | ||
git config user.email "opensource@mindee.com" | ||
git tag -a "${tag}" -m"Version ${version}"; | ||
git push origin "${tag}" | ||
echo "Tagged and pushed: ${tag}" |