ci: auto-bump version on merge to main (v0.1.0-alpha)
This commit is contained in:
parent
d437595f4f
commit
9ec0f4749d
1 changed files with 73 additions and 0 deletions
73
.github/workflows/release.yml
vendored
Normal file
73
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '.github/workflows/**'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: release
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Bump version and push tag
|
||||
id: bump
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git fetch --tags --force
|
||||
|
||||
if git describe --tags --exact-match HEAD >/dev/null 2>&1; then
|
||||
echo "HEAD is already tagged, skipping bump"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
latest=$(git tag --sort=-v:refname --list 'v*.*.*-alpha' | head -n 1)
|
||||
if [ -z "$latest" ]; then
|
||||
echo "::error::No tag matching vX.Y.Z-alpha pattern found"
|
||||
exit 1
|
||||
fi
|
||||
echo "Latest tag: $latest"
|
||||
|
||||
version="${latest#v}"
|
||||
version="${version%-alpha}"
|
||||
IFS='.' read -r major minor patch <<< "$version"
|
||||
new_version="${major}.${minor}.$((patch + 1))-alpha"
|
||||
new_tag="v${new_version}"
|
||||
|
||||
if git rev-parse "$new_tag" >/dev/null 2>&1; then
|
||||
echo "::error::Tag $new_tag already exists"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git tag -a "$new_tag" -m "Release $new_tag"
|
||||
git push origin "$new_tag"
|
||||
|
||||
echo "tag=$new_tag" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Create GitHub release
|
||||
if: steps.bump.outputs.tag
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.bump.outputs.tag }}
|
||||
name: ${{ steps.bump.outputs.tag }}
|
||||
prerelease: true
|
||||
generate_release_notes: true
|
||||
Loading…
Reference in a new issue