mirror of
https://github.com/Dasemu/Maskarr.git
synced 2026-11-26 15:26:10 +00:00
91 lines
2.9 KiB
YAML
91 lines
2.9 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: Create release
|
|
if: gitea.ref_name == 'main'
|
|
env:
|
|
TOKEN: ${{ gitea.token }}
|
|
TAG: v${{ steps.version.outputs.new }}
|
|
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
|
|
run: |
|
|
status=$(curl -s -o /dev/null -w '%{http_code}' -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG")
|
|
if [ "$status" = "200" ]; then
|
|
echo "Release $TAG already exists, skipping"
|
|
exit 0
|
|
fi
|
|
curl -sf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"$TAG\", \"target_commitish\": \"$(git rev-parse HEAD)\", \"name\": \"$TAG\", \"body\": \"Release $TAG\"}" \
|
|
"$API/releases"
|
|
|
|
- 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
|