1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00
vcmi/CI/get_package_name.sh

43 lines
1.3 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=""
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}"
VCMI_PACKAGE_NAME_SUFFIX="branch ${branch_name}"
else
VCMI_PACKAGE_FILE_NAME="${VCMI_PACKAGE_FILE_NAME}-PR-${TMP_PRID}-${TMP_COMMIT}"
VCMI_PACKAGE_NAME_SUFFIX="PR ${TMP_PRID}"
fi
VCMI_PACKAGE_NAME_SUFFIX="(${VCMI_PACKAGE_NAME_SUFFIX})"
export VCMI_PACKAGE_FILE_NAME
export VCMI_PACKAGE_NAME_SUFFIX