-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: guess some environment variables based on builder name and os
Some environment variables (like DEPLOY or DEPLOY_ALT for dist builders, or IMAGE on Linux builders) are set on a lot of builders, and whether they should be present or not can be detected automatically based on the builder name and the platform. This commit simplifies the CI configuration by automatically setting those environment variables.
- Loading branch information
1 parent
c90ad20
commit b1a5bb0
Showing
5 changed files
with
72 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
# This script guesses some environment variables based on the builder name and | ||
# the current platform, to reduce the amount of variables defined in the CI | ||
# configuration. | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" | ||
|
||
# Builders starting with `dist-` are dist builders, but if they also end with | ||
# `-alt` they are alternate dist builders. | ||
if [[ "${CI_JOB_NAME}" = dist-* ]]; then | ||
if [[ "${CI_JOB_NAME}" = *-alt ]]; then | ||
echo "alternate dist builder detected, setting DEPLOY_ALT=1" | ||
ciCommandSetEnv DEPLOY_ALT 1 | ||
else | ||
echo "normal dist builder detected, setting DEPLOY=1" | ||
ciCommandSetEnv DEPLOY 1 | ||
fi | ||
fi | ||
|
||
# All the Linux builds happen inside Docker. | ||
if isLinux; then | ||
if [[ -z "${IMAGE+x}" ]]; then | ||
echo "linux builder detected, using docker to run the build" | ||
ciCommandSetEnv IMAGE "${CI_JOB_NAME}" | ||
else | ||
echo "a custom docker image is already set" | ||
fi | ||
fi |