index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2020-03-03 9:27:21.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2020-03-03 9:27:21.0 +00:00:00
commit
2adc5db8513b62bd660f85d117b59e418f6328b6 [patch]
tree
4aeb1413fb35b758107df383bb2e66d47e5423e0
parent
38808fb493535d3fa25610503560f4264ff931b8
download
2adc5db8513b62bd660f85d117b59e418f6328b6.tar.gz

refactor: relocate version script



Diff

 Makefile           |  4 ++--
 docker/version.sh  | 37 +++++++++++++++++++++++++++++++++++++
 scripts/version.sh | 37 -------------------------------------
 3 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/Makefile b/Makefile
index e631cb6..82147ca 100644
--- a/Makefile
+++ b/Makefile
@@ -210,7 +210,7 @@ prod.release.tag:
	git push --delete origin latest

	# Update docker files to latest tag per platform
	./scripts/version.sh v$(PKG_TAG)
	./docker/version.sh v$(PKG_TAG)

	git add .
	git commit . -m "v$(PKG_TAG)"
@@ -223,5 +223,5 @@ prod.release.tag:

prod.release.dockerfiles:
	# Update docker files to latest tag per platform
	./scripts/version.sh v$(PKG_TAG)
	./docker/version.sh v$(PKG_TAG)
.ONESHELL: prod.release.dockerfiles
diff --git a/docker/version.sh b/docker/version.sh
new file mode 100755
index 0000000..ea02cdf
--- /dev/null
+++ b/docker/version.sh
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -e
set -u

LATEST_TAG=$1
BASE_PATH="$(pwd)/docker"

if [ $# -eq 0 ]; then
    echo "Usage: ./version.sh <tag or branch>"
    exit
fi

export VERSION=$LATEST_TAG
export ALPINE_VERSION=3.10

PLATFORMS=(
    "alpine"
    "scratch"
)

for PLATFORM in "${PLATFORMS[@]}"; do
    PLATFORM_DIR="${BASE_PATH}/${PLATFORM}"
    
    if [ ! -d "$PLATFORM_DIR" ]; then
        echo "Directory no found for \"${PLATFORM_DIR}\""
        exit 1
    fi
    
    echo "Generating Dockerfile for platform \"${PLATFORM}\""
    
    rm -rf "${PLATFORM_DIR}/Dockerfile"
    
    envsubst \$ALPINE_VERSION,\$VERSION <"${PLATFORM_DIR}/Dockerfile.tmpl" >"${PLATFORM_DIR}/Dockerfile"
done

echo "All Dockerfiles were updated!"
diff --git a/scripts/version.sh b/scripts/version.sh
deleted file mode 100755
index a9a4a2a..0000000
--- a/scripts/version.sh
+++ /dev/null
@@ -1,37 +0,0 @@
#!/usr/bin/env bash

set -e
set -u

LATEST_TAG=$1
BASE_PATH="$(pwd)/docker"

if [ $# -eq 0 ]; then
    echo "Usage: ./version.sh <tag or branch>"
    exit
fi

export VERSION=$LATEST_TAG
export ALPINE_VERSION=3.10

PLATFORMS=(
    "alpine"
    "scratch"
)

for PLATFORM in "${PLATFORMS[@]}"; do
    PLATFORM_DIR="${BASE_PATH}/${PLATFORM}"

    if [ ! -d "$PLATFORM_DIR" ]; then
        echo "Directory no found for \"${PLATFORM_DIR}\""
        exit 1
    fi

    echo "Generating Dockerfile for platform \"${PLATFORM}\""

    rm -rf "${PLATFORM_DIR}/Dockerfile"

    envsubst \$ALPINE_VERSION,\$VERSION <"${PLATFORM_DIR}/Dockerfile.tmpl" >"${PLATFORM_DIR}/Dockerfile"
done

echo "All Dockerfiles were updated!"