From 28618bd3ac622ccc529eb14f323c897396188ed0 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 16 Mar 2021 08:57:05 +0100 Subject: [PATCH] Add packager helper script --- app-version.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 app-version.sh diff --git a/app-version.sh b/app-version.sh new file mode 100755 index 0000000..dce338e --- /dev/null +++ b/app-version.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Usage: ./app-version.sh +# Example: ./app-version.sh drone/drone:1.10.1 app +# +# Accepts a full format hub.docker.com image tag which it pulls locally and +# generates output which can be used to put in the abra.sh for app packaging. +# Requires the yq program https://mikefarah.gitbook.io/yq/ + +error() { + echo "$(tput setaf 1)ERROR: $*$(tput sgr0)" + exit 1 +} + +IMAGE="$1" +SERVICE="$2" + +if ! docker pull -q "$IMAGE" > /dev/null 2>&1; then + error "Failed to download image, is the tag correct?" +fi + +version=$(echo "$IMAGE" | cut -d ':' -f2) +digest=$(docker image inspect -f "{{.Id}}" "$IMAGE" | cut -d ':' -f2- | cut -c 1-8) + +echo "ABRA_TYPE_${SERVICE^^}_VERSION=${version}" +echo "ABRA_TYPE_${SERVICE^^}_DIGEST=${digest}"