1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/CI/get_package_name.sh

53 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/sh
if [ ! -z "$TRAVIS_JOB_ID" ];
then
echo "Using Travis environment variables!"
TMP_JOBID="$TRAVIS_JOB_ID"
TMP_BRANCH="$TRAVIS_BRANCH"
TMP_PRID="$TRAVIS_PULL_REQUEST"
TMP_COMMIT="$TRAVIS_COMMIT"
elif [ ! -z "${APPVEYOR_JOB_ID}" ];
then
echo "Using AppVeyor environment variables!"
TMP_JOBID=$(echo "$APPVEYOR_JOB_ID" | sed 's/[^[:digit:]]\+//g')
TMP_BRANCH="$APPVEYOR_REPO_BRANCH"
TMP_PRID="$APPVEYOR_PULL_REQUEST_NUMBER"
TMP_COMMIT="$APPVEYOR_REPO_COMMIT"
2021-07-05 19:04:17 +02:00
elif [ ! -z "${GITHUB_RUN_ID}" ];
then
echo "Using Github environment variables!"
TMP_JOBID="$GITHUB_RUN_ID"
2021-07-27 20:26:17 +02:00
TMP_BRANCH=$(basename ${GITHUB_REF#refs/heads/})
2021-07-05 19:04:17 +02:00
TMP_PRID="$PULL_REQUEST"
TMP_COMMIT=$(git rev-parse --short "$GITHUB_SHA")
else
echo "No Travir or AppVeyor environment variables found!"
exit
fi
VCMI_PACKAGE_FILE_NAME="${TMP_JOBID}-vcmi"
VCMI_PACKAGE_NAME_SUFFIX=""
2022-12-23 10:10:05 +02:00
VCMI_PACKAGE_GITVERSION="ON"
if [ -z "$TMP_PRID" ] || [ "$TMP_PRID" == "false" ];
then
branch_name=$(echo "$TMP_BRANCH" | sed 's/[^[:alnum:]]\+/_/g')
VCMI_PACKAGE_FILE_NAME="${VCMI_PACKAGE_FILE_NAME}-branch-${branch_name}-${TMP_COMMIT}"
2022-12-23 10:10:05 +02:00
if [ "${branch_name}" != "master" ];
then
VCMI_PACKAGE_NAME_SUFFIX="branch ${branch_name}"
else
VCMI_PACKAGE_GITVERSION="OFF"
fi
else
VCMI_PACKAGE_FILE_NAME="${VCMI_PACKAGE_FILE_NAME}-PR-${TMP_PRID}-${TMP_COMMIT}"
VCMI_PACKAGE_NAME_SUFFIX="PR ${TMP_PRID}"
fi
2022-12-23 10:10:05 +02:00
if [ "${VCMI_PACKAGE_NAME_SUFFIX}" != "" ];
then
VCMI_PACKAGE_NAME_SUFFIX="(${VCMI_PACKAGE_NAME_SUFFIX})"
fi
export VCMI_PACKAGE_FILE_NAME
export VCMI_PACKAGE_NAME_SUFFIX
2022-12-23 10:10:05 +02:00
export VCMI_PACKAGE_GITVERSION