mirror of
https://github.com/Dasemu/Transcriptarr.git
synced 2026-11-26 15:06:06 +00:00
90 lines
3.1 KiB
YAML
90 lines
3.1 KiB
YAML
name: Version
|
|
|
|
on:
|
|
push:
|
|
branches: [development, main]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
bump:
|
|
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Configure git identity
|
|
run: |
|
|
git config user.name "gitea-actions[bot]"
|
|
git config user.email "gitea-actions[bot]@users.noreply.zenvairo.es"
|
|
|
|
- name: Determine bump type
|
|
id: bump
|
|
run: |
|
|
if [ "${{ github.ref_name }}" = "development" ]; then
|
|
echo "type=patch" >> "$GITHUB_OUTPUT"
|
|
else
|
|
# On main: a minor bump if this push is a merge whose commits all
|
|
# came from development (an approved development -> main PR),
|
|
# otherwise a direct hotfix push gets a patch bump.
|
|
if git log -1 --pretty=%P | grep -q ' ' && \
|
|
git log -1 --pretty=%s | grep -qiE "development"; 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 push origin HEAD:${{ github.ref_name }}
|
|
|
|
- name: Merge main back into development
|
|
if: github.ref_name == 'main'
|
|
run: |
|
|
if ! git ls-remote --exit-code --heads origin development >/dev/null; then
|
|
echo "No development branch on the remote; nothing to merge back."
|
|
exit 0
|
|
fi
|
|
git fetch origin development
|
|
git checkout development
|
|
git merge --no-edit origin/main
|
|
git push origin development
|
|
|
|
- name: Create Gitea release
|
|
if: github.ref_name == 'main'
|
|
env:
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
tag="v${{ steps.version.outputs.new }}"
|
|
prev=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || true)
|
|
if [ -n "$prev" ]; then range="$prev..HEAD"; else range="HEAD"; fi
|
|
notes=$(git log "$range" --pretty='- %s' | grep -v 'chore(release)' || true)
|
|
jq -n --arg tag "$tag" --arg sha "$(git rev-parse HEAD)" --arg body "$notes" \
|
|
'{tag_name: $tag, target_commitish: $sha, name: $tag, body: $body}' > release.json
|
|
curl -fsS -X POST \
|
|
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
|
-d @release.json \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"
|