141dc90db7
Release / release (push) Successful in 5s
- New .gitea/workflows/release.yml triggers on push to main - Scans commits since last v* tag and bumps strict semver - feat: -> minor, fix: -> patch, !: or BREAKING CHANGE -> major - Updates package.json + package-lock.json, commits as <version>, tags v<version>, pushes both - Tag push triggers existing deploy.yml (PACKAGES_TOKEN is a PAT so cross-workflow triggers work) - Skips silently when no releaseable commits are found - Updates CLAUDE.md release section to reflect automation
92 lines
3.0 KiB
YAML
92 lines
3.0 KiB
YAML
name: Release
|
|
|
|
# Auto-tagging baserat på conventional commits sedan senaste taggen.
|
|
# feat: → minor bump (1.2.9 → 1.3.0)
|
|
# fix: → patch bump (1.2.9 → 1.2.10)
|
|
# "!:" eller "BREAKING CHANGE" → major bump (1.2.9 → 2.0.0)
|
|
# Andra prefix (chore:, docs:, ci:, refactor:, style:, test:) bumpar inte.
|
|
# Skippas tyst när inga releaseable commits hittas — t.ex. när workflow:n själv pushar version-commiten.
|
|
# Push av tag triggar deploy.yml (PACKAGES_TOKEN är en PAT så cross-workflow-triggers funkar).
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
token: ${{ secrets.PACKAGES_TOKEN }}
|
|
|
|
- name: Configure git
|
|
run: |
|
|
git config user.name "Release Bot"
|
|
git config user.email "noreply@shcizo.se"
|
|
|
|
- name: Determine version bump
|
|
id: bump
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
LAST_TAG=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || echo "")
|
|
if [ -z "$LAST_TAG" ]; then
|
|
RANGE=""
|
|
echo "No previous v* tag found — scanning all commits."
|
|
else
|
|
RANGE="${LAST_TAG}..HEAD"
|
|
echo "Scanning commits since ${LAST_TAG}."
|
|
fi
|
|
|
|
BUMP="none"
|
|
while IFS= read -r subject; do
|
|
[ -z "$subject" ] && continue
|
|
if echo "$subject" | grep -qE "^[a-z]+(\([^)]+\))?!:|BREAKING[ -]CHANGE"; then
|
|
BUMP="major"
|
|
break
|
|
elif echo "$subject" | grep -qE "^feat(\([^)]+\))?:"; then
|
|
[ "$BUMP" != "major" ] && BUMP="minor"
|
|
elif echo "$subject" | grep -qE "^fix(\([^)]+\))?:"; then
|
|
[ "$BUMP" = "none" ] && BUMP="patch"
|
|
fi
|
|
done < <(git log ${RANGE} --no-merges --pretty=format:%s)
|
|
|
|
echo "Determined bump: ${BUMP}"
|
|
echo "bump=${BUMP}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Compute new version
|
|
if: steps.bump.outputs.bump != 'none'
|
|
id: version
|
|
run: |
|
|
set -euo pipefail
|
|
CURRENT=$(node -p "require('./package.json').version")
|
|
IFS=. read -r MAJ MIN PAT <<< "$CURRENT"
|
|
case "${{ steps.bump.outputs.bump }}" in
|
|
major) NEW="$((MAJ+1)).0.0" ;;
|
|
minor) NEW="${MAJ}.$((MIN+1)).0" ;;
|
|
patch) NEW="${MAJ}.${MIN}.$((PAT+1))" ;;
|
|
esac
|
|
echo "Bumping ${CURRENT} → ${NEW}"
|
|
echo "new=${NEW}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Update files, commit, tag, push
|
|
if: steps.bump.outputs.bump != 'none'
|
|
run: |
|
|
set -euo pipefail
|
|
NEW="${{ steps.version.outputs.new }}"
|
|
|
|
npm version "$NEW" --no-git-tag-version
|
|
|
|
git add package.json package-lock.json
|
|
git commit -m "$NEW"
|
|
git tag "v${NEW}"
|
|
git push origin main "v${NEW}"
|
|
|
|
- name: No-op summary
|
|
if: steps.bump.outputs.bump == 'none'
|
|
run: echo "No feat/fix/breaking commits since last tag — no release."
|