Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

on:
pull_request:
types: [closed]
branches: [main]

permissions:
contents: write

concurrency:
group: release
cancel-in-progress: false

jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # need full tag history

- name: Compute next version
id: ver
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
# Bump the patch of the HIGHEST existing GitHub Release (independent of
# the in-code version). Only the patch increments, so you can publish a
# higher major/minor by hand (e.g. v1.1.0) and the next merge continues
# from there (-> v1.1.1). First run only (no release yet): seed v1.0.0.
latest=$(gh release list --limit 1000 --json tagName --jq '.[].tagName' | sort -V | tail -n1)
if [ -z "$latest" ]; then
next="v1.0.0"
else
core=${latest#v}; core=${core%%.post*}; core=${core%%-*}
IFS='.' read -r major minor patch <<< "$core"
next="v${major}.${minor}.$((patch + 1))"
fi
echo "Latest release: ${latest:-none} Next: $next"
echo "tag=$next" >> "$GITHUB_OUTPUT"

- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.ver.outputs.tag }}" \
--target "${{ github.event.pull_request.merge_commit_sha }}" \
--title "${{ steps.ver.outputs.tag }}" \
--generate-notes
Loading