mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-12 04:50:01 -08:00
[CI] Polish release naming and workflow env conventions
Rebased remainder of #7014 onto master, where the file has been rewritten since the branch was opened. Keeps master's newer build definitions and re-applies only the conventions that still apply: - prep_release.sh emits a single beta=true/false output instead of is_beta - the release step consumes it in UPPER_CASE env vars, passes --latest for stable releases, and fills an existing empty draft with the same flags - docker.sh and the workflow agree on BUILD_REFERENCE and CACHE_DIR, so the Linux ccache and image cache are no longer written to a throwaway dir The Windows asset suffix stays -Win10 (old clients match on that token) and release_channel.cpp is dropped: master already matches Win|Windows.
This commit is contained in:
parent
1ca67ebb0f
commit
b2596fd562
3 changed files with 63 additions and 61 deletions
|
|
@ -7,18 +7,18 @@
|
|||
# usage: source <script> <name> [--get] [--build] [--save] [--interactive] [--set-cache <location>]
|
||||
# <name> sets the name of the docker image, these correspond to directories in .ci
|
||||
# --get loads the image from a previously saved image cache, will build if no image is found
|
||||
# --build builds the image from the Dockerfile in .ci/$NAME
|
||||
# --build builds the image from the Dockerfile in .ci/$BUILD_REFERENCE
|
||||
# --save stores the image, if an image was loaded it will not be stored
|
||||
# --interactive immediately starts the image interactively for debugging
|
||||
# --set-cache <location> sets the location to cache the image or for ccache
|
||||
#
|
||||
# requires: docker
|
||||
# uses env: NAME IMAGE_SUFFIX CACHE BUILD GET SAVE INTERACTIVE
|
||||
# uses env: BUILD_REFERENCE IMAGE_SUFFIX CACHE_DIR BUILD GET SAVE INTERACTIVE
|
||||
# (correspond to args: <name> --set-cache <cache> --build --get --save --interactive)
|
||||
# sets env: RUN CCACHE_DIR IMAGE_NAME RUN_ARGS RUN_OPTS BUILD_SCRIPT
|
||||
# exitcode: 1 for failure, 2 for missing dockerfile, 3 for invalid arguments
|
||||
#
|
||||
# IMAGE_SUFFIX is optional and only appended to the image name, never to NAME, so that a matrix
|
||||
# IMAGE_SUFFIX is optional and only appended to the image name, never to BUILD_REFERENCE, so that a matrix
|
||||
# leg can have its own image and image cache without needing its own directory under .ci. Two legs
|
||||
# building and tagging the same image concurrently would race on `docker build --tag`.
|
||||
# It is deliberately not called SUFFIX: compile.sh already uses SUFFIX for output file names, and
|
||||
|
|
@ -63,10 +63,10 @@ while [[ $# != 0 ]]; do
|
|||
echo "--set-cache expects an argument" >&2
|
||||
exit 3
|
||||
fi
|
||||
CACHE=$1
|
||||
CACHE_DIR=$1
|
||||
shift
|
||||
if ! [[ -d $CACHE ]]; then
|
||||
echo "could not find cache path: $CACHE" >&2
|
||||
if ! [[ -d $CACHE_DIR ]]; then
|
||||
echo "could not find cache path: $CACHE_DIR" >&2
|
||||
return 3
|
||||
fi
|
||||
;;
|
||||
|
|
@ -75,45 +75,45 @@ while [[ $# != 0 ]]; do
|
|||
echo "unrecognized option: $1"
|
||||
return 3
|
||||
fi
|
||||
NAME="$1"
|
||||
BUILD_REFERENCE="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Setup
|
||||
if ! [[ $NAME ]]; then
|
||||
if ! [[ $BUILD_REFERENCE ]]; then
|
||||
echo "no build name given" >&2
|
||||
return 3
|
||||
fi
|
||||
|
||||
export IMAGE_NAME="${project_name,,}_${NAME,,}${IMAGE_SUFFIX:+_${IMAGE_SUFFIX,,}}" # lower case
|
||||
export IMAGE_NAME="${project_name,,}_${BUILD_REFERENCE,,}${IMAGE_SUFFIX:+_${IMAGE_SUFFIX,,}}" # lower case
|
||||
|
||||
docker_dir=".ci/$NAME"
|
||||
docker_dir=".ci/$BUILD_REFERENCE"
|
||||
if ! [[ -r $docker_dir/Dockerfile ]]; then
|
||||
echo "could not find Dockerfile in $docker_dir" >&2
|
||||
return 2 # even if the image is cached, we do not want to run if there is no way to build this image
|
||||
fi
|
||||
|
||||
if ! [[ $CACHE ]]; then
|
||||
if ! [[ $CACHE_DIR ]]; then
|
||||
echo "cache dir is not set!" >&2
|
||||
CACHE="$(mktemp -d)"
|
||||
echo "set cache dir to $CACHE" >&2
|
||||
CACHE_DIR="$(mktemp -d)"
|
||||
echo "set cache dir to $CACHE_DIR" >&2
|
||||
fi
|
||||
if ! [[ -d $CACHE ]]; then
|
||||
echo "could not find cache dir: $CACHE" >&2
|
||||
mkdir -p "$CACHE"
|
||||
if ! [[ -d $CACHE_DIR ]]; then
|
||||
echo "could not find cache dir: $CACHE_DIR" >&2
|
||||
mkdir -p "$CACHE_DIR"
|
||||
unset GET # the dir is empty
|
||||
fi
|
||||
if [[ $GET || $SAVE ]]; then
|
||||
img_dir="$CACHE/$image_cache"
|
||||
img_dir="$CACHE_DIR/$image_cache"
|
||||
img_save="$img_dir/$IMAGE_NAME$save_extension"
|
||||
if ! [[ -d $img_dir ]]; then
|
||||
echo "could not find image dir: $img_dir" >&2
|
||||
mkdir -p "$img_dir"
|
||||
fi
|
||||
fi
|
||||
export CCACHE_DIR="$CACHE/$ccache_cache"
|
||||
export CCACHE_DIR="$CACHE_DIR/$ccache_cache"
|
||||
if ! [[ -d $CCACHE_DIR ]]; then
|
||||
echo "could not find ccache dir: $CCACHE_DIR" >&2
|
||||
mkdir -p "$CCACHE_DIR"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
# adds output to GITHUB_OUTPUT
|
||||
template_path=".ci/release_template.md"
|
||||
body_path="/tmp/release.md"
|
||||
beta_regex='beta'
|
||||
beta_regex='-beta'
|
||||
name_regex='set\(GIT_TAG_RELEASENAME "([[:print:]]+)")'
|
||||
whitespace='^\s*$'
|
||||
|
||||
|
|
@ -23,28 +23,29 @@ fi
|
|||
|
||||
# create title
|
||||
if [[ $TAG =~ $beta_regex ]]; then
|
||||
echo "is_beta=yes" >>"$GITHUB_OUTPUT"
|
||||
beta=true
|
||||
echo "beta=$beta" >>"$GITHUB_OUTPUT"
|
||||
title="$TAG"
|
||||
echo "creating beta release '$title'"
|
||||
echo "Creating beta release '$title'"
|
||||
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
|
||||
else
|
||||
echo "is_beta=no" >>"$GITHUB_OUTPUT"
|
||||
beta=false
|
||||
echo "beta=$beta" >>"$GITHUB_OUTPUT"
|
||||
name="${BASH_REMATCH[1]}"
|
||||
version="${TAG##*-}"
|
||||
title="Cockatrice $version: $name"
|
||||
no_beta=1
|
||||
echo "friendly_name=$name" >>"$GITHUB_OUTPUT"
|
||||
echo "creating full release '$title'"
|
||||
echo "Creating full release '$title'"
|
||||
fi
|
||||
echo "title=$title" >>"$GITHUB_OUTPUT"
|
||||
|
||||
# add release notes template
|
||||
if [[ $no_beta ]]; then
|
||||
if [[ $beta == "false" ]]; then
|
||||
body="$(cat "$template_path")"
|
||||
if [[ ! $body ]]; then
|
||||
echo "::warning file=$0::could not find release template"
|
||||
echo "::warning file=$0::Could not find release template"
|
||||
fi
|
||||
body="${body//--REPLACE-WITH-RELEASE-TITLE--/$title}"
|
||||
else
|
||||
|
|
@ -64,13 +65,13 @@ before="${all_tags%%
|
|||
"$TAG"*}" # strip line with current tag an all lines after it
|
||||
# note the extra newlines are needed to always have a last line
|
||||
if [[ $all_tags == "$before" ]]; then
|
||||
echo "::warning file=$0::could not find current tag"
|
||||
echo "::warning file=$0::Could not find current tag"
|
||||
else
|
||||
while
|
||||
previous="${before##*
|
||||
}" # get the last line
|
||||
# skip this tag if this is a full release and it's a beta or if empty
|
||||
[[ $no_beta && $previous =~ $beta_regex || ! $previous ]]
|
||||
[[ $beta == "false" && $previous =~ $beta_regex || ! $previous ]]
|
||||
do
|
||||
beta_list+=" $previous" # add to list of skipped betas
|
||||
next_before="${before%
|
||||
|
|
@ -85,7 +86,7 @@ else
|
|||
if generated_list="$(git log "$previous..$TAG" --pretty="- %s")"; then
|
||||
count="$(git rev-list --count "$previous..$TAG")"
|
||||
[[ $previous =~ $beta_regex ]] && previousreleasetype="beta release" || previousreleasetype="full release"
|
||||
echo "adding list of commits to release notes:"
|
||||
echo "Adding list of commits to release notes:"
|
||||
echo "'$previous' to '$TAG' ($count commits)"
|
||||
# --> is the markdown comment escape sequence, emojis are way better
|
||||
generated_list="${generated_list//-->/→}"
|
||||
|
|
@ -98,15 +99,15 @@ else
|
|||
if [[ $beta_list =~ $whitespace ]]; then
|
||||
beta_list="-n there are no betas to delete!"
|
||||
else
|
||||
echo "the following betas should be deleted after publishing:"
|
||||
echo "The following betas should be deleted after publishing:"
|
||||
echo "$beta_list"
|
||||
fi
|
||||
body="${body//--REPLACE-WITH-BETA-LIST--/$beta_list}"
|
||||
else
|
||||
echo "::warning file=$0::failed to produce git log"
|
||||
echo "::warning file=$0::Failed to produce git log"
|
||||
fi
|
||||
else
|
||||
echo "::warning file=$0::could not find previous tag"
|
||||
echo "::warning file=$0::Could not find previous tag"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue