faas/contrib/publish-arm.sh
Richard Gee 27ebbfdccd Refactor CI and enable auto-builds for auth
Automatic builds for auth-module on x86_64 (via Travis) and on-demand on-device for arm via publish.sh

The basic-auth module is not built or pushed upon 'tag' / 'release' of the faas repo, but it should be: https://github.com/openfaas/faas/tree/master/auth.  We also don't create on-device images for this, but should do for both armhf and arm64: https://github.com/openfaas/faas/blob/master/contrib/publish-arm.sh

This change addresses these challenges and also introduces a tagAndPush script to alleviate some of the recently introduced repetition in .travis.yml.

Signed-off-by: Richard Gee <richard@technologee.co.uk>
2019-06-23 20:39:48 +01:00

80 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
declare -a repos=("openfaas-incubator/openfaas-operator" "openfaas-incubator/faas-idler" "openfaas/faas" "openfaas/faas-swarm" "openfaas/nats-queue-worker" "openfaas/faas-netes" "openfaas/faas-cli")
HERE=`pwd`
ARCH=$(uname -m)
#if [ ! -z "$CACHED" ]; then
rm -rf staging || :
mkdir -p staging/openfaas
mkdir -p staging/openfaas-incubator
#fi
get_image_names() {
if [ "openfaas-incubator/faas-idler" = $1 ]; then
images=("openfaas/faas-idler")
elif [ "openfaas/faas" = $1 ]; then
images=("openfaas/gateway" "openfaas/basic-auth-plugin")
elif [ "openfaas/nats-queue-worker" = $1 ]; then
images=("openfaas/queue-worker")
elif [ "openfaas-incubator/openfaas-operator" = $1 ]; then
images=("openfaas/openfaas-operator")
else
images=($1)
fi
}
if [ "$ARCH" = "armv7l" ] ; then
ARM_VERSION="armhf"
elif [ "$ARCH" = "aarch64" ] ; then
ARM_VERSION="arm64"
fi
echo "Target architecture: ${ARM_VERSION}"
for r in "${repos[@]}"
do
cd $HERE
echo -e "\nBuilding: $r\n"
git clone https://github.com/$r ./staging/$r
cd ./staging/$r
pwd
export TAG=$(git describe --abbrev=0 --tags)
echo "Latest release: $TAG"
get_image_names $r
for IMAGE in "${images[@]}"
do
TAG_PRESENT=$(curl -s "https://hub.docker.com/v2/repositories/${IMAGE}/tags/${TAG}-${ARM_VERSION}/" | grep -Po '"detail": *"[^"]*"' | grep -o 'Not found')
if [ "$TAG_PRESENT" = "Not found" ]; then
break
fi
done
if [ "$TAG_PRESENT" = "Not found" ]; then
make ci-${ARM_VERSION}-build ci-${ARM_VERSION}-push
else
for IMAGE in "${images[@]}"
do
echo "Image is already present: ${IMAGE}:${TAG}-${ARM_VERSION}"
done
fi
done
echo "Docker images"
for r in "${repos[@]}"
do
cd $HERE
cd ./staging/$r
export TAG=$(git describe --abbrev=0 --tags)
echo "$r"
get_image_names $r
for IMAGE in "${images[@]}"
do
echo " ${IMAGE}:${TAG}-${ARM_VERSION}"
done
done