release version extraction

This commit is contained in:
tooomm 2026-02-22 18:40:42 +01:00 committed by GitHub
parent 25149fac1b
commit 07669c9534
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@
# it just has to provide a template # it just has to provide a template
# this requires the repo to be unshallowed # this requires the repo to be unshallowed
# adds output to GITHUB_OUTPUT # adds output to GITHUB_OUTPUT
template_path=".ci/release_template.md" template_path=".ci/release_template.md"
body_path="/tmp/release.md" body_path="/tmp/release.md"
beta_regex='beta' beta_regex='beta'
@ -25,18 +26,18 @@ fi
if [[ $TAG =~ $beta_regex ]]; then if [[ $TAG =~ $beta_regex ]]; then
echo "is_beta=yes" >>"$GITHUB_OUTPUT" echo "is_beta=yes" >>"$GITHUB_OUTPUT"
title="$TAG" title="$TAG"
echo "creating beta release '$title'" echo "Creating beta release '$title'"
elif [[ ! $(cat CMakeLists.txt) =~ $name_regex ]]; then elif [[ ! $(cat CMakeLists.txt) =~ $name_regex ]]; then
echo "::error file=$0::could not find releasename in CMakeLists.txt" echo "::error file=$0::could not find releasename in CMakeLists.txt"
exit 1 exit 1
else else
echo "is_beta=no" >>"$GITHUB_OUTPUT" echo "is_beta=no" >>"$GITHUB_OUTPUT"
name="${BASH_REMATCH[1]}" name="${BASH_REMATCH[1]}"
version="${TAG##*-}" version="${TAG%-*}"
title="Cockatrice $version: $name" title="Cockatrice $version: $name"
no_beta=1 no_beta=1
echo "friendly_name=$name" >>"$GITHUB_OUTPUT" echo "friendly_name=$name" >>"$GITHUB_OUTPUT"
echo "creating full release '$title'" echo "Creating stable release '$title'"
fi fi
echo "title=$title" >>"$GITHUB_OUTPUT" echo "title=$title" >>"$GITHUB_OUTPUT"
@ -44,7 +45,7 @@ echo "title=$title" >>"$GITHUB_OUTPUT"
if [[ $no_beta ]]; then if [[ $no_beta ]]; then
body="$(cat "$template_path")" body="$(cat "$template_path")"
if [[ ! $body ]]; then if [[ ! $body ]]; then
echo "::warning file=$0::could not find release template" echo "::warning file=$0::Could not find release template"
fi fi
body="${body//--REPLACE-WITH-RELEASE-TITLE--/$title}" body="${body//--REPLACE-WITH-RELEASE-TITLE--/$title}"
else else
@ -64,7 +65,7 @@ before="${all_tags%%
"$TAG"*}" # strip line with current tag an all lines after it "$TAG"*}" # strip line with current tag an all lines after it
# note the extra newlines are needed to always have a last line # note the extra newlines are needed to always have a last line
if [[ $all_tags == "$before" ]]; then if [[ $all_tags == "$before" ]]; then
echo "::warning file=$0::could not find current tag" echo "::warning file=$0::Could not find current tag"
else else
while while
previous="${before##* previous="${before##*
@ -84,8 +85,9 @@ else
if [[ $previous ]]; then if [[ $previous ]]; then
if generated_list="$(git log "$previous..$TAG" --pretty="- %s")"; then if generated_list="$(git log "$previous..$TAG" --pretty="- %s")"; then
count="$(git rev-list --count "$previous..$TAG")" count="$(git rev-list --count "$previous..$TAG")"
[[ $previous =~ $beta_regex ]] && previousreleasetype="beta release" || previousreleasetype="full release" [[ $previous =~ $beta_regex ]] && previousreleasetype="beta release" || previousreleasetype="stable release"
echo "adding list of commits to release notes:" echo ""
echo "Adding list of commits to release notes:"
echo "'$previous' to '$TAG' ($count commits)" echo "'$previous' to '$TAG' ($count commits)"
# --> is the markdown comment escape sequence, emojis are way better # --> is the markdown comment escape sequence, emojis are way better
generated_list="${generated_list//-->/→}" generated_list="${generated_list//-->/→}"
@ -96,15 +98,16 @@ else
if [[ $beta_list =~ $whitespace ]]; then if [[ $beta_list =~ $whitespace ]]; then
beta_list="-n there are no betas to delete!" beta_list="-n there are no betas to delete!"
else else
echo "the following betas should be deleted after publishing:" echo ""
echo "::notice::The following betas should be deleted after publishing:"
echo "$beta_list" echo "$beta_list"
fi fi
body="${body//--REPLACE-WITH-BETA-LIST--/$beta_list}" body="${body//--REPLACE-WITH-BETA-LIST--/$beta_list}"
else else
echo "::warning file=$0::failed to produce git log" echo "::warning file=$0::Failed to produce git log"
fi fi
else else
echo "::warning file=$0::could not find previous tag" echo "::warning file=$0::Could not find previous tag"
fi fi
fi fi