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
33 changes: 21 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Easiest: Actions > Release > Run workflow on main. It raises the version in CMakeLists.txt by the chosen
# step (default: the last number, 0.2.5.5 -> 0.2.5.6), commits that to main, tags it, then builds and drafts
# the release below. Pushing a version tag by hand still works. A version tag (v1.2.3, or v1.2.3-rc1 for a pre-release) builds every download from source, runs the
# Easiest: Actions > Release > Run workflow on main. It reads the commits since the last version tag, raises the
# version in CMakeLists.txt by what they say (see "Next version" below; normally just the last number,
# 0.2.5.5 -> 0.2.5.6), commits that to main, tags it, then builds and drafts the release below. Pushing a version tag by hand still works. A version tag (v1.2.3, or v1.2.3-rc1 for a pre-release) builds every download from source, runs the
# tests on those builds, and attaches them to a draft GitHub Release; the release text is reviewed before it is published.
# Only DeliciousMeatPop/Venture-UnknownSourceEdition builds releases.
name: Release
Expand All @@ -11,11 +11,6 @@ on:
# Run on a tag ("Use workflow from" > Tags) to rebuild that release's downloads.
workflow_dispatch:
inputs:
bump:
description: "Version step when run on main (ignored on a tag). build: 0.2.5.5 to 0.2.5.6, patch: 0.2.6.0, minor: 0.3.0.0, major: 1.0.0.0"
type: choice
options: [build, patch, minor, major]
default: build
skip_upstream_check:
description: "Skip the check for newer upstream Venture changes"
type: boolean
Expand Down Expand Up @@ -112,13 +107,27 @@ jobs:
fetch-depth: 0
- name: Next version
id: next
env:
BUMP: ${{ inputs.bump }}
run: |
cur=$(sed -n 's/^project(Venture VERSION \([0-9.]*\).*/\1/p' CMakeLists.txt | head -1)
last=$(git describe --tags --match 'v[0-9]*' --abbrev=0 2>/dev/null || true)
if [ -n "$last" ]; then
[ "$(git rev-list --count "$last"..HEAD)" -gt 0 ] || { echo "No commits since $last; nothing to release"; exit 1; }
msgs=$(git log "$last"..HEAD --format=%B)
else
msgs=$(git log --format=%B)
fi
# Rules, read from every commit message since the last tag (a merge commit carries its PR title):
# major: "BREAKING CHANGE", a "type!:" prefix, or [major] 1.0.0.0
# minor: a "feat:" / "feat(area):" prefix, or [minor] 0.3.0.0
# patch: [patch] 0.2.6.0
# otherwise: the last number goes up 0.2.5.6
if grep -qiE 'BREAKING CHANGE|^[a-z]+(\([^)]*\))?!:|\[major\]' <<< "$msgs"; then level=major
elif grep -qiE '^feat(\([^)]*\))?:|\[minor\]' <<< "$msgs"; then level=minor
elif grep -qiE '\[patch\]' <<< "$msgs"; then level=patch
else level=build; fi
IFS=. read -r a b c d <<< "$cur"
a=${a:-0}; b=${b:-0}; c=${c:-0}; d=${d:-0}
case "$BUMP" in
case "$level" in
major) a=$((a+1)); b=0; c=0; d=0 ;;
minor) b=$((b+1)); c=0; d=0 ;;
patch) c=$((c+1)); d=0 ;;
Expand All @@ -131,7 +140,7 @@ jobs:
sed -i "s/^project(Venture VERSION [0-9.]*/project(Venture VERSION $next/" CMakeLists.txt
grep -q "VERSION $next " CMakeLists.txt || { echo "Version edit failed"; exit 1; }
echo "tag=v$next" >> "$GITHUB_OUTPUT"
echo "Version $cur -> $next ($BUMP)" | tee -a "$GITHUB_STEP_SUMMARY"
echo "Version $cur -> $next ($level, commits since ${last:-the start})" | tee -a "$GITHUB_STEP_SUMMARY"
- name: Commit and tag
env:
TAG: ${{ steps.next.outputs.tag }}
Expand Down
Loading