From c50bc7ecfa7b2ba1dce919b8be89d6baf2679da7 Mon Sep 17 00:00:00 2001 From: Stephen Gaito Date: Fri, 29 Nov 2019 09:43:07 +0000 Subject: [PATCH] refactored upload scripts --- buildScripts/createAppImage | 3 ++ buildScripts/createDockerImage | 26 ++++++++++ buildScripts/uploadDockerImage | 48 +++++++++++++++++++ .../{uploadRelease => uploadGitHubRelease} | 2 +- ...ploadReleaseDSL => uploadGitHubReleaseDSL} | 0 ...easeMessage => uploadGitHubReleaseMessage} | 0 buildScripts/uploadImages | 13 +++++ buildScripts/versionEnvs | 18 +++---- 8 files changed, 100 insertions(+), 10 deletions(-) create mode 100755 buildScripts/uploadDockerImage rename buildScripts/{uploadRelease => uploadGitHubRelease} (98%) rename buildScripts/{uploadReleaseDSL => uploadGitHubReleaseDSL} (100%) rename buildScripts/{uploadReleaseMessage => uploadGitHubReleaseMessage} (100%) create mode 100644 buildScripts/uploadImages diff --git a/buildScripts/createAppImage b/buildScripts/createAppImage index 5321e1e..4ebebd6 100755 --- a/buildScripts/createAppImage +++ b/buildScripts/createAppImage @@ -13,6 +13,9 @@ echo "" # For appimage output plugin # export VERSION="$PDF2HTMLEX_BRANCH-$BUILD_TIME" +export APPIMAGE_NAME="pdf2htmlEX-$PDF2HTMLEX_BRANCH-$BUILD_TIME-$MACHINE_ARCH.AppImage" + +echo "export APPIMAGE_NAME=\"$APPIMAGE_NAME\"" >> buildScripts/reSourceVersionEnvs mkdir -p imageBuild/appDir/usr/lib/ diff --git a/buildScripts/createDockerImage b/buildScripts/createDockerImage index 8945c71..71e2287 100755 --- a/buildScripts/createDockerImage +++ b/buildScripts/createDockerImage @@ -14,6 +14,32 @@ if [ -x "$(which docker)" ]; then source buildScripts/dockerFunctions +if [ -z "$DOCKER_FROM" ]; then + echo "" + read -p "Enter the docker image for the 'from' base: " DOCKER_FROM + echo "" + if [ -z "$DOCKER_FROM" ]; then + echo "DOCKER_FROM not set... so we can not build the docker image" + exit 1 + fi +fi + +if [ -z "$DOCKER_USERNAME" ]; then + echo "" + read -p "Enter a docker username: " DOCKER_USERNAME + echo "" + if [ -z "$DOCKER_USERNAME" ]; then + echo "DOCKER_USERNAME not set... so we can not build the docker image" + exit 1 + fi +fi + +export DOCKER_NAME="$DOCKER_USERNAME/pdf2htmlex:$PDF2HTMLEX_BRANCH-$BUILD_TIME" + +echo "export DOCKER_FROM=\"$DOCKER_FROM\"" >> buildScripts/reSourceVersionEnvs +echo "export DOCKER_USERNAME=\"$DOCKER_USERNAME\"" >> buildScripts/reSourceVersionEnvs +echo "export DOCKER_NAME=\"$DOCKER_NAME\"" >> buildScripts/reSourceVersionEnvs + mkdir -p imageBuild/dockerDir cd pdf2htmlEX/build diff --git a/buildScripts/uploadDockerImage b/buildScripts/uploadDockerImage new file mode 100755 index 0000000..13fe66f --- /dev/null +++ b/buildScripts/uploadDockerImage @@ -0,0 +1,48 @@ +#!/bin/bash + +# This bash script uploads the pdf2htmlEX docker image to docker hub +# +# We EXPECT the following environment variables to be set: +# DOCKER_USERNAME +# +# You can OPTIONALLY set the following environment variables: +# DOCKER_PASSWORD (if not set you will be asked for your password) +# + +source ./buildScripts/reSourceVersionEnvs + +echo "" +echo "-------------------------------------------------------------------" +echo "UPLOADING pdf2htmlEX Docker Image to Docker Hub" +echo "-------------------------------------------------------------------" +echo "" + +################################## +# push docker image +# +if [ -x "$(which docker)" ]; then + + if [ -z "$DOCKER_USERNAME" ]; then + echo "" + read -p "Enter the Docker usernane): " DOCKER_USERNAME + echo "" + if [ -z "$DOCKER_USERNAME" ]; then + echo "DOCKER_USERNAME not set... so we do not know where to push image." + exit 1 + fi + fi + + if [ -z "$DOCKER_PASSWORD" ]; then + echo "" + echo "Please type your the Docker hub password" + docker login -u "$DOCKER_USERNAME" + else + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + fi + + docker push $DOCKER_USERNAME/pdf2htmlex + +else + echo "Docker is not installed... skipping upload of docker image." +fi + diff --git a/buildScripts/uploadRelease b/buildScripts/uploadGitHubRelease similarity index 98% rename from buildScripts/uploadRelease rename to buildScripts/uploadGitHubRelease index fefc3c3..0f6b35e 100755 --- a/buildScripts/uploadRelease +++ b/buildScripts/uploadGitHubRelease @@ -73,7 +73,7 @@ echo $DOCKER_NAME > dockerImageName deleteReleaseByTag "$TRAVIS_REPO_SLUG" "continuous" createNewRelease "$TRAVIS_REPO_SLUG" "continuous" "Latest release" \ - ../buildScripts/uploadReleaseMessage + ../buildScripts/uploadGitHubReleaseMessage uploadAnAsset $upload_url appImageName "text/plain" uploadAnAsset $upload_url buildTime "text/plain" diff --git a/buildScripts/uploadReleaseDSL b/buildScripts/uploadGitHubReleaseDSL similarity index 100% rename from buildScripts/uploadReleaseDSL rename to buildScripts/uploadGitHubReleaseDSL diff --git a/buildScripts/uploadReleaseMessage b/buildScripts/uploadGitHubReleaseMessage similarity index 100% rename from buildScripts/uploadReleaseMessage rename to buildScripts/uploadGitHubReleaseMessage diff --git a/buildScripts/uploadImages b/buildScripts/uploadImages new file mode 100644 index 0000000..8941229 --- /dev/null +++ b/buildScripts/uploadImages @@ -0,0 +1,13 @@ +#!/bin/bash + +# This bash script uploads already existing pdf2htmlEX AppImage and Docker +# Images + +################ +# do the uploads + +./buildScripts/uploadGitHubRelease || { echo 'uploadGitHubRelease FAILED' ; exit 1 ; } + +./buildScripts/uploadDockerImage || { echo 'uploadDockerImage FAILED' ; exit 1 ; } + + diff --git a/buildScripts/versionEnvs b/buildScripts/versionEnvs index 0c11cf9..ccc0093 100755 --- a/buildScripts/versionEnvs +++ b/buildScripts/versionEnvs @@ -11,24 +11,24 @@ export FONTFORGE_VERSION=20170731 if [ -z "$PDF2HTMLEX_BRANCH" ]; then export PDF2HTMLEX_BRANCH="$(git rev-parse --abbrev-ref HEAD)" + if [ -z "$PDF2HTMLEX_BRANCH" ]; then + echo "" + read -p "Enter the pdf2htmlEX branch or version: " PDF2HTMLEX_BRANCH + echo "" + if [ -z "$PDF2HTMLEX_BRANCH" ]; then + echo "PDF2HTMLEX_BRANCH not set... so we can not build anything." + exit 1 + fi + fi fi export MACHINE_ARCH="$(uname -m)" export BUILD_TIME="$(date +%Y_%m_%d-%H_%M_%S)" -export DOCKER_FROM=ubuntu:18.04 - -export DOCKER_NAME="$DOCKER_USERNAME/pdf2htmlex:$PDF2HTMLEX_BRANCH-$BUILD_TIME" - -export APPIMAGE_NAME="pdf2htmlEX-$PDF2HTMLEX_BRANCH-$BUILD_TIME-$MACHINE_ARCH.AppImage" - echo "export POPPLER_VERSION=\"$POPPLER_VERSION\"" > buildScripts/reSourceVersionEnvs echo "export FONTFORGE_VERSION=\"$FONTFORGE_VERSION\"" >> buildScripts/reSourceVersionEnvs echo "export PDF2HTMLEX_BRANCH=\"$PDF2HTMLEX_BRANCH\"" >> buildScripts/reSourceVersionEnvs echo "export MACHINE_ARCH=\"$MACHINE_ARCH\"" >> buildScripts/reSourceVersionEnvs echo "export BUILD_TIME=\"$BUILD_TIME\"" >> buildScripts/reSourceVersionEnvs -echo "export DOCKER_FROM=\"$DOCKER_FROM\"" >> buildScripts/reSourceVersionEnvs -echo "export DOCKER_NAME=\"$DOCKER_NAME\"" >> buildScripts/reSourceVersionEnvs -echo "export APPIMAGE_NAME=\"$APPIMAGE_NAME\"" >> buildScripts/reSourceVersionEnvs