2021-10-19 18:49:46 -06:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2021-10-20 14:49:40 -06:00
|
|
|
images="ghcr.io/dirtbags/moth dirtbags/moth"
|
2021-10-19 20:09:51 -06:00
|
|
|
|
2021-10-19 18:49:46 -06:00
|
|
|
ACTION=$1
|
2021-10-19 18:52:19 -06:00
|
|
|
if [ -z "$ACTION" ]; then
|
|
|
|
echo "Usage: $0 ACTION"
|
2021-10-19 18:49:46 -06:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
log () {
|
|
|
|
printf "=== %s\n" "$*" 1>&2
|
|
|
|
}
|
|
|
|
|
|
|
|
fail () {
|
|
|
|
printf "\033[31;1m=== FAIL: %s\033[0m\n" "$*" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2021-10-19 19:55:42 -06:00
|
|
|
run () {
|
2021-10-19 20:01:27 -06:00
|
|
|
printf "\033[32m\$\033[0m %s\n" "$*" 1>&2
|
2021-10-19 19:55:42 -06:00
|
|
|
"$@"
|
|
|
|
}
|
|
|
|
|
2021-10-19 18:49:46 -06:00
|
|
|
tags () {
|
|
|
|
pfx=$1
|
2021-10-19 20:09:51 -06:00
|
|
|
for base in $images; do
|
2021-10-20 14:27:32 -06:00
|
|
|
echo $pfx $base:${CI_COMMIT_REF_NAME}
|
|
|
|
echo $pfx $base:${CI_COMMIT_REF_NAME%.*}
|
|
|
|
echo $pfx $base:${CI_COMMIT_REF_NAME%.*.*}
|
2021-10-19 18:49:46 -06:00
|
|
|
done | uniq
|
|
|
|
}
|
|
|
|
|
|
|
|
case $ACTION in
|
|
|
|
publish)
|
2021-10-19 19:55:42 -06:00
|
|
|
run docker build \
|
2021-10-19 18:49:46 -06:00
|
|
|
--file build/package/Containerfile \
|
2021-10-19 20:05:02 -06:00
|
|
|
$(tags --tag) \
|
2021-10-19 18:53:18 -06:00
|
|
|
.
|
2021-10-19 20:12:36 -06:00
|
|
|
tags | while read image; do
|
|
|
|
run docker push $image
|
2021-10-19 20:09:51 -06:00
|
|
|
done
|
2021-10-19 18:49:46 -06:00
|
|
|
;;
|
2023-10-18 15:12:38 -06:00
|
|
|
release)
|
|
|
|
run go build -v ./cmd/mothd
|
|
|
|
run go build -v ./cmd/transpile
|
|
|
|
run tar czf moth-$(git tag --contains).$(uname -s)-$(uname -m).tar.gz mothd transpile theme
|
|
|
|
;;
|
2021-10-19 18:49:46 -06:00
|
|
|
*)
|
|
|
|
echo "Unknown action: $1" 1>&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|