mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 07:16:17 +00:00
Pushing main and development together raced: the main run's merge back into development was rejected because the development run had moved it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
2.1 KiB
YAML
61 lines
2.1 KiB
YAML
name: version
|
|
on:
|
|
push:
|
|
branches: [development, main]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
# Pushes to main and development in quick succession must not bump or merge back concurrently.
|
|
concurrency:
|
|
group: version
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
bump:
|
|
if: >-
|
|
!contains(github.event.head_commit.message, '[skip ci]') &&
|
|
github.actor != 'github-actions[bot]' && github.actor != 'gitea-actions'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Bump version
|
|
env:
|
|
BEFORE: ${{ github.event.before }}
|
|
run: |
|
|
set -euo pipefail
|
|
git config user.name "version-bot"
|
|
git config user.email "version-bot@noreply.local"
|
|
branch="$GITHUB_REF_NAME"
|
|
# Bump on top of the branch tip, which an earlier run may have moved.
|
|
git fetch origin "$branch"
|
|
git checkout -B "$branch" "origin/$branch"
|
|
IFS=. read -r MA MI PA < VERSION
|
|
if [ "$branch" = development ]; then
|
|
PA=$((PA + 1))
|
|
else
|
|
git fetch origin development
|
|
zero=0000000000000000000000000000000000000000
|
|
# MINOR bump only if every non-merge commit in this push is already on development.
|
|
if [ -n "$BEFORE" ] && [ "$BEFORE" != "$zero" ] &&
|
|
[ -z "$(git rev-list --no-merges "$BEFORE..$GITHUB_SHA" --not origin/development)" ]; then
|
|
MI=$((MI + 1)); PA=0
|
|
else
|
|
PA=$((PA + 1))
|
|
fi
|
|
fi
|
|
new="$MA.$MI.$PA"
|
|
echo "$new" > VERSION
|
|
git commit -am "chore(release): v$new [skip ci]"
|
|
git push origin HEAD:"$branch"
|
|
if [ "$branch" = main ]; then
|
|
main_sha=$(git rev-parse HEAD)
|
|
git fetch origin development
|
|
git checkout -B development origin/development
|
|
# main's VERSION wins if development bumped in the meantime.
|
|
git merge --no-ff -X theirs -m "chore: merge main into development [skip ci]" "$main_sha"
|
|
git push origin development
|
|
fi
|