diff --git a/action.bash b/action.bash index de7b7db..96d91a9 100755 --- a/action.bash +++ b/action.bash @@ -6,12 +6,13 @@ TARGET=icinga/icingaweb2 mkimg () { test -n "$TAG" + test -n "$MODE" node /actions/checkout/dist/index.js |grep -vFe ::add-matcher:: git archive --prefix=icingaweb2/ HEAD |tar -x - /get-mods.sh "$1" + /get-mods.sh "$MODE" /composer.bash patch -d icingaweb2 -p0 < /icingaweb2.patch @@ -31,39 +32,24 @@ push () { fi } -# Matches Git references that start with `refs/` and then continue with `heads/` or `tags/`. -# An optional `v` that follows is ignored. Then the tag or branch name is captured. These may -# be of the following forms and what is captured of them: -# -# -
-> g1(´heads´ or ´tags´),g2,g3 -# -# - v1 -> ,1, -# - v1.1 -> ,1.1, -# - v1.2-1 -> ,1.2-1, -# - 2.0.0 -> ,2.0.0, -# - master -> ,master, -# - main -> ,main, -# - something -> ,something, -# - verbose -> ,erbose, -# - vault -> ,ault, -# - fix/error-123 -> ,fix/error-123,error-123 -# - fix/mistake-456 -> ,fix/mistake-456,mistake-456 -# - fix/climate -> ,fix/climate,climate -# - bugfix/legacy -> ,bugfix/legacy,legacy -# - feature/green-energy -> ,feature/green-energy,green-energy -# - feature/verbosity -> ,feature/verbosity,verbosity -# - viehture/bullshit -> ,viehture/bullshit,bullshit -# -re_docker_tag="^refs/(heads|tags)/v?([^/]+|[a-z]+/(.*))$" - case "$GITHUB_EVENT_NAME" in workflow_dispatch|schedule|release) - [[ "$GITHUB_REF" =~ $re_docker_tag ]] - if [ -n "${BASH_REMATCH[3]}" ]; then - TAG="${BASH_REMATCH[3]}" - else - TAG="${BASH_REMATCH[2]}" - fi + case "$GITHUB_REF" in + refs/tags/v*) + MODE=release + TAG=${GITHUB_REF#refs/tags/v} + ;; + refs/heads/*) + MODE=snapshot + TAG=${GITHUB_REF#refs/heads/} + # Remove everything up to the first slash to remove prefixes like "feature/" + TAG=${TAG#*/} + ;; + *) + echo "Unknown ref: $GITHUB_REF" >&2 + false + ;; + esac mkimg push ;; diff --git a/build.bash b/build.bash index 208b689..5b72e79 100755 --- a/build.bash +++ b/build.bash @@ -3,7 +3,7 @@ set -exo pipefail IW2SRC="$1" -export MODS_BRANCH="$2" +export BUILD_MODE="${2:-release}" if [ -z "$IW2SRC" ]; then cat <&2 @@ -22,14 +22,14 @@ docker run --rm -i \ -v "${IW2SRC}:/iw2src:ro" \ -v "${BLDCTX}:/bldctx:ro" \ -v /var/run/docker.sock:/var/run/docker.sock \ - -e MODS_BRANCH \ + -e BUILD_MODE \ icinga/icingaweb2-builder bash <&2 < + + release: download the latest release version of all external modules + snapshot: download a snapshot/development version of all external modules +EOF + exit 1 +} get_tag () { if git -C dockerweb2-temp tag |grep -qvFe -; then # ex. RCs @@ -17,22 +25,25 @@ get_special () { rm -rf dockerweb2-temp git clone --bare "https://github.com/Icinga/${1}.git" dockerweb2-temp - case "$2" in - icingaweb2/modules/incubator) + case "$MODE" in + release) REF="$(get_tag)" ;; - *) - if [ "$BRANCH" = master ] && [[ "$2" == icinga-php/* ]]; then - REF=snapshot/nightly - elif [ -n "$BRANCH" ] && git -C dockerweb2-temp show -s --oneline "$BRANCH"; then - REF="$BRANCH" - else - REF="$(get_tag)" - - if [ "$2" = icingaweb2/modules/icingadb ] && [ "$REF" = 'v1.0.0-rc1' ]; then - REF=2c0662c420617712bd26234da550dcf8d4afcdb8 # v1.0.0-rc1+ - fi - fi + snapshot) + case "$2" in + icingaweb2/modules/incubator) + # "HINT: Do NOT install the GIT master, it will not work!" + # https://github.com/Icinga/icingaweb2-module-incubator/blob/master/README.md + REF="$(get_tag)" + ;; + icinga-php/*) + # Special branch that contains vendored dependencies missing in HEAD + REF=snapshot/nightly + ;; + *) + REF=HEAD + ;; + esac ;; esac @@ -53,6 +64,12 @@ get_mod () { get_altname "icingaweb2-module-$1" "$1" } +MODE="$1" +case "$MODE" in + release|snapshot) ;; + *) usage ;; +esac + get_lib library ipl get_lib thirdparty vendor get_mod audit