mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-11-08 21:14:47 +09:00
- Add VERSION file (starting at 1.0.0) - Add GitHub Actions workflow to auto-bump version on push - patch: default for all commits - minor: commits starting with "feat:" or "feature:" - major: commits starting with "BREAKING:" or "major:" - Add CLI commands: version, check-update - Update 'serverkit update' to show semantic versions - Compare local vs remote version before updating Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
111 lines
3.5 KiB
YAML
111 lines
3.5 KiB
YAML
name: Version Bump
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- 'VERSION'
|
|
- '.github/workflows/version-bump.yml'
|
|
|
|
jobs:
|
|
bump-version:
|
|
runs-on: ubuntu-latest
|
|
# Skip if commit message contains [skip ci] or [skip version]
|
|
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip version]') && !startsWith(github.event.head_commit.message, 'chore: bump version')"
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Get current version
|
|
id: current
|
|
run: |
|
|
if [ -f VERSION ]; then
|
|
VERSION=$(cat VERSION | tr -d '\n\r ')
|
|
else
|
|
VERSION="0.0.0"
|
|
fi
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Current version: $VERSION"
|
|
|
|
- name: Determine bump type
|
|
id: bump
|
|
run: |
|
|
COMMIT_MSG="${{ github.event.head_commit.message }}"
|
|
|
|
# Check for major version bump keywords
|
|
if echo "$COMMIT_MSG" | grep -qiE "^(BREAKING|breaking!|major):"; then
|
|
echo "type=major" >> $GITHUB_OUTPUT
|
|
echo "Bump type: major"
|
|
# Check for minor version bump keywords
|
|
elif echo "$COMMIT_MSG" | grep -qiE "^(feat|feature|minor):"; then
|
|
echo "type=minor" >> $GITHUB_OUTPUT
|
|
echo "Bump type: minor"
|
|
# Default to patch
|
|
else
|
|
echo "type=patch" >> $GITHUB_OUTPUT
|
|
echo "Bump type: patch"
|
|
fi
|
|
|
|
- name: Calculate new version
|
|
id: new
|
|
run: |
|
|
VERSION="${{ steps.current.outputs.version }}"
|
|
BUMP_TYPE="${{ steps.bump.outputs.type }}"
|
|
|
|
# Parse version components
|
|
MAJOR=$(echo $VERSION | cut -d. -f1)
|
|
MINOR=$(echo $VERSION | cut -d. -f2)
|
|
PATCH=$(echo $VERSION | cut -d. -f3)
|
|
|
|
# Bump appropriate component
|
|
case $BUMP_TYPE in
|
|
major)
|
|
MAJOR=$((MAJOR + 1))
|
|
MINOR=0
|
|
PATCH=0
|
|
;;
|
|
minor)
|
|
MINOR=$((MINOR + 1))
|
|
PATCH=0
|
|
;;
|
|
patch)
|
|
PATCH=$((PATCH + 1))
|
|
;;
|
|
esac
|
|
|
|
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
|
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
|
echo "New version: $NEW_VERSION"
|
|
|
|
- name: Update VERSION file
|
|
run: |
|
|
echo "${{ steps.new.outputs.version }}" > VERSION
|
|
cat VERSION
|
|
|
|
- name: Commit and push
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add VERSION
|
|
git commit -m "chore: bump version to ${{ steps.new.outputs.version }} [skip ci]"
|
|
git push
|
|
|
|
- name: Create summary
|
|
run: |
|
|
echo "## Version Bump Summary" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
|
|
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Previous Version | ${{ steps.current.outputs.version }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| New Version | ${{ steps.new.outputs.version }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Bump Type | ${{ steps.bump.outputs.type }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Trigger Commit | ${{ github.event.head_commit.message }} |" >> $GITHUB_STEP_SUMMARY
|