rony-llm-agent/.forgejo/workflows/bump-version.yml

78 lines
2.4 KiB
YAML
Raw Normal View History

2026-08-03 01:25:14 +00:00
name: bump-version
on:
push:
branches: [main]
workflow_dispatch:
env:
FORGEJO_HOST: src.sersofts.org
FORGEJO_PROTOCOL: https
2026-08-03 01:25:14 +00:00
concurrency:
group: bump-version
cancel-in-progress: false
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Checkout
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: |
set -euo pipefail
git clone "${FORGEJO_PROTOCOL}://x-access-token:${FORGEJO_TOKEN}@${FORGEJO_HOST}/${GITHUB_REPOSITORY}.git" .
git checkout "$GITHUB_SHA"
git config user.name "forgejo-actions[bot]"
git config user.email "forgejo-actions[bot]@noreply.local"
2026-08-03 01:25:14 +00:00
- name: Skip if latest commit is already a release commit
run: |
SUBJECT=$(git log -1 --pretty=%s)
if [[ "$SUBJECT" == "chore(release):"* ]]; then
2026-08-03 01:25:14 +00:00
echo "Latest commit is a release commit ('$SUBJECT'). Skipping bump to avoid loop."
exit 0
fi
echo "Latest commit subject: $SUBJECT — proceeding with bump."
- name: Read current version
id: current
run: |
if [[ ! -f VERSION ]]; then
echo "VERSION file missing"
exit 1
fi
VERSION=$(tr -d '[:space:]' < VERSION)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Compute next patch version
id: next
run: |
CURRENT="${{ steps.current.outputs.version }}"
STRIP_LEADING_V='s/^v//'
CORE=$(echo "$CURRENT" | sed -E "$STRIP_LEADING_V")
BASE="${CORE%%-*}"
SUFFIX=""
if [[ "$CORE" == *-* ]]; then
SUFFIX="-${CORE#*-}"
fi
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE"
if [[ -z "$MAJOR" || -z "$MINOR" || -z "$PATCH" ]]; then
echo "Cannot parse version: $CURRENT"
exit 1
fi
NEXT="v${MAJOR}.${MINOR}.$((PATCH + 1))${SUFFIX}"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
echo "Bumping $CURRENT → $NEXT"
- name: Update VERSION and push bump commit
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
2026-08-03 01:25:14 +00:00
run: |
NEXT="${{ steps.next.outputs.next }}"
printf '%s\n' "$NEXT" > VERSION
git add VERSION
git commit -m "chore(release): bump version to $NEXT"
git push "${FORGEJO_PROTOCOL}://x-access-token:${FORGEJO_TOKEN}@${FORGEJO_HOST}/${GITHUB_REPOSITORY}.git" HEAD:main