|
| 1 | +name: Auto Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + branches: [main] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + auto-release: |
| 13 | + name: Determine Version and Tag |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: github.event.pull_request.merged == true |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Setup Bun |
| 23 | + uses: oven-sh/setup-bun@v2 |
| 24 | + with: |
| 25 | + bun-version: latest |
| 26 | + |
| 27 | + - name: Install Just |
| 28 | + uses: extractions/setup-just@v2 |
| 29 | + |
| 30 | + - name: Determine next version |
| 31 | + id: version |
| 32 | + run: | |
| 33 | + latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") |
| 34 | + echo "latest=$latest_tag" >> "$GITHUB_OUTPUT" |
| 35 | +
|
| 36 | + # Parse current version |
| 37 | + version="${latest_tag#v}" |
| 38 | + IFS='.' read -r major minor patch <<< "$version" |
| 39 | +
|
| 40 | + # Check commit messages since last tag for bump type |
| 41 | + commits=$(git log "$latest_tag"..HEAD --pretty=format:"%s" 2>/dev/null || git log --pretty=format:"%s") |
| 42 | +
|
| 43 | + if echo "$commits" | grep -qE "^feat(\(.+\))?!:|^fix(\(.+\))?!:|^refactor(\(.+\))?!:|BREAKING CHANGE"; then |
| 44 | + major=$((major + 1)) |
| 45 | + minor=0 |
| 46 | + patch=0 |
| 47 | + elif echo "$commits" | grep -qE "^feat(\(.+\))?:"; then |
| 48 | + minor=$((minor + 1)) |
| 49 | + patch=0 |
| 50 | + else |
| 51 | + patch=$((patch + 1)) |
| 52 | + fi |
| 53 | +
|
| 54 | + next="v${major}.${minor}.${patch}" |
| 55 | + echo "next=$next" >> "$GITHUB_OUTPUT" |
| 56 | + echo "version=${major}.${minor}.${patch}" >> "$GITHUB_OUTPUT" |
| 57 | + echo "Next version: $next" |
| 58 | +
|
| 59 | + - name: Update versions |
| 60 | + run: | |
| 61 | + bun install --frozen-lockfile |
| 62 | + just set-version ${{ steps.version.outputs.version }} |
| 63 | +
|
| 64 | + - name: Verify |
| 65 | + run: | |
| 66 | + just typecheck |
| 67 | + just test |
| 68 | +
|
| 69 | + - name: Commit and tag |
| 70 | + env: |
| 71 | + TAG: ${{ steps.version.outputs.next }} |
| 72 | + VERSION: ${{ steps.version.outputs.version }} |
| 73 | + run: | |
| 74 | + git config user.name "github-actions[bot]" |
| 75 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 76 | + git add package.json src/cli/index.ts skills/*/SKILL.md |
| 77 | + git commit -m "chore(release): bump version to v$VERSION" |
| 78 | + git tag -a "$TAG" -m "Release $TAG" |
| 79 | + git push origin main --follow-tags |
0 commit comments