mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 17:14:52 -07:00
merge build workflows (#4197)
* merge build workflows * fix mac version comparisons
This commit is contained in:
parent
1ddc9cc929
commit
b63145c0a1
9 changed files with 549 additions and 649 deletions
|
|
@ -5,6 +5,9 @@
|
|||
# Read arguments
|
||||
while [[ "$@" ]]; do
|
||||
case "$1" in
|
||||
'--')
|
||||
shift
|
||||
;;
|
||||
'--format')
|
||||
CHECK_FORMAT=1
|
||||
shift
|
||||
|
|
@ -17,14 +20,19 @@ while [[ "$@" ]]; do
|
|||
MAKE_PACKAGE=1
|
||||
shift
|
||||
if [[ $# != 0 && $1 != -* ]]; then
|
||||
PACKAGE_NAME="$1"
|
||||
PACKAGE_TYPE="$1"
|
||||
shift
|
||||
if [[ $# != 0 && $1 != -* ]]; then
|
||||
PACKAGE_TYPE="$1"
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
'--suffix')
|
||||
shift
|
||||
if [[ $# == 0 ]]; then
|
||||
echo "::error file=$0::--suffix expects an argument"
|
||||
exit 1
|
||||
fi
|
||||
PACKAGE_SUFFIX="$1"
|
||||
shift
|
||||
;;
|
||||
'--server')
|
||||
MAKE_SERVER=1
|
||||
shift
|
||||
|
|
@ -41,13 +49,9 @@ while [[ "$@" ]]; do
|
|||
BUILDTYPE="Release"
|
||||
shift
|
||||
;;
|
||||
'--zip')
|
||||
MAKE_ZIP=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [[ $1 == -* ]]; then
|
||||
echo "unrecognized option: $1"
|
||||
echo "::error file=$0::unrecognized option: $1"
|
||||
exit 3
|
||||
fi
|
||||
BUILDTYPE="$1"
|
||||
|
|
@ -58,7 +62,9 @@ done
|
|||
|
||||
# Check formatting using clang-format
|
||||
if [[ $CHECK_FORMAT ]]; then
|
||||
echo "::group::Run linter"
|
||||
source ./.ci/lint.sh
|
||||
echo "::endgroup::"
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
|
@ -68,8 +74,8 @@ set -e
|
|||
mkdir -p build
|
||||
cd build
|
||||
|
||||
if ! [[ $CORE_AMOUNT ]]; then
|
||||
CORE_AMOUNT="2" # default machines have 2 cores
|
||||
if [[ ! $CMAKE_BUILD_PARALLEL_LEVEL ]]; then
|
||||
CMAKE_BUILD_PARALLEL_LEVEL=2 # default machines have 2 cores
|
||||
fi
|
||||
|
||||
# Add cmake flags
|
||||
|
|
@ -78,7 +84,6 @@ if [[ $MAKE_SERVER ]]; then
|
|||
fi
|
||||
if [[ $MAKE_TEST ]]; then
|
||||
flags+=" -DTEST=1"
|
||||
BUILDTYPE="Debug" # test requires buildtype Debug
|
||||
fi
|
||||
if [[ $BUILDTYPE ]]; then
|
||||
flags+=" -DCMAKE_BUILD_TYPE=$BUILDTYPE"
|
||||
|
|
@ -87,42 +92,51 @@ if [[ $PACKAGE_TYPE ]]; then
|
|||
flags+=" -DCPACK_GENERATOR=$PACKAGE_TYPE"
|
||||
fi
|
||||
|
||||
# Add qt install location when using brew
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
PATH="/usr/local/opt/ccache/bin:$PATH"
|
||||
# prepend ccache compiler binaries to path
|
||||
PATH="/usr/local/opt/ccache/libexec:$PATH"
|
||||
# Add qt install location when using homebrew
|
||||
flags+=" -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5/"
|
||||
fi
|
||||
|
||||
# Compile
|
||||
echo "::group::Show ccache stats"
|
||||
ccache --show-stats
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Configure cmake"
|
||||
cmake --version
|
||||
cmake .. $flags
|
||||
make -j"$CORE_AMOUNT"
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build project"
|
||||
cmake --build .
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Show ccache stats again"
|
||||
ccache --show-stats
|
||||
echo "::endgroup::"
|
||||
|
||||
if [[ $MAKE_TEST ]]; then
|
||||
make test
|
||||
echo "::group::Run tests"
|
||||
cmake --build . --target test
|
||||
echo "::endgroup::"
|
||||
fi
|
||||
|
||||
if [[ $MAKE_INSTALL ]]; then
|
||||
make install
|
||||
echo "::group::Install"
|
||||
cmake --build . --target install
|
||||
echo "::endgroup::"
|
||||
fi
|
||||
|
||||
if [[ $MAKE_PACKAGE ]]; then
|
||||
make package
|
||||
if [[ $PACKAGE_NAME ]]; then
|
||||
found="$(find . -maxdepth 1 -type f -name "Cockatrice-*.*" -print -quit)"
|
||||
path="${found%/*}"
|
||||
file="${found##*/}"
|
||||
if [[ ! $file ]]; then
|
||||
echo "could not find package" >&2
|
||||
exit 1
|
||||
fi
|
||||
new_name="$path/${file%.*}-$PACKAGE_NAME."
|
||||
if [[ $MAKE_ZIP ]]; then
|
||||
zip "${new_name}zip" "$path/$file"
|
||||
mv "$path/$file" "$path/_$file"
|
||||
else
|
||||
extension="${file##*.}"
|
||||
mv "$path/$file" "$new_name$extension"
|
||||
fi
|
||||
echo "::group::Create package"
|
||||
cmake --build . --target package
|
||||
echo "::endgroup::"
|
||||
|
||||
if [[ $PACKAGE_SUFFIX ]]; then
|
||||
echo "::group::Update package name"
|
||||
../.ci/name_build.sh "$PACKAGE_SUFFIX"
|
||||
echo "::endgroup::"
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ if ! [[ $NAME ]]; then
|
|||
return 3
|
||||
fi
|
||||
|
||||
export IMAGE_NAME="${project_name,,}_${NAME,,}"
|
||||
export IMAGE_NAME="${project_name,,}_${NAME,,}" # lower case
|
||||
|
||||
docker_dir=".ci/$NAME"
|
||||
if ! [[ -r $docker_dir/Dockerfile ]]; then
|
||||
|
|
@ -133,7 +133,7 @@ function RUN ()
|
|||
{
|
||||
echo "running image:"
|
||||
if docker images | grep "$IMAGE_NAME"; then
|
||||
args="--mount type=bind,source=$(pwd),target=/src -w=/src"
|
||||
args="--mount type=bind,source=$PWD,target=/src -w=/src"
|
||||
if [[ $CCACHE_DIR ]]; then
|
||||
args+=" --mount type=bind,source=$CCACHE_DIR,target=/.ccache -e CCACHE_DIR=/.ccache"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/bash
|
||||
# this script is to be used by the ci to fetch the github upload url
|
||||
# using curl and jq
|
||||
[[ $ref ]] || missing+=" ref"
|
||||
[[ $repo ]] || missing+=" repo"
|
||||
if [[ $missing ]]; then
|
||||
echo "missing env:$missing" >&2
|
||||
exit 2
|
||||
fi
|
||||
tag="${ref##*/}"
|
||||
api_url="https://api.github.com/repos/$repo/releases/tags/$tag"
|
||||
upload_url="$(curl "$api_url" | jq -r '.upload_url')"
|
||||
if [[ $upload_url && $upload_url != null ]]; then
|
||||
echo "$upload_url"
|
||||
exit 0
|
||||
else
|
||||
echo "failed to fetch upload url from $api_url" >&2
|
||||
exit 1
|
||||
fi
|
||||
50
.ci/name_build.sh
Executable file
50
.ci/name_build.sh
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
# used by the ci to rename build artifacts
|
||||
# renames the file to [original name][SUFFIX].[original extension]
|
||||
# where SUFFIX is either available in the environment or as the first arg
|
||||
# if MAKE_ZIP is set instead a zip is made
|
||||
# expected to be run in the build directory
|
||||
builddir="."
|
||||
findrx="Cockatrice-*.*"
|
||||
|
||||
if [[ $1 ]]; then
|
||||
SUFFIX="$1"
|
||||
fi
|
||||
|
||||
# check env
|
||||
if [[ ! $SUFFIX ]]; then
|
||||
echo "::error file=$0::SUFFIX is missing"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
# find file
|
||||
found="$(find "$builddir" -maxdepth 1 -type f -name "$findrx" -print -quit)"
|
||||
path="${found%/*}" # remove all after last /
|
||||
file="${found##*/}" # remove all before last /
|
||||
if [[ ! $file ]]; then
|
||||
echo "::error file=$0::could not find package"
|
||||
exit 1
|
||||
fi
|
||||
if ! cd "$path"; then
|
||||
echo "::error file=$0::could not get file path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# set filename
|
||||
name="${file%.*}" # remove all after last .
|
||||
new_name="$name$SUFFIX."
|
||||
if [[ $MAKE_ZIP ]]; then
|
||||
filename="${new_name}zip"
|
||||
echo "creating zip '$filename' from '$file'"
|
||||
zip "$filename" "$file"
|
||||
else
|
||||
extension="${file##*.}" # remove all before last .
|
||||
filename="$new_name$extension"
|
||||
echo "renaming '$file' to '$filename'"
|
||||
mv "$file" "$filename"
|
||||
fi
|
||||
ls -l "$PWD/$filename"
|
||||
echo "::set-output name=path::$PWD/$filename"
|
||||
echo "::set-output name=name::$filename"
|
||||
Loading…
Add table
Add a link
Reference in a new issue