2022-03-10 00:15:32 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
2020-01-19 09:04:59 -05:00
|
|
|
|
2021-04-14 18:34:52 -04:00
|
|
|
# This sets up more environment variables using the existing environment
|
2020-01-19 09:04:59 -05:00
|
|
|
# It should be dot sourced into your environment
|
|
|
|
if [[ "$GITHUB_ACTIONS" != "true" ]]; then
|
|
|
|
export OPENRCT2_BUILD_SERVER=$(hostname)
|
2023-09-03 11:13:15 -04:00
|
|
|
export OPENRCT2_VERSION=0.4.6
|
2020-01-19 09:04:59 -05:00
|
|
|
GITHUB_REF=$(git rev-parse --symbolic-full-name HEAD)
|
|
|
|
GITHUB_SHA=$(git rev-parse HEAD)
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "\033[0;36mSetting up environment for OpenRCT2...\033[0m"
|
|
|
|
|
|
|
|
# Get the build number (number of commits since last tag)
|
|
|
|
get_build_number()
|
|
|
|
{
|
|
|
|
local pattern='.+-([0-9]+)-.+'
|
|
|
|
[[ $OPENRCT2_DESCRIBE =~ $pattern ]]
|
|
|
|
echo "${BASH_REMATCH[1]}"
|
|
|
|
}
|
|
|
|
export OPENRCT2_BUILD=$(get_build_number)
|
|
|
|
|
|
|
|
# Get the name of the branch and decide whether we should push the build to openrct2.org
|
2021-04-12 18:01:15 -04:00
|
|
|
unset OPENRCT2_TAG
|
|
|
|
unset OPENRCT2_PUSH
|
2020-01-19 09:04:59 -05:00
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
2021-04-12 18:01:15 -04:00
|
|
|
unset OPENRCT2_BRANCH
|
2020-01-19 09:04:59 -05:00
|
|
|
export OPENRCT2_TAG=true
|
|
|
|
export OPENRCT2_PUSH=true
|
|
|
|
else
|
|
|
|
export OPENRCT2_BRANCH=${GITHUB_REF#refs/heads/}
|
|
|
|
if [[ "$OPENRCT2_BRANCH" =~ ^(develop|push/) ]]; then
|
|
|
|
export OPENRCT2_PUSH=true
|
|
|
|
fi
|
|
|
|
fi
|
2022-03-09 23:56:47 -05:00
|
|
|
if [[ -z "$OPENRCT2_ORG_TOKEN" ]]; then
|
2021-04-12 18:01:15 -04:00
|
|
|
unset OPENRCT2_PUSH
|
2020-01-19 09:04:59 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Get the short SHA1
|
|
|
|
export OPENRCT2_SHA1=$GITHUB_SHA
|
2022-03-11 06:31:07 -05:00
|
|
|
export OPENRCT2_SHA1_SHORT=${OPENRCT2_SHA1::7}
|
2021-04-12 18:01:15 -04:00
|
|
|
unset OPENRCT2_VERSION_EXTRA
|
2020-01-19 09:04:59 -05:00
|
|
|
if [[ "$OPENRCT2_TAG" != "true" ]]; then
|
|
|
|
export OPENRCT2_VERSION_EXTRA=$OPENRCT2_BRANCH-$OPENRCT2_SHA1_SHORT
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add scripts directory to PATH
|
|
|
|
realpath() {
|
|
|
|
[[ $1 = /* ]] && echo "$1" || echo "$(pwd)/${1#./}"
|
|
|
|
}
|
2020-01-24 06:46:12 -05:00
|
|
|
scriptsdir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
2020-01-19 09:04:59 -05:00
|
|
|
export PATH="$scriptsdir:$PATH"
|
2021-02-10 16:35:04 -05:00
|
|
|
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
2020-01-19 09:04:59 -05:00
|
|
|
|
|
|
|
# Output all the variables
|
|
|
|
if [[ "$1" != "-q" ]]; then
|
|
|
|
echo "----------------------------------------------"
|
|
|
|
echo "OPENRCT2_BUILD_SERVER: $OPENRCT2_BUILD_SERVER"
|
|
|
|
echo "OPENRCT2_TAG: $OPENRCT2_TAG"
|
|
|
|
echo "OPENRCT2_BRANCH: $OPENRCT2_BRANCH"
|
|
|
|
echo "OPENRCT2_VERSION: $OPENRCT2_VERSION"
|
|
|
|
echo "OPENRCT2_VERSION_EXTRA: $OPENRCT2_VERSION_EXTRA"
|
|
|
|
echo "OPENRCT2_BUILD: $OPENRCT2_BUILD"
|
|
|
|
echo "OPENRCT2_DESCRIBE: $OPENRCT2_DESCRIBE"
|
|
|
|
echo "OPENRCT2_PUSH: $OPENRCT2_PUSH"
|
|
|
|
echo "OPENRCT2_SHA1: $OPENRCT2_SHA1"
|
|
|
|
echo "OPENRCT2_SHA1_SHORT: $OPENRCT2_SHA1_SHORT"
|
|
|
|
echo "----------------------------------------------"
|
|
|
|
fi
|