File: setenv

package info (click to toggle)
openrct2 0.4.29%2Bds-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 104,244 kB
  • sloc: cpp: 676,472; ansic: 1,322; javascript: 716; xml: 640; sh: 439; python: 313; php: 34; makefile: 19
file content (70 lines) | stat: -rwxr-xr-x 2,390 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash

set -e

# This sets up more environment variables using the existing environment
# It should be dot sourced into your environment
if [[ "$GITHUB_ACTIONS" != "true" ]]; then
    export OPENRCT2_BUILD_SERVER=$(hostname)
    export OPENRCT2_VERSION=$(grep 'OPENRCT2_VERSION:' openrct2/.github/workflows/ci.yml | sed 's/.*OPENRCT2_VERSION: *//;s/".*//')
    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()
{
    echo "${DISTANCE_FROM_TAG}"
}
export OPENRCT2_BUILD=$(get_build_number)

# Get the name of the branch and decide whether we should push the build to openrct2.org
unset OPENRCT2_TAG
unset OPENRCT2_PUSH
if [[ $GITHUB_REF == refs/tags/* ]]; then
    unset OPENRCT2_BRANCH
    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
if [[ -z "$OPENRCT2_ORG_TOKEN" ]]; then
    unset OPENRCT2_PUSH
fi

# Get the short SHA1
export OPENRCT2_SHA1=$GITHUB_SHA
export OPENRCT2_SHA1_SHORT=${OPENRCT2_SHA1::10}
unset OPENRCT2_VERSION_EXTRA
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#./}"
}
scriptsdir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
export PATH="$scriptsdir:$PATH"
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"

# 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