From c661b24764122f340f569b2b4dbdd20878cc0820 Mon Sep 17 00:00:00 2001 From: zokradonh Date: Wed, 10 Nov 2021 16:44:31 +0100 Subject: [PATCH] BugFix: incompatible version string --- .github/workflows/ci.yml | 24 ++++++++++++++++++++---- gh_output_dockertags.sh | 16 +++++++++------- version.sh | 16 ++++++++++++---- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46b7ba7..16233be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,12 @@ jobs: push: false tags: zokradonh/kopano_repo_helper context: repo + # We need this custom cache implementation here. buildx driver `docker-container` supports all + # kinds of caching mechanisms but it is always trying to pull images from a registry during build. + # It is never loading from local `docker images` that we use for our `kopano_repo_helper`. + # Therefore, we use buildx driver `docker` which mimics plain old docker with full `docker images` support + # but it lacks a lot of caching options. Since there is no plan to build for different platforms + # we can stick with driver `docker`. - name: Cache Kopano APT Packages if: steps.apt-cache.outputs.cache-hit != 'true' run: | @@ -79,21 +85,31 @@ jobs: - name: Use Kopano APT Packages from cache if: steps.apt-cache.outputs.cache-hit == 'true' run: docker load /tmp/.kopano-repo-helper-cache/kopano_repo_helper.tar - - uses: ./.github/actions/build-component + # - name: Prepare Docker Layer Cache # TODO cache by old registry image (with BUILDKIT_INLINE_CACHE) or `docker save` + # uses: actions/cache@v2 + # with: + # path: /tmp/.layer-cache + # key: ${{ runner.os }}-buildx-${{ github.sha }} + # restore-keys: ${{ runner.os }}-buildx- # also allow old caches. Docker decides if the old cache is of any use. + - name: Build base + uses: ./.github/actions/build-component with: push: false component: base - - uses: ./.github/actions/build-component + - name: Build core + uses: ./.github/actions/build-component with: push: false component: core tags: ${{ steps.kopano-versions.outputs.core_version_tags }} - - uses: ./.github/actions/build-component + - name: Build webapp + uses: ./.github/actions/build-component with: push: false component: webapp tags: ${{ steps.kopano-versions.outputs.webapp_version_tags }} - - uses: ./.github/actions/build-component + - name: Build zpush + uses: ./.github/actions/build-component with: push: false component: zpush diff --git a/gh_output_dockertags.sh b/gh_output_dockertags.sh index bb64fe6..bc2ef87 100755 --- a/gh_output_dockertags.sh +++ b/gh_output_dockertags.sh @@ -2,23 +2,25 @@ if [ $# -eq 0 ] then - echo "Usage: version_dockertags.sh [] [] []" + echo "Usage: version_dockertags.sh [] [] []" fi function version_to_tags { - version=$1 - result=$version + repo=$1 + component=$2 + version=$3 + result="$repo/kopano_$component:$version" while [[ $version == *.* ]]; do \ version=${version%.*} ; \ - result="$result,$version" + result="$result,$repo/kopano_$component:$version" done echo $result } -version="$( ./version.sh $@ )" +version="$( ./version.sh ${@:2} )" -echo "::set-output name=$1_version::$version" -echo "::set-output name=$1_version_tags::$(version_to_tags $version)" +echo "::set-output name=$2_version::$version" +echo "::set-output name=$2_version_tags::$(version_to_tags $1 $2 $version)" diff --git a/version.sh b/version.sh index eda6fcc..6d64009 100755 --- a/version.sh +++ b/version.sh @@ -8,6 +8,10 @@ if ! command -v jq > /dev/null; then exit 1 fi +function conform_to_docker { + echo $1 | tr -c '[:alnum:]._\n\r-' '-' +} + function finish { if [ -e "$tmpfile" ]; then rm "$tmpfile" @@ -42,7 +46,8 @@ core) KOPANO_CORE_REPOSITORY_URL=${KOPANO_CORE_REPOSITORY_URL:-""} if [[ $KOPANO_CORE_REPOSITORY_URL == http* ]]; then version=$(curl --netrc-file ./apt_auth.conf --netrc-optional -m 1 -s -S -L "$KOPANO_CORE_REPOSITORY_URL"/Packages | grep -A2 "Package: kopano-server-packages") - echo "${version##* }" + version=$(conform_to_docker $version) + echo $(conform_to_docker ${version##* }) exit fi ;; @@ -50,7 +55,8 @@ webapp) KOPANO_WEBAPP_REPOSITORY_URL=${KOPANO_WEBAPP_REPOSITORY_URL:-""} if [[ $KOPANO_WEBAPP_REPOSITORY_URL == http* ]]; then version=$(curl --netrc-file ./apt_auth.conf --netrc-optional -m 1 -s -S -L "$KOPANO_WEBAPP_REPOSITORY_URL"/Packages | grep -m1 -A1 "Package: kopano-webapp") - echo "${version##* }" + version=$(conform_to_docker $version) + echo $(conform_to_docker ${version##* }) exit fi ;; @@ -58,7 +64,7 @@ zpush) KOPANO_ZPUSH_REPOSITORY_URL=${KOPANO_ZPUSH_REPOSITORY_URL:-"https://download.kopano.io/zhub/z-push:/final/Debian_10/"} if [[ $KOPANO_ZPUSH_REPOSITORY_URL == http* ]]; then version=$(curl -m 1 -s -S -L "$KOPANO_ZPUSH_REPOSITORY_URL"/Packages | grep -m2 -A2 "Package: z-push-kopano") - echo "${version##* }" + echo $(conform_to_docker ${version##* }) exit fi ;; @@ -66,7 +72,7 @@ meet) KOPANO_MEET_REPOSITORY_URL=${KOPANO_MEET_REPOSITORY_URL:-""} if [[ $KOPANO_MEET_REPOSITORY_URL == http* ]]; then version=$(curl --netrc-file ./apt_auth.conf --netrc-optional -m 1 -s -S -L "$KOPANO_MEET_REPOSITORY_URL"/Packages | grep -A2 "Package: kopano-meet-packages") - echo "${version##* }" + echo $(conform_to_docker ${version##* }) exit fi ;; @@ -87,4 +93,6 @@ if [ ${#versiontemp} -lt 2 ]; then exit 1 fi +currentVersion=$(conform_to_docker $currentVersion) + echo "$currentVersion"