mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 07:16:15 +00:00
60 lines
1.8 KiB
YAML
60 lines
1.8 KiB
YAML
name: Version bump
|
|
|
|
on:
|
|
push:
|
|
branches: [development, main]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
bump:
|
|
if: github.actor != 'github-actions[bot]'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Configure git
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
- name: Bump version
|
|
run: |
|
|
set -euo pipefail
|
|
CURRENT=$(cat VERSION)
|
|
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
|
|
|
|
if [ "${{ github.ref_name }}" = "development" ]; then
|
|
PATCH=$((PATCH + 1))
|
|
elif [ "${{ github.ref_name }}" = "main" ]; then
|
|
# Merge commit from an approved development -> main PR: bump MINOR.
|
|
# Any other push to main is treated as a hotfix: bump PATCH.
|
|
PARENTS=$(git log -1 --pretty=%P | wc -w)
|
|
if [ "$PARENTS" -ge 2 ] && git log -1 --pretty=%s | grep -qi "development"; then
|
|
MINOR=$((MINOR + 1))
|
|
PATCH=0
|
|
else
|
|
PATCH=$((PATCH + 1))
|
|
fi
|
|
fi
|
|
|
|
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
|
|
echo "$NEW_VERSION" > VERSION
|
|
git add VERSION
|
|
git commit -m "chore(release): v$NEW_VERSION [skip ci]"
|
|
git tag "v$NEW_VERSION"
|
|
git push origin HEAD:${{ github.ref_name }}
|
|
git push origin "v$NEW_VERSION"
|
|
|
|
- name: Merge main back into development
|
|
if: github.ref_name == 'main'
|
|
run: |
|
|
git fetch origin development
|
|
git checkout development
|
|
git merge --no-edit origin/main
|
|
git push origin development
|