diff options
author | Christian Segundo | 2024-07-23 21:43:05 +0200 |
---|---|---|
committer | Christian Segundo | 2024-07-23 21:43:05 +0200 |
commit | 362af4e16d7cdfa1512a6f2f154f055907b4d900 (patch) | |
tree | f0e8817df1cad49bd466c60016cdd8b70913690c /.scripts.d | |
parent | 076b6aefd5b17cccc34cc403b7b4f2ba4f093a57 (diff) | |
download | transmission-hacks-362af4e16d7cdfa1512a6f2f154f055907b4d900.tar.gz |
add ci
Diffstat (limited to '.scripts.d')
-rw-r--r-- | .scripts.d/20-build.sh | 20 | ||||
-rw-r--r-- | .scripts.d/30-test.sh | 28 | ||||
-rw-r--r-- | .scripts.d/40-publish.sh | 45 |
3 files changed, 93 insertions, 0 deletions
diff --git a/.scripts.d/20-build.sh b/.scripts.d/20-build.sh new file mode 100644 index 0000000..6f8beb9 --- /dev/null +++ b/.scripts.d/20-build.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# vim: ai:ts=8:sw=8:noet +set -EeufCo pipefail +export SHELLOPTS # propagate set to children by default +IFS=$'\t\n' + +# check required commands are in place +command -v docker >/dev/null 2>&1 || { + echo 'please install docker-client' + exit 1 +} + +docker buildx build \ + --no-cache \ + --pull \ + --load \ + --tag "chn2guevara/transmission-hacks:${BUILD_ID}" \ + . + + diff --git a/.scripts.d/30-test.sh b/.scripts.d/30-test.sh new file mode 100644 index 0000000..16c4fac --- /dev/null +++ b/.scripts.d/30-test.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# vim: ai:ts=8:sw=8:noet +set -EeufCo pipefail +export SHELLOPTS # propagate set to children by default +IFS=$'\t\n' + +# check required commands are in place +command -v docker >/dev/null 2>&1 || { + echo 'please install docker-client' + exit 1 +} + +# install goss +curl -fsSL https://goss.rocks/install | sh + +export GOSS_SLEEP=${GOSS_SLEEP:-5} +export GOSS_VARS=${GOSS_VARS:-} +export GOSS_ADDITIONAL_COPY_PATH=${GOSS_ADDITIONAL_COPY_PATH:-} +export GOSS_OPTS="--format junit --no-color" +export CONTAINER_LOG_OUTPUT=${CONTAINER_LOG_OUTPUT:-} +export GOSS_FILES_STRATEGY=cp + +goss --gossfile goss.yaml render >goss-full.yaml +mv goss-full.yaml goss.yaml + +rm -rf build/reports/ +mkdir -p build/reports/ +dgoss run "chn2guevara/transmission-hacks:${BUILD_ID}" "/usr/bin/sleep" "infinity" >build/reports/goss.xml diff --git a/.scripts.d/40-publish.sh b/.scripts.d/40-publish.sh new file mode 100644 index 0000000..4f5f4d4 --- /dev/null +++ b/.scripts.d/40-publish.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: ai:ts=8:sw=8:noet +set -EeufCo pipefail +export SHELLOPTS # propagate set to children by default +IFS=$'\t\n' + +# check required commands are in place +command -v docker >/dev/null 2>&1 || { + echo 'please install docker-client' + exit 1 +} + +docker login --username "chn2guevara" \ + --password-stdin <<<"$DOCKERHUB_TOKEN" + +BUILDER_SUFFIX=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5 ; echo '') +docker run --privileged --rm tonistiigi/binfmt --install arm64 +docker buildx create --use --name "multi-arch-builder-${BUILDER_SUFFIX}" +trap "docker buildx rm 'multi-arch-builder-""${BUILDER_SUFFIX}""'" EXIT + +DOCKER_TAG="latest" +if [ "$GIT_BRANCH" != "master" ]; then + DOCKER_TAG="${GIT_BRANCH//\//-}" +fi + +if [ "$(git tag --contains)" = "" ]; then + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --builder "multi-arch-builder-${BUILDER_SUFFIX}" \ + --no-cache \ + --pull \ + --push \ + --tag "chn2guevara/transmission-hacks:${DOCKER_TAG}" \ + . +else + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --builder "multi-arch-builder-${BUILDER_SUFFIX}" \ + --no-cache \ + --pull \ + --push \ + --tag "chn2guevara/transmission-hacks:${DOCKER_TAG}" \ + --tag "chn2guevara/transmission-hacks:$(git tag --contains | head -1)" \ + . +fi |