ci: auto-create app release on approved PR merge to main
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push' && startsWith(github.event.head_commit.message, 'Merge pull request')
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Compute next version
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
latest=$(git tag --list 'v[0-9]*' --sort=-v:refname | head -n 1)
|
||||||
|
if [ -z "$latest" ]; then
|
||||||
|
next="v1.0.0"
|
||||||
|
else
|
||||||
|
latest=${latest#v}
|
||||||
|
IFS='.' read -r major minor patch <<< "$latest"
|
||||||
|
next="v${major}.${minor}.$((patch + 1))"
|
||||||
|
fi
|
||||||
|
echo "next=${next}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Build changelog
|
||||||
|
id: changelog
|
||||||
|
run: |
|
||||||
|
prev_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
||||||
|
if [ -z "$prev_tag" ]; then
|
||||||
|
log=$(git log --oneline --no-merges main | head -n 40)
|
||||||
|
else
|
||||||
|
log=$(git log --oneline --no-merges "$prev_tag"..main | head -n 40)
|
||||||
|
fi
|
||||||
|
{
|
||||||
|
echo "body<<EOF"
|
||||||
|
echo "## What's new in this release"
|
||||||
|
echo ""
|
||||||
|
echo "$log" | sed 's/^/- /'
|
||||||
|
echo "EOF"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.version.outputs.next }}
|
||||||
|
name: ${{ steps.version.outputs.next }}
|
||||||
|
body: ${{ steps.changelog.outputs.body }}
|
||||||
|
generate_release_notes: false
|
||||||
Reference in New Issue
Block a user