Files
2026-10-18 21:18:17 +02:00

75 lines
2.2 KiB
YAML

name: Version
on:
push:
branches: [development, main]
permissions:
contents: write
concurrency:
group: version-${{ gitea.ref_name }}
cancel-in-progress: false
jobs:
bump:
if: ${{ !contains(gitea.event.head_commit.message, '[skip ci]') && gitea.actor != 'gitea-actions' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ gitea.ref_name }}
fetch-depth: 0
token: ${{ gitea.token }}
- name: Configure git identity
run: |
git config user.name "gitea-actions"
git config user.email "gitea-actions@noreply.git.zenvairo.es"
- name: Determine bump type
id: bump
run: |
if [ "${{ gitea.ref_name }}" = "development" ]; then
echo "type=patch" >> "$GITHUB_OUTPUT"
else
# main: minor bump only when this push is a merge (an approved
# development -> main PR), otherwise a direct hotfix push.
MERGE_COMMIT=$(git log -1 --merges --pretty=%H || true)
if [ -n "$MERGE_COMMIT" ]; then
echo "type=minor" >> "$GITHUB_OUTPUT"
else
echo "type=patch" >> "$GITHUB_OUTPUT"
fi
fi
- name: Bump VERSION
id: version
run: |
current=$(cat VERSION)
IFS='.' read -r major minor patch <<< "$current"
if [ "${{ steps.bump.outputs.type }}" = "minor" ]; then
minor=$((minor + 1))
patch=0
else
patch=$((patch + 1))
fi
new="$major.$minor.$patch"
echo "$new" > VERSION
echo "new=$new" >> "$GITHUB_OUTPUT"
- name: Commit and push version bump
run: |
git add VERSION
git commit -m "chore(release): v${{ steps.version.outputs.new }} [skip ci]"
git pull --rebase origin ${{ gitea.ref_name }}
git push origin HEAD:${{ gitea.ref_name }}
- name: Merge main back into development
if: gitea.ref_name == 'main'
run: |
git fetch origin development
git checkout development
git merge --no-edit origin/main
git push origin development