Skip to content

Commit

Permalink
Enhancement (ci): Add more usage in build.sh (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh authored Mar 17, 2023
1 parent ab77a50 commit db80621
Showing 1 changed file with 61 additions and 47 deletions.
108 changes: 61 additions & 47 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,75 @@
set -u

usage() {

echo "build.sh: Builds a docker image"
echo "Configuration (environment variables):"
echo "################################# CI variables #################################"
echo "# Use this section for local builds."
echo "# All variables regardless of type will be processed as strings in builds."
echo "# Types specified in comments but serve to aid users in populating said variables."
echo "##################################################################################"

echo "## Job variables ##"
echo "PIPELINE= # string - 'build' for clean builds, 'update' for layered builds - required"
echo
echo "## build variables ##"
echo "GAME_VERSION= # int - required"
echo "APPID= # int - required"
echo "CLIENT_APPID= # int - required"
echo "GAME= # string - required"
echo "MOD= # string - required for APPID=90"
echo "FIX_APPMANIFEST= # bool - optional and only applicable to APPID=90"
echo "LATEST=true # bool - optional"
echo "CACHE= # bool - optional"
echo "NO_TEST= # bool - optional"
echo "NO_PUSH= # bool - optional"
echo "STEAM_LOGIN= # bool - optional"
echo
echo "## update variables ##"
echo "GAME_VERSION= # int - required"
echo "APPID= # int - required"
echo "GAME= # string - required"
echo "GAME_UPDATE_COUNT= # int - required"
echo "NO_PULL= # bool - optional"
echo "NO_TEST= # bool - optional"
echo "NO_PUSH= # bool - optional"
echo "STEAM_LOGIN= # bool - optional"
echo
echo "## User variables ##"
echo "REGISTRY_USER= # string - docker hub username - required unless NO_PUSH=true"
echo "REGISTRY_PASSWORD= # string - docker hub password or api key - required unless NO_PUSH=true"
echo "REGISTRY_GOLDSOURCE= # string - docker hub username or organization for goldsource games - required"
echo "REGISTRY_SOURCE= # string - docker hub username or organization for source games - required"
echo "STEAM_USERNAME= # string - steam username - optional"
echo "STEAM_PASSWORD= # string - steam password - optional"
echo
echo "build.sh: Builds a docker image. Requires docker and git"
echo "Usage: ./build.sh [OPTIONS]"
echo 'Options:'
echo " -f|--env-file Path to env file. Default: ./.env"
echo " -h|--help Help"
echo "Environment variables:"
echo " PIPELINE Build pipeline"
echo " Type: int"
echo " Possible values: 'build', 'update'"
echo " GAME_UPDATE_COUNT Game update count (docker label). Applies only to PIPELINE=update"
echo " Type: int"
echo " GAME_VERSION Game version. For example, to get the latest CS:GO version:"
echo " wget -qO- 'https://api.steampowered.com/ISteamApps/UpToDateCheck/v1?appid=730&version=0' | jq '.response.required_version'"
echo " Type: int"
echo " APPID AppID. See: https://developer.valvesoftware.com/wiki/Steam_Application_IDs"
echo " Type: int"
echo " CLIENT_APPID Client AppID. See: https://developer.valvesoftware.com/wiki/Steam_Application_IDs"
echo " Type: int"
echo " GAME Game"
echo " Type: string"
echo " MOD Mod. Needed when APPID=90, except for APPID=90 GAME=valve"
echo " Type: string, optional"
echo " FIX_APPMANIFEST Whether to fix appmanifests."
echo " Type: bool, optional"
echo " LATEST Whether to tag docker image as :latest. Applies only to PIPELINE=build"
echo " Type: bool, optional"
echo " Possible values: 'true', 'false'"
echo " CACHE Whether to pull the :latest image before running build"
echo " Type: bool, optional"
echo " Possible values: 'true', 'false'"
echo " NO_PULL Whether to skip pulling :latest image before building. Applies only to PIPELINE=update"
echo " Type: bool, optional"
echo " Possible values: 'true', 'false'"
echo " NO_TEST Whether to skip testing the game image after a successful build"
echo " Type: bool, optional"
echo " Possible values: 'true', 'false'"
echo " NO_PUSH Whether to skip pushing the docker image after a successful build"
echo " Type: bool, optional"
echo " Possible values: 'true', 'false'"
echo " DOCKER_REPOSITORY Docker repository"
echo " Type: string"
echo " REGISTRY_USER Docker registry user"
echo " Type: string"
echo " REGISTRY_PASSWORD Docker registry password"
echo " Type: string"
echo " STEAM_LOGIN Whether to logon to Steam so that games download without rate limiting. Generally needed when APPID=90"
echo " Type: bool, optional"
echo " STEAM_USERNAME Steam username"
echo " Type: string"
echo " STEAM_PASSWORD Steam password"
echo " Type: string"
echo "Examples:"
echo " # Build hlds/cstrike image and push"
echo " PIPELINE=build GAME_VERSION=1127 APPID=90 CLIENT_APPID=10 GAME=cstrike MOD=cstrike FIX_APPMANIFEST=true LATEST=true STEAM_LOGIN=true REGISTRY_GOLDSOURCE=docker.io/mynamespace/cstrike REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx STEAM_USERNAME=xxx STEAM_PASSWORD=xxx ./build.sh"
echo " PIPELINE=build GAME_VERSION=1127 APPID=90 CLIENT_APPID=10 GAME=cstrike MOD=cstrike FIX_APPMANIFEST=true LATEST=true STEAM_LOGIN=true DOCKER_REPOSITORY=docker.io/mynamespace/cstrike REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx STEAM_USERNAME=xxx STEAM_PASSWORD=xxx ./build.sh"
echo
echo " # Update hlds/cstrike image and push"
echo " PIPELINE=update GAME_UPDATE_COUNT=1 GAME_VERSION=1127 APPID=90 CLIENT_APPID=10 GAME=cstrike MOD=cstrike FIX_APPMANIFEST=true STEAM_LOGIN=true REGISTRY_GOLDSOURCE=docker.io/mynamespace/cstrike REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx STEAM_USERNAME=xxx STEAM_PASSWORD=xxx ./build.sh"
echo " PIPELINE=update GAME_UPDATE_COUNT=1 GAME_VERSION=1128 APPID=90 CLIENT_APPID=10 GAME=cstrike MOD=cstrike FIX_APPMANIFEST=true STEAM_LOGIN=true DOCKER_REPOSITORY=docker.io/mynamespace/cstrike REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx STEAM_USERNAME=xxx STEAM_PASSWORD=xxx ./build.sh"
echo
echo " # Build hlds/valve image and push"
echo " PIPELINE=build GAME_VERSION=1122 APPID=90 CLIENT_APPID=10 GAME=valve MOD= FIX_APPMANIFEST=true LATEST=true STEAM_LOGIN=true DOCKER_REPOSITORY=docker.io/mynamespace/valve REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx STEAM_USERNAME=xxx STEAM_PASSWORD=xxx ./build.sh"
echo
echo " # Update hlds/valve image and push"
echo " PIPELINE=update GAME_UPDATE_COUNT=1 GAME_VERSION=1123 APPID=90 CLIENT_APPID=10 GAME=valve MOD= FIX_APPMANIFEST=true STEAM_LOGIN=true DOCKER_REPOSITORY=docker.io/mynamespace/valve REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx STEAM_USERNAME=xxx STEAM_PASSWORD=xxx ./build.sh"
echo
echo " # Build srcds/csgo image and push"
echo " PIPELINE=build GAME_VERSION=13840 APPID=740 CLIENT_APPID=730 GAME=csgo LATEST=true REGISTRY_SOURCE=docker.io/mynamespace/csgo REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx ./build.sh"
echo " PIPELINE=build GAME_VERSION=13840 APPID=740 CLIENT_APPID=730 GAME=csgo LATEST=true DOCKER_REPOSITORY=docker.io/mynamespace/csgo REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx ./build.sh"
echo
echo " # Update srcds/csgo image and push"
echo " PIPELINE=update GAME_UPDATE_COUNT=1 GAME_VERSION=13840 APPID=740 CLIENT_APPID=730 GAME=csgo REGISTRY_SOURCE=docker.io/mynamespace/csgo REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx ./build.sh"
echo " PIPELINE=update GAME_UPDATE_COUNT=1 GAME_VERSION=13841 APPID=740 CLIENT_APPID=730 GAME=csgo DOCKER_REPOSITORY=docker.io/mynamespace/csgo REGISTRY_USER=xxx REGISTRY_PASSWORD=xxx ./build.sh"
echo
echo " # Build using an .env file in the same directory as build.sh"
echo " ./build.sh"
Expand Down

0 comments on commit db80621

Please sign in to comment.