Skip to content

Commit

Permalink
ci: add working semver autotag (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gornak40 authored Oct 20, 2024
1 parent 0bf2703 commit 46b1317
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/semver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Semver

on:
push:
branches:
- master

jobs:
set_tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run version bump script
run: |
VERSION=$(./scripts/semver.sh)
echo "Project version: $VERSION"
git config --global user.name "Gornak40[bot]"
git config --global user.email "noreply@algolymp.ru"
MESSAGE=$(git log -1 --pretty=%B)
git tag $VERSION -m $MESSAGE
git push origin $VERSION
22 changes: 22 additions & 0 deletions scripts/semver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/bash
major=0
minor=0
patch=0

commits=$(git log --reverse --pretty=format:"%s")

while read -r commit_msg; do
if [[ $commit_msg == major* ]]; then
((major++))
minor=0
patch=0
elif [[ $commit_msg == feat* ]]; then
((minor++))
patch=0
else
((patch++))
fi
>&2 echo "[v$major.$minor.$patch] $commit_msg"
done <<< $commits

echo "v$major.$minor.$patch"

0 comments on commit 46b1317

Please sign in to comment.