name: Release
on:
pull_request:
types: [closed]
branches:
- main
permissions:
contents: write
jobs:
release:
if: github.event.pull_request.merged == true && (startsWith(github.event.pull_request.title, 'feat:') || startsWith(github.event.pull_request.title, 'fix:'))
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup mise
uses: jdx/mise-action@v4
- name: Determine version bump type
id: bump
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
if [[ "$PR_TITLE" == feat:* ]]; then
echo "type=minor" >> $GITHUB_OUTPUT
elif [[ "$PR_TITLE" == fix:* ]]; then
echo "type=patch" >> $GITHUB_OUTPUT
fi
- name: Bump version
id: version
run: |
NEW_VERSION=$(bun scripts/bump-version.js ${{ steps.bump.outputs.type }})
echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"
cargo update -p auto-launcher --precise "$NEW_VERSION"
- name: Commit and push version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Cargo.toml Cargo.lock
git commit -m "chore: bump version to ${{ steps.version.outputs.new }}" || true
git pull --rebase origin main
git push origin main
- name: Create Git tag
run: |
# Delete tag if it already exists (idempotent)
git tag -d "v${{ steps.version.outputs.new }}" 2>/dev/null || true
git push origin ":refs/tags/v${{ steps.version.outputs.new }}" 2>/dev/null || true
git tag "v${{ steps.version.outputs.new }}"
git push origin "v${{ steps.version.outputs.new }}"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Delete release if it already exists (idempotent)
gh release delete "v${{ steps.version.outputs.new }}" --yes 2>/dev/null || true
gh release create "v${{ steps.version.outputs.new }}" \
--title "v${{ steps.version.outputs.new }}" \
--notes "Automated release for PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: cargo publish