From 4ed07c08aec10281a07c5c73e78cc92d0f86b3a0 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 29 Oct 2024 20:30:51 +0100 Subject: [PATCH] new: [bitwarden,collabora,mongo,nextcloud,rocketchat] move ``upstream-versions`` to ``actions`` --- bitwarden/actions/upstream-versions | 41 ++++++++++++++++ collabora/actions/upstream-version-normalize | 16 +++++++ collabora/actions/upstream-versions | 41 ++++++++++++++++ collabora/hooks/upstream-versions | 49 -------------------- mongo/actions/upstream-versions | 42 +++++++++++++++++ mongo/hooks/upstream-versions | 36 -------------- nextcloud/actions/upstream-versions | 41 ++++++++++++++++ nextcloud/hooks/upstream-versions | 37 --------------- rocketchat/actions/upstream-versions | 40 ++++++++++++++++ 9 files changed, 221 insertions(+), 122 deletions(-) create mode 100755 bitwarden/actions/upstream-versions create mode 100755 collabora/actions/upstream-version-normalize create mode 100755 collabora/actions/upstream-versions delete mode 100755 collabora/hooks/upstream-versions create mode 100755 mongo/actions/upstream-versions delete mode 100755 mongo/hooks/upstream-versions create mode 100755 nextcloud/actions/upstream-versions delete mode 100755 nextcloud/hooks/upstream-versions create mode 100755 rocketchat/actions/upstream-versions diff --git a/bitwarden/actions/upstream-versions b/bitwarden/actions/upstream-versions new file mode 100755 index 0000000..af9ab78 --- /dev/null +++ b/bitwarden/actions/upstream-versions @@ -0,0 +1,41 @@ +#!/bin/bash +# compose: no-hooks + +## List upstream available versions in reverse chronological order +## +## These versions information will be the input for the version +## information usually used by the build process. +## +## A external query of upstream sources will be done. +## +## By default, limit should be 1 (the latest version) + +usage="$exname [-h|--help] [-l|--limit ]" + +version_limit=5 +while [ "$1" ]; do + case "$1" in + "--help"|"-h") + print_usage + exit 0 + ;; + "--limit"|"-l") + version_limit="$2" + shift + ;; + *) + err "Unexpected argument '$1'." + exit 1 + ;; + esac + shift +done + +set -e + +DOCKER_IMAGE_NAME=vaultwarden/server + +docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+-alpine" | + sort -rV | + cut -f 1 -d "-" | + head -n "$version_limit" diff --git a/collabora/actions/upstream-version-normalize b/collabora/actions/upstream-version-normalize new file mode 100755 index 0000000..eb136a2 --- /dev/null +++ b/collabora/actions/upstream-version-normalize @@ -0,0 +1,16 @@ +#!/bin/bash +# compose: no-hooks + +upstream_version="$1" +version="${upstream_version/./}" +read -r year_month major minor patch <<< ${version//./ } +if ! [ "${#patch}" == 1 ]; then + echo "Error: build number is not a single digit: '${patch}' (upstream: '${upstream_version}')" >&2 + exit 1 +fi +if [ "${#major}" -gt 2 ]; then + echo "Error: major number is more than 2 digits: '${major}' (upstream: '${upstream_version}')" >&2 + exit 1 +fi +major=$(printf "%02d" ${major}) +echo "${year_month}${major}.${minor}.${patch}" diff --git a/collabora/actions/upstream-versions b/collabora/actions/upstream-versions new file mode 100755 index 0000000..727e44e --- /dev/null +++ b/collabora/actions/upstream-versions @@ -0,0 +1,41 @@ +#!/bin/bash +# compose: no-hooks + +## List upstream available versions in reverse chronological order +## +## These versions information will be the input for the version +## information usually used by the build process. +## +## A external query of upstream sources will be done. +## +## By default, limit should be 1 (the latest version) + +usage="$exname [-h|--help] [-l|--limit ]" + +version_limit=5 +while [ "$1" ]; do + case "$1" in + "--help"|"-h") + print_usage + exit 0 + ;; + "--limit"|"-l") + version_limit="$2" + shift + ;; + *) + err "Unexpected argument '$1'." + exit 1 + ;; + esac + shift +done + +set -e + +DOCKER_IMAGE_NAME=collabora/code + +docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | + sort -rV | + cut -f 1 -d "-" | + head -n "${version_limit}" diff --git a/collabora/hooks/upstream-versions b/collabora/hooks/upstream-versions deleted file mode 100755 index 6d08d17..0000000 --- a/collabora/hooks/upstream-versions +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -## List upstream available versions in reverse chronological order -## -## These versions information will be the input for the version information -## usually used by the build process. -## A external query of upstream sources will be done. -## - -## This script is launched by ``charm upstream-versions`` and will receive these env variables -## -## -## VERSION_LIMIT ## limit number of version to read -## -## -## The script CWD will be the root of the charm directory -## - -DOCKER_IMAGE_NAME=collabora/code - -semver:normalize() { - local upstream_version="$1" - local version="${upstream_version/./}" - read -r year_month major minor patch <<< ${version//./ } - if ! [ "${#patch}" == 1 ]; then - echo "Error: build number is not a single digit: '${patch}' (upstream: '${upstream_version}')" >&2 - return 1 - fi - if [ "${#major}" -gt 2 ]; then - echo "Error: major number is more than 2 digits: '${major}' (upstream: '${upstream_version}')" >&2 - return 1 - fi - major=$(printf "%02d" ${major}) - echo "${year_month}${major}.${minor}.${patch}" -} - - -upstream:list() { - local limit=${1:-5} - docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "${limit}" -f "^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | - sort -rV | - cut -f 1 -d "-" -} - - -while read -r "upstream_version"; do - normalized_version=$(semver:normalize "${upstream_version}") || exit 1 - printf "%s %s\n" "$(semver:normalize "${upstream_version}")" "$upstream_version" -done < <(upstream:list "${VERSION_LIMIT}") diff --git a/mongo/actions/upstream-versions b/mongo/actions/upstream-versions new file mode 100755 index 0000000..546875a --- /dev/null +++ b/mongo/actions/upstream-versions @@ -0,0 +1,42 @@ +#!/bin/bash +# compose: no-hooks + +## List upstream available versions in reverse chronological order +## +## These versions information will be the input for the version +## information usually used by the build process. +## +## A external query of upstream sources will be done. +## +## By default, limit should be 1 (the latest version) + +usage="$exname [-h|--help] [-l|--limit ]" + +version_limit=5 +while [ "$1" ]; do + case "$1" in + "--help"|"-h") + print_usage + exit 0 + ;; + "--limit"|"-l") + version_limit="$2" + shift + ;; + *) + err "Unexpected argument '$1'." + exit 1 + ;; + esac + shift +done + +set -e +set -o pipefail + + +DOCKER_IMAGE_NAME=mongo + +docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+$" | + sort -rV | + head -n "$version_limit" diff --git a/mongo/hooks/upstream-versions b/mongo/hooks/upstream-versions deleted file mode 100755 index dbccfb6..0000000 --- a/mongo/hooks/upstream-versions +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -## List upstream available versions in reverse chronological order -## -## These versions information will be the input for the version information -## usually used by the build process. -## A external query of upstream sources will be done. -## - -## This script is launched by ``charm upstream-versions`` and will receive these env variables -## -## -## VERSION_LIMIT ## limit number of version to read -## -## -## The script CWD will be the root of the charm directory -## - -DOCKER_IMAGE_NAME=mongo - -semver:normalize() { - local upstream_version="$1" - echo "$upstream_version" -} - - -upstream:list() { - local limit=${1:-5} - docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "${limit}" -f "^[0-9]+\.[0-9]+\.[0-9]+$" | - sort -rV -} - - -while read -r "upstream_version"; do - printf "%s %s\n" "$(semver:normalize "${upstream_version}")" "$upstream_version" -done < <(upstream:list "${VERSION_LIMIT}") diff --git a/nextcloud/actions/upstream-versions b/nextcloud/actions/upstream-versions new file mode 100755 index 0000000..0e83ae3 --- /dev/null +++ b/nextcloud/actions/upstream-versions @@ -0,0 +1,41 @@ +#!/bin/bash +# compose: no-hooks + +## List upstream available versions in reverse chronological order +## +## These versions information will be the input for the version +## information usually used by the build process. +## +## A external query of upstream sources will be done. +## +## By default, limit should be 1 (the latest version) + +usage="$exname [-h|--help] [-l|--limit ]" + +version_limit=5 +while [ "$1" ]; do + case "$1" in + "--help"|"-h") + print_usage + exit 0 + ;; + "--limit"|"-l") + version_limit="$2" + shift + ;; + *) + err "Unexpected argument '$1'." + exit 1 + ;; + esac + shift +done + +set -e + +DOCKER_IMAGE_NAME=nextcloud + +docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+-apache" | + sort -rV | + cut -f 1 -d "-" | + head -n "$version_limit" diff --git a/nextcloud/hooks/upstream-versions b/nextcloud/hooks/upstream-versions deleted file mode 100755 index d869848..0000000 --- a/nextcloud/hooks/upstream-versions +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -## List upstream available versions in reverse chronological order -## -## These versions information will be the input for the version information -## usually used by the build process. -## A external query of upstream sources will be done. -## - -## This script is launched by ``charm upstream-versions`` and will receive these env variables -## -## -## VERSION_LIMIT ## limit number of version to read -## -## -## The script CWD will be the root of the charm directory -## - -DOCKER_IMAGE_NAME=nextcloud - -semver:normalize() { - local upstream_version="$1" - echo "$upstream_version" -} - - -upstream:list() { - local limit=${1:-5} - docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "${limit}" -f "^[0-9]+\.[0-9]+\.[0-9]+-apache" | - sort -rV | - cut -f 1 -d "-" -} - - -while read -r "upstream_version"; do - printf "%s %s\n" "$(semver:normalize "${upstream_version}")" "$upstream_version" -done < <(upstream:list "${VERSION_LIMIT}") diff --git a/rocketchat/actions/upstream-versions b/rocketchat/actions/upstream-versions new file mode 100755 index 0000000..0c45871 --- /dev/null +++ b/rocketchat/actions/upstream-versions @@ -0,0 +1,40 @@ +#!/bin/bash +# compose: no-hooks + +## List upstream available versions in reverse chronological order +## +## These versions information will be the input for the version +## information usually used by the build process. +## +## A external query of upstream sources will be done. +## +## By default, limit should be 1 (the latest version) + +usage="$exname [-h|--help] [-l|--limit ]" + +version_limit=5 +while [ "$1" ]; do + case "$1" in + "--help"|"-h") + print_usage + exit 0 + ;; + "--limit"|"-l") + version_limit="$2" + shift + ;; + *) + err "Unexpected argument '$1'." + exit 1 + ;; + esac + shift +done + +set -e + +DOCKER_IMAGE_NAME=rocketchat/rocket.chat + +docker-tags-fetch "$DOCKER_IMAGE_NAME" -l "20" -f "^[0-9]+\.[0-9]+\.[0-9]+$" | + sort -rV | + head -n "${version_limit}"