From 26542cb74daf7a111a9398efcf4c2f8fac124c1e Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 16:13:03 +0200 Subject: [PATCH 01/22] Reworks the way we handle Nc versions. --- .gitlab-ci.yml | 80 ++++++++++++++++++++++++++++++++++++------------- base/Dockerfile | 7 +++-- ci/functions.sh | 27 +++++++++++++++++ fullversion.sh | 22 -------------- fullversions | 2 -- web/Dockerfile | 4 +-- 6 files changed, 93 insertions(+), 49 deletions(-) create mode 100644 ci/functions.sh delete mode 100755 fullversion.sh delete mode 100644 fullversions diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aef20c3..d70348b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,8 +2,12 @@ variables: GIT_SUBMODULE_STRATEGY: recursive DOCKER_HUB_REPO: libresh/nextcloud -.compute_long_version: &compute_long_version - - export LONG_VERSION=`cat ${CI_PROJECT_DIR}/fullversions | grep $VERSION` +.compute_versions: &compute_versions + - source ./ci/functions.sh + - patch_version + - echo $MARKETTING_VERSION + - echo $MINOR_VERSION + - echo $PATCH_VERSION .test: image: @@ -13,49 +17,85 @@ variables: DESTINATION_BASE: "--no-push" DESTINATION_FR: "--no-push" DESTINATION_WEB: "--no-push" + before_script: + - *compute_version script: - - *compute_long_version - - echo $LONG_VERSION - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - export CONTEXT=${CI_PROJECT_DIR}/base - cd ${CONTEXT} - - /kaniko/executor --context ${CONTEXT} ${DESTINATION_BASE} --build-arg VERSION=$LONG_VERSION + - /kaniko/executor --context ${CONTEXT} ${DESTINATION_BASE} --build-arg MARKETTING_VERSION=$MARKETTING_VERSION --build-arg PATCH_VERSION=$PATCH_VERSION - export CONTEXT=${CI_PROJECT_DIR}/web - cd ${CONTEXT} - - /kaniko/executor --context ${CONTEXT} ${DESTINATION_WEB} --build-arg VERSION=$LONG_VERSION + - /kaniko/executor --context ${CONTEXT} ${DESTINATION_WEB} --build-arg MINOR_VERSION=$MINOR_VERSION except: - master -test-v22: +test-alpha: + extends: .test + variables: + LINE: "alpha" + +test-beta: extends: .test variables: - VERSION: "22.2" + LINE: "beta" -test-v23: +test-stable: extends: .test variables: - VERSION: "23.0" + LINE: "stable" .push: extends: .test before_script: - - *compute_long_version + - *compute_version - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" - - export DATE=`date "+%Y-%m-%d"` - - export DESTINATION_BASE="${DESTINATION_PREFIX}:${VERSION} ${DESTINATION_PREFIX}:${VERSION}-${DATE}" - - export DESTINATION_BASE="${DESTINATION_BASE} ${DESTINATION_PREFIX}:${LONG_VERSION} ${DESTINATION_PREFIX}:${LONG_VERSION}-${DATE}" - - export DESTINATION_WEB="${DESTINATION_PREFIX}:${VERSION}-web ${DESTINATION_PREFIX}:${VERSION}-web-${DATE}" - - export DESTINATION_WEB="${DESTINATION_WEB} ${DESTINATION_PREFIX}:${LONG_VERSION}-web ${DESTINATION_PREFIX}:${LONG_VERSION}-web-${DATE}" + - export DATE=`"+%Y-%m-%d_%H-%M"` + - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION} ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}" + - export DESTINATION_WEB="${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${DATE}" except: [] only: - master -push-v22: +push-alpha: + extends: .push + variables: + LINE: "alpha" + +push-beta: + extends: .push + variables: + LINE: "beta" + +push-stable: + extends: .push + variables: + LINE: "stable" + +.push-feature: + extends: .test + before_script: + - *compute_version + - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" + - export DATE=`"+%Y-%m-%d_%H-%M"` + - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" + - export DESTINATION_WEB="${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" + - export MINOR_VERSION=`echo ${MINOR_VERSION}-${CI_COMMIT_BRANCH}` + except: [] + only: + - /^feature-*$/ + +push-feature-alpha: + extends: .push + variables: + LINE: "alpha" + +push-feature-beta: extends: .push variables: - VERSION: "22.2" + LINE: "beta" -push-v23: +push-feature-stable: extends: .push variables: - VERSION: "23.0" + LINE: "stable" \ No newline at end of file diff --git a/base/Dockerfile b/base/Dockerfile index 0e3ffe8..3b5d421 100644 --- a/base/Dockerfile +++ b/base/Dockerfile @@ -1,13 +1,14 @@ -ARG VERSION +ARG MARKETTING_VERSION +ARG PATCH_VERSION FROM alpine as apps RUN apk add --no-cache jq curl bash patch COPY apps /apps WORKDIR /apps -ARG VERSION RUN ./install.sh RUN rm ./install.sh ./install-list -FROM nextcloud:${VERSION}-fpm-alpine +FROM nextcloud:${MARKETTING_VERSION}-fpm-alpine +ENV VERSION $PATCH_VERSION RUN apk add --no-cache patch jq COPY redis.ini /usr/local/etc/php/conf.d/ COPY opcache-recommended.ini /usr/local/etc/php/conf.d/opcache.ini diff --git a/ci/functions.sh b/ci/functions.sh new file mode 100644 index 0000000..fa82964 --- /dev/null +++ b/ci/functions.sh @@ -0,0 +1,27 @@ + +function marketting_version() { + export CURRENT_MARKETTING=`curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | sort -uV | tail -1 | cut -d\. -f1` + if [ "$LINE" = "alpha" ]; then + export MARKETTING_VERSION=$CURRENT_MARKETTING + elif [ "$LINE" = "beta" ]; then + export MARKETTING_VERSION=$(($CURRENT_MARKETTING - 1)) + else + export MARKETTING_VERSION=$(($CURRENT_MARKETTING - 2)) + fi +} + +function minor_version() { + marketting_version + curl https://api.github.com/repos/nextcloud/server/tags > /tmp/tags + curl https://api.github.com/repos/nextcloud/server/tags?page=2 >> /tmp/tags + curl https://api.github.com/repos/nextcloud/server/tags?page=3 >> /tmp/tags + export MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` + + +} + +function patch_version() { + minor_version + export PATCH_NUMBER=`curl https://raw.githubusercontent.com/nextcloud/server/v${MINOR_VERSION}/version.php | grep '$OC_Version =' | cut -d, -f4 | cut -d] -f1 | xargs` + export PATCH_VERSION=`echo "$MINOR_VERSION.$PATCH_NUMBER"` +} diff --git a/fullversion.sh b/fullversion.sh deleted file mode 100755 index e1c3315..0000000 --- a/fullversion.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -min_version='17.0' - -# version_greater_or_equal A B returns whether A >= B -function version_greater_or_equal() { - [[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" || "$1" == "$2" ]]; -} - -fullversions=( $( curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| \ - grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | \ - grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | \ - sort -urV ) ) -versions=( $( printf '%s\n' "${fullversions[@]}" | cut -d. -f1-2 | sort -urV ) ) -for version in "${versions[@]}"; do - fullversion="$( printf '%s\n' "${fullversions[@]}" | grep -E "^$version" | head -1 )" - - if version_greater_or_equal "$version" "$min_version"; then - echo "$fullversion" - fi -done - diff --git a/fullversions b/fullversions deleted file mode 100644 index 52fe2c7..0000000 --- a/fullversions +++ /dev/null @@ -1,2 +0,0 @@ -22.2.10 -23.0.7 diff --git a/web/Dockerfile b/web/Dockerfile index f021c2b..9a8abd8 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,5 +1,5 @@ -ARG VERSION -FROM libresh/nextcloud:${VERSION} as builder +ARG MINOR_VERSION +FROM libresh/nextcloud:${MINOR_VERSION} as builder FROM nginx:alpine COPY --from=builder /usr/src/nextcloud /usr/src/nextcloud COPY default.conf.template /etc/nginx/templates/ -- GitLab From 6a82f3a6cb8e9f5c492ecc37947e3add9be53bf7 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 16:17:01 +0200 Subject: [PATCH 02/22] f --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d70348b..78156a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ variables: DESTINATION_FR: "--no-push" DESTINATION_WEB: "--no-push" before_script: - - *compute_version + - *compute_versions script: - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - export CONTEXT=${CI_PROJECT_DIR}/base @@ -48,7 +48,7 @@ test-stable: .push: extends: .test before_script: - - *compute_version + - *compute_versions - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" - export DATE=`"+%Y-%m-%d_%H-%M"` - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION} ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}" @@ -75,7 +75,7 @@ push-stable: .push-feature: extends: .test before_script: - - *compute_version + - *compute_versions - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" - export DATE=`"+%Y-%m-%d_%H-%M"` - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" -- GitLab From 1c0c4b1529146b0512931397ebfeb032f4108a75 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:13:43 +0200 Subject: [PATCH 03/22] f --- .gitlab-ci.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 78156a3..20ee714 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,11 +3,22 @@ variables: DOCKER_HUB_REPO: libresh/nextcloud .compute_versions: &compute_versions + + +prepare: + stage: prepare + image: + name: debian + entrypoint: [""] + script: - source ./ci/functions.sh - patch_version - - echo $MARKETTING_VERSION - - echo $MINOR_VERSION - - echo $PATCH_VERSION + - echo "MARKETTING_VERSION=$MARKETTING_VERSION" > build.env + - echo "MINOR_VERSION=$MINOR_VERSION" >> build.env + - echo "PATCH_VERSION=$PATCH_VERSION" >> build.env + artifacts: + reports: + dotenv: build.env .test: image: @@ -17,9 +28,12 @@ variables: DESTINATION_BASE: "--no-push" DESTINATION_FR: "--no-push" DESTINATION_WEB: "--no-push" - before_script: - - *compute_versions + dependencies: + - prepare script: + - echo $MARKETTING_VERSION + - echo $MINOR_VERSION + - echo $PATCH_VERSION - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - export CONTEXT=${CI_PROJECT_DIR}/base - cd ${CONTEXT} -- GitLab From 09ea54fd580367accdebcdd51d9717265cbf63db Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:15:05 +0200 Subject: [PATCH 04/22] f --- .gitlab-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20ee714..c650c13 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -61,8 +61,9 @@ test-stable: .push: extends: .test + dependencies: + - prepare before_script: - - *compute_versions - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" - export DATE=`"+%Y-%m-%d_%H-%M"` - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION} ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}" @@ -88,8 +89,9 @@ push-stable: .push-feature: extends: .test + dependencies: + - prepare before_script: - - *compute_versions - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" - export DATE=`"+%Y-%m-%d_%H-%M"` - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" -- GitLab From 2aa00b7f75de317a2d5e7559e25f45d47e83ee81 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:15:32 +0200 Subject: [PATCH 05/22] f --- .gitlab-ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c650c13..0bf7745 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,9 +2,6 @@ variables: GIT_SUBMODULE_STRATEGY: recursive DOCKER_HUB_REPO: libresh/nextcloud -.compute_versions: &compute_versions - - prepare: stage: prepare image: -- GitLab From 738b391ea87b9817488fc8a811c5095e2aa0846c Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:16:15 +0200 Subject: [PATCH 06/22] f --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0bf7745..ea62cd3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ variables: DOCKER_HUB_REPO: libresh/nextcloud prepare: - stage: prepare + stage: .pre image: name: debian entrypoint: [""] -- GitLab From de4b6c5c672c977727a0b65e8a4bfcff923e8400 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:17:45 +0200 Subject: [PATCH 07/22] f --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea62cd3..a54d60e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ variables: prepare: stage: .pre image: - name: debian + name: registry.gitlab.com/gitlab-ci-utils/curl-jq:latest entrypoint: [""] script: - source ./ci/functions.sh -- GitLab From 768d4280579787a85ff7011148ed0c6be2bdaff0 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:40:36 +0200 Subject: [PATCH 08/22] f --- .gitlab-ci.yml | 16 ++++++++++++---- ci/functions.sh | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a54d60e..bd36906 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,9 +10,15 @@ prepare: script: - source ./ci/functions.sh - patch_version - - echo "MARKETTING_VERSION=$MARKETTING_VERSION" > build.env - - echo "MINOR_VERSION=$MINOR_VERSION" >> build.env - - echo "PATCH_VERSION=$PATCH_VERSION" >> build.env + - echo "ALPHA_MARKETTING_VERSION=$ALPHA_MARKETTING_VERSION" > build.env + - echo "BETA_MARKETTING_VERSION=$BETA_MARKETTING_VERSION" >> build.env + - echo "STABLE_MARKETTING_VERSION=$STABLE_MARKETTING_VERSION" >> build.env + - echo "ALPHA_MINOR_VERSION=$ALPHA_MINOR_VERSION" >> build.env + - echo "BETA_MINOR_VERSION=$BETA_MINOR_VERSION" >> build.env + - echo "STABLE_MINOR_VERSION=$STABLE_MINOR_VERSION" >> build.env + - echo "ALPHA_PATCH_VERSION=$ALPHA_PATCH_VERSION" >> build.env + - echo "BETA_PATCH_VERSION=$BETA_PATCH_VERSION" >> build.env + - echo "STABLE_PATCH_VERSION=$STABLE_PATCH_VERSION" >> build.env artifacts: reports: dotenv: build.env @@ -28,10 +34,10 @@ prepare: dependencies: - prepare script: + - source ./ci/functions.sh && compute_versions - echo $MARKETTING_VERSION - echo $MINOR_VERSION - echo $PATCH_VERSION - - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - export CONTEXT=${CI_PROJECT_DIR}/base - cd ${CONTEXT} - /kaniko/executor --context ${CONTEXT} ${DESTINATION_BASE} --build-arg MARKETTING_VERSION=$MARKETTING_VERSION --build-arg PATCH_VERSION=$PATCH_VERSION @@ -65,6 +71,7 @@ test-stable: - export DATE=`"+%Y-%m-%d_%H-%M"` - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION} ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}" - export DESTINATION_WEB="${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${DATE}" + - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json except: [] only: - master @@ -94,6 +101,7 @@ push-stable: - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" - export DESTINATION_WEB="${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" - export MINOR_VERSION=`echo ${MINOR_VERSION}-${CI_COMMIT_BRANCH}` + - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json except: [] only: - /^feature-*$/ diff --git a/ci/functions.sh b/ci/functions.sh index fa82964..51e861a 100644 --- a/ci/functions.sh +++ b/ci/functions.sh @@ -1,13 +1,6 @@ function marketting_version() { - export CURRENT_MARKETTING=`curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | sort -uV | tail -1 | cut -d\. -f1` - if [ "$LINE" = "alpha" ]; then - export MARKETTING_VERSION=$CURRENT_MARKETTING - elif [ "$LINE" = "beta" ]; then - export MARKETTING_VERSION=$(($CURRENT_MARKETTING - 1)) - else - export MARKETTING_VERSION=$(($CURRENT_MARKETTING - 2)) - fi + export CURRENT_MARKETTING_VERSION=`curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | sort -uV | tail -1 | cut -d\. -f1` } function minor_version() { @@ -15,13 +8,38 @@ function minor_version() { curl https://api.github.com/repos/nextcloud/server/tags > /tmp/tags curl https://api.github.com/repos/nextcloud/server/tags?page=2 >> /tmp/tags curl https://api.github.com/repos/nextcloud/server/tags?page=3 >> /tmp/tags - export MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` + export ALPHA_MARKETTING_VERSION=$CURRENT_MARKETTING + export BETA_MARKETTING_VERSION=$(($CURRENT_MARKETTING - 1)) + export STABLE_MARKETTING_VERSION=$(($CURRENT_MARKETTING - 2)) + export ALPHA_MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${ALPHA_MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` + export BETA_MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${ALPHA_MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` + export STABLE_MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${ALPHA_MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` } function patch_version() { minor_version - export PATCH_NUMBER=`curl https://raw.githubusercontent.com/nextcloud/server/v${MINOR_VERSION}/version.php | grep '$OC_Version =' | cut -d, -f4 | cut -d] -f1 | xargs` - export PATCH_VERSION=`echo "$MINOR_VERSION.$PATCH_NUMBER"` + export ALPHA_PATCH_NUMBER=`curl https://raw.githubusercontent.com/nextcloud/server/v${ALPHA_MINOR_VERSION}/version.php | grep '$OC_Version =' | cut -d, -f4 | cut -d] -f1 | xargs` + export ALPHA_PATCH_VERSION=`echo "$ALPHA_MINOR_VERSION.$ALPHA_PATCH_NUMBER"` + export BETA_PATCH_NUMBER=`curl https://raw.githubusercontent.com/nextcloud/server/v${BETA_MINOR_VERSION}/version.php | grep '$OC_Version =' | cut -d, -f4 | cut -d] -f1 | xargs` + export BETA_PATCH_VERSION=`echo "$BETA_MINOR_VERSION.$BETA_PATCH_NUMBER"` + export STABLE_PATCH_NUMBER=`curl https://raw.githubusercontent.com/nextcloud/server/v${STABLE_MINOR_VERSION}/version.php | grep '$OC_Version =' | cut -d, -f4 | cut -d] -f1 | xargs` + export STABLE_PATCH_VERSION=`echo "$STABLE_MINOR_VERSION.$STABLE_PATCH_NUMBER"` +} + +function compute_versions() { + if [ "$LINE" = "alpha" ]; then + export MARKETTING_VERSION=$ALPHA_MARKETTING_VERSION + export MINOR_VERSION=$ALPHA_MARKETTING_VERSION + export PATCH_VERSION=$ALPHA_MARKETTING_VERSION + elif [ "$LINE" = "beta" ]; then + export MARKETTING_VERSION=$BETA_MARKETTING_VERSION + export MINOR_VERSION=$BETA_MARKETTING_VERSION + export PATCH_VERSION=$BETA_MARKETTING_VERSION + else + export MARKETTING_VERSION=$STABLE_MARKETTING_VERSION + export MINOR_VERSION=$STABLE_MARKETTING_VERSION + export PATCH_VERSION=$STABLE_MARKETTING_VERSION + fi } -- GitLab From 0e5f8d1021755c65a87db4667afa0e21ec7eaf99 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:42:18 +0200 Subject: [PATCH 09/22] f --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bd36906..e4e5476 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,9 @@ prepare: dependencies: - prepare script: - - source ./ci/functions.sh && compute_versions + - source ./ci/functions.sh + - compute_versions + - echo $STABLE_PATCH_VERSION - echo $MARKETTING_VERSION - echo $MINOR_VERSION - echo $PATCH_VERSION -- GitLab From 9145ea06d6ccb9a5409c6abaaf6eeddc0e2250c4 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:44:57 +0200 Subject: [PATCH 10/22] f --- ci/functions.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ci/functions.sh b/ci/functions.sh index 51e861a..4e23714 100644 --- a/ci/functions.sh +++ b/ci/functions.sh @@ -31,15 +31,15 @@ function patch_version() { function compute_versions() { if [ "$LINE" = "alpha" ]; then export MARKETTING_VERSION=$ALPHA_MARKETTING_VERSION - export MINOR_VERSION=$ALPHA_MARKETTING_VERSION - export PATCH_VERSION=$ALPHA_MARKETTING_VERSION + export MINOR_VERSION=$ALPHA_MINOR_VERSION + export PATCH_VERSION=$ALPHA_PATCH_VERSION elif [ "$LINE" = "beta" ]; then export MARKETTING_VERSION=$BETA_MARKETTING_VERSION - export MINOR_VERSION=$BETA_MARKETTING_VERSION - export PATCH_VERSION=$BETA_MARKETTING_VERSION + export MINOR_VERSION=$BETA_MINOR_VERSION + export PATCH_VERSION=$BETA_PATCH_VERSION else export MARKETTING_VERSION=$STABLE_MARKETTING_VERSION - export MINOR_VERSION=$STABLE_MARKETTING_VERSION - export PATCH_VERSION=$STABLE_MARKETTING_VERSION + export MINOR_VERSION=$STABLE_MINOR_VERSION + export PATCH_VERSION=$STABLE_PATCH_VERSION fi } -- GitLab From 41854faf7bfd6672a7fb840ffe423dd9c5cf4ee1 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:46:49 +0200 Subject: [PATCH 11/22] f --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e4e5476..0777682 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,7 +36,9 @@ prepare: script: - source ./ci/functions.sh - compute_versions - - echo $STABLE_PATCH_VERSION + - echo $STABLE_MARKETTING_VERSION + - echo $ALPHA_MARKETTING_VERSION + - echo $BETA_MARKETTING_VERSION - echo $MARKETTING_VERSION - echo $MINOR_VERSION - echo $PATCH_VERSION -- GitLab From 3b4cf4e9c25dd8e58aaff7a9c98cf6403f5f3443 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:50:19 +0200 Subject: [PATCH 12/22] f --- ci/functions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/functions.sh b/ci/functions.sh index 4e23714..529be72 100644 --- a/ci/functions.sh +++ b/ci/functions.sh @@ -9,9 +9,9 @@ function minor_version() { curl https://api.github.com/repos/nextcloud/server/tags?page=2 >> /tmp/tags curl https://api.github.com/repos/nextcloud/server/tags?page=3 >> /tmp/tags - export ALPHA_MARKETTING_VERSION=$CURRENT_MARKETTING - export BETA_MARKETTING_VERSION=$(($CURRENT_MARKETTING - 1)) - export STABLE_MARKETTING_VERSION=$(($CURRENT_MARKETTING - 2)) + export ALPHA_MARKETTING_VERSION=$CURRENT_MARKETTING_VERSION + export BETA_MARKETTING_VERSION=$(($CURRENT_MARKETTING_VERSION - 1)) + export STABLE_MARKETTING_VERSION=$(($CURRENT_MARKETTING_VERSION - 2)) export ALPHA_MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${ALPHA_MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` export BETA_MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${ALPHA_MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` -- GitLab From c26af87b024d0e27dd6d1f73ea23bf701273a59a Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:55:42 +0200 Subject: [PATCH 13/22] f --- base/apps/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/apps/install.sh b/base/apps/install.sh index d5f4d59..b0e379f 100755 --- a/base/apps/install.sh +++ b/base/apps/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -eux -curl -Ls https://apps.nextcloud.com/api/v1/platform/${VERSION}/apps.json > /tmp/apps.json +curl -Ls https://apps.nextcloud.com/api/v1/platform/${PATCH_VERSION}/apps.json > /tmp/apps.json function download_link() { cat /tmp/apps.json | jq '.[] | select(.id == "'$1'") | .releases | map(select(.version|test("alpha|beta|rc|RC|build")|not)) | sort_by(.version | split(".") | map(tonumber))[-1] | .download' -- GitLab From eca753a140fcfaf1c65aee8c3f5a116d788987b5 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 17:58:00 +0200 Subject: [PATCH 14/22] f --- .gitlab-ci.yml | 3 --- base/Dockerfile | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0777682..dca4e26 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,9 +36,6 @@ prepare: script: - source ./ci/functions.sh - compute_versions - - echo $STABLE_MARKETTING_VERSION - - echo $ALPHA_MARKETTING_VERSION - - echo $BETA_MARKETTING_VERSION - echo $MARKETTING_VERSION - echo $MINOR_VERSION - echo $PATCH_VERSION diff --git a/base/Dockerfile b/base/Dockerfile index 3b5d421..f828aa2 100644 --- a/base/Dockerfile +++ b/base/Dockerfile @@ -4,6 +4,7 @@ FROM alpine as apps RUN apk add --no-cache jq curl bash patch COPY apps /apps WORKDIR /apps +ARG PATCH_VERSION RUN ./install.sh RUN rm ./install.sh ./install-list -- GitLab From 3710e4b84b906656644f451d56c5e7ebf3301f6c Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 18:01:30 +0200 Subject: [PATCH 15/22] f --- .gitlab-ci.yml | 2 +- base/Dockerfile | 2 +- base/apps/install.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dca4e26..faf207f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,7 +41,7 @@ prepare: - echo $PATCH_VERSION - export CONTEXT=${CI_PROJECT_DIR}/base - cd ${CONTEXT} - - /kaniko/executor --context ${CONTEXT} ${DESTINATION_BASE} --build-arg MARKETTING_VERSION=$MARKETTING_VERSION --build-arg PATCH_VERSION=$PATCH_VERSION + - /kaniko/executor --context ${CONTEXT} ${DESTINATION_BASE} --build-arg MARKETTING_VERSION=$MARKETTING_VERSION --build-arg MINOR_VERSION=$MINOR_VERSION --build-arg PATCH_VERSION=$PATCH_VERSION - export CONTEXT=${CI_PROJECT_DIR}/web - cd ${CONTEXT} - /kaniko/executor --context ${CONTEXT} ${DESTINATION_WEB} --build-arg MINOR_VERSION=$MINOR_VERSION diff --git a/base/Dockerfile b/base/Dockerfile index f828aa2..8c0def9 100644 --- a/base/Dockerfile +++ b/base/Dockerfile @@ -4,7 +4,7 @@ FROM alpine as apps RUN apk add --no-cache jq curl bash patch COPY apps /apps WORKDIR /apps -ARG PATCH_VERSION +ARG MINOR_VERSION RUN ./install.sh RUN rm ./install.sh ./install-list diff --git a/base/apps/install.sh b/base/apps/install.sh index b0e379f..fed8126 100755 --- a/base/apps/install.sh +++ b/base/apps/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -eux -curl -Ls https://apps.nextcloud.com/api/v1/platform/${PATCH_VERSION}/apps.json > /tmp/apps.json +curl -Ls https://apps.nextcloud.com/api/v1/platform/${MINOR_VERSION}/apps.json > /tmp/apps.json function download_link() { cat /tmp/apps.json | jq '.[] | select(.id == "'$1'") | .releases | map(select(.version|test("alpha|beta|rc|RC|build")|not)) | sort_by(.version | split(".") | map(tonumber))[-1] | .download' -- GitLab From bf5dbb4fae38acefa090a81cdea5bbb9c6f68d63 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 18:03:33 +0200 Subject: [PATCH 16/22] f --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index faf207f..4d15d4b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,7 +44,7 @@ prepare: - /kaniko/executor --context ${CONTEXT} ${DESTINATION_BASE} --build-arg MARKETTING_VERSION=$MARKETTING_VERSION --build-arg MINOR_VERSION=$MINOR_VERSION --build-arg PATCH_VERSION=$PATCH_VERSION - export CONTEXT=${CI_PROJECT_DIR}/web - cd ${CONTEXT} - - /kaniko/executor --context ${CONTEXT} ${DESTINATION_WEB} --build-arg MINOR_VERSION=$MINOR_VERSION + - /kaniko/executor --context ${CONTEXT} ${DESTINATION_WEB} --build-arg MINOR_VERSION=$MINOR_WEB_VERSION except: - master @@ -72,6 +72,7 @@ test-stable: - export DATE=`"+%Y-%m-%d_%H-%M"` - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION} ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}" - export DESTINATION_WEB="${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${DATE}" + - export MINOR_WEB_VERSION=$MINOR_WEB_VERSION - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json except: [] only: @@ -101,7 +102,7 @@ push-stable: - export DATE=`"+%Y-%m-%d_%H-%M"` - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" - export DESTINATION_WEB="${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" - - export MINOR_VERSION=`echo ${MINOR_VERSION}-${CI_COMMIT_BRANCH}` + - export MINOR_WEB_VERSION=`echo ${MINOR_VERSION}-${CI_COMMIT_BRANCH}` - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json except: [] only: -- GitLab From 9e9b413d3897a74c0ed0acbd6132a0c4fef6ce15 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 18:09:50 +0200 Subject: [PATCH 17/22] f --- .gitlab-ci.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4d15d4b..126d370 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,6 +33,13 @@ prepare: DESTINATION_WEB: "--no-push" dependencies: - prepare + before_script: + - source ./ci/functions.sh + - compute_versions + - echo $MARKETTING_VERSION + - echo $MINOR_VERSION + - echo $PATCH_VERSION + - export MINOR_WEB_VERSION=$MINOR_VERSION script: - source ./ci/functions.sh - compute_versions @@ -68,11 +75,16 @@ test-stable: dependencies: - prepare before_script: + - source ./ci/functions.sh + - compute_versions + - echo $MARKETTING_VERSION + - echo $MINOR_VERSION + - echo $PATCH_VERSION + - export MINOR_WEB_VERSION=$MINOR_VERSION - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" - export DATE=`"+%Y-%m-%d_%H-%M"` - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION} ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}" - export DESTINATION_WEB="${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${DATE}" - - export MINOR_WEB_VERSION=$MINOR_WEB_VERSION - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json except: [] only: @@ -98,6 +110,11 @@ push-stable: dependencies: - prepare before_script: + - source ./ci/functions.sh + - compute_versions + - echo $MARKETTING_VERSION + - echo $MINOR_VERSION + - echo $PATCH_VERSION - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" - export DATE=`"+%Y-%m-%d_%H-%M"` - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" -- GitLab From 91c99088b9ec9c84d249db320103ac2913a29733 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Jul 2022 18:14:30 +0200 Subject: [PATCH 18/22] f --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 126d370..5a4c8b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,6 +54,8 @@ prepare: - /kaniko/executor --context ${CONTEXT} ${DESTINATION_WEB} --build-arg MINOR_VERSION=$MINOR_WEB_VERSION except: - master + - /^feature-*$/ + test-alpha: extends: .test -- GitLab From e63326a8629919ce10cacebb32dbcf4a10749f84 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Mon, 1 Aug 2022 18:08:40 +0200 Subject: [PATCH 19/22] f --- .gitignore | 3 +- .gitlab-ci.yml | 128 +++++------------------------------------------- ci/functions | 58 ++++++++++++++++++++++ ci/functions.sh | 45 ----------------- current_version | 1 + fr/Dockerfile | 3 -- web/Dockerfile | 4 +- 7 files changed, 75 insertions(+), 167 deletions(-) create mode 100644 ci/functions delete mode 100644 ci/functions.sh create mode 100644 current_version delete mode 100644 fr/Dockerfile diff --git a/.gitignore b/.gitignore index 80bd12f..26f9f5e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -base/apps/apps \ No newline at end of file +base/apps/apps +build.env \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5a4c8b5..d34c501 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,136 +8,32 @@ prepare: name: registry.gitlab.com/gitlab-ci-utils/curl-jq:latest entrypoint: [""] script: - - source ./ci/functions.sh - - patch_version - - echo "ALPHA_MARKETTING_VERSION=$ALPHA_MARKETTING_VERSION" > build.env - - echo "BETA_MARKETTING_VERSION=$BETA_MARKETTING_VERSION" >> build.env - - echo "STABLE_MARKETTING_VERSION=$STABLE_MARKETTING_VERSION" >> build.env - - echo "ALPHA_MINOR_VERSION=$ALPHA_MINOR_VERSION" >> build.env - - echo "BETA_MINOR_VERSION=$BETA_MINOR_VERSION" >> build.env - - echo "STABLE_MINOR_VERSION=$STABLE_MINOR_VERSION" >> build.env - - echo "ALPHA_PATCH_VERSION=$ALPHA_PATCH_VERSION" >> build.env - - echo "BETA_PATCH_VERSION=$BETA_PATCH_VERSION" >> build.env - - echo "STABLE_PATCH_VERSION=$STABLE_PATCH_VERSION" >> build.env + - source ./current_version + - source ./ci/functions + - prepare_env > build.env artifacts: reports: dotenv: build.env -.test: +test: image: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] - variables: - DESTINATION_BASE: "--no-push" - DESTINATION_FR: "--no-push" - DESTINATION_WEB: "--no-push" dependencies: - prepare - before_script: - - source ./ci/functions.sh - - compute_versions - - echo $MARKETTING_VERSION - - echo $MINOR_VERSION - - echo $PATCH_VERSION - - export MINOR_WEB_VERSION=$MINOR_VERSION script: - - source ./ci/functions.sh - - compute_versions - - echo $MARKETTING_VERSION - - echo $MINOR_VERSION - - echo $PATCH_VERSION - - export CONTEXT=${CI_PROJECT_DIR}/base - - cd ${CONTEXT} - - /kaniko/executor --context ${CONTEXT} ${DESTINATION_BASE} --build-arg MARKETTING_VERSION=$MARKETTING_VERSION --build-arg MINOR_VERSION=$MINOR_VERSION --build-arg PATCH_VERSION=$PATCH_VERSION - - export CONTEXT=${CI_PROJECT_DIR}/web - - cd ${CONTEXT} - - /kaniko/executor --context ${CONTEXT} ${DESTINATION_WEB} --build-arg MINOR_VERSION=$MINOR_WEB_VERSION + - source ./ci/functions + - test_build except: - master - - /^feature-*$/ + - /^feature.*$/ - -test-alpha: - extends: .test - variables: - LINE: "alpha" - -test-beta: - extends: .test - variables: - LINE: "beta" - -test-stable: - extends: .test - variables: - LINE: "stable" - -.push: - extends: .test +push: dependencies: - prepare - before_script: - - source ./ci/functions.sh - - compute_versions - - echo $MARKETTING_VERSION - - echo $MINOR_VERSION - - echo $PATCH_VERSION - - export MINOR_WEB_VERSION=$MINOR_VERSION - - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" - - export DATE=`"+%Y-%m-%d_%H-%M"` - - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION} ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}" - - export DESTINATION_WEB="${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${DATE}" - - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - except: [] + script: + - source ./ci/functions + - build only: - master - -push-alpha: - extends: .push - variables: - LINE: "alpha" - -push-beta: - extends: .push - variables: - LINE: "beta" - -push-stable: - extends: .push - variables: - LINE: "stable" - -.push-feature: - extends: .test - dependencies: - - prepare - before_script: - - source ./ci/functions.sh - - compute_versions - - echo $MARKETTING_VERSION - - echo $MINOR_VERSION - - echo $PATCH_VERSION - - export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" - - export DATE=`"+%Y-%m-%d_%H-%M"` - - export DESTINATION_BASE="${DESTINATION_PREFIX}:${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" - - export DESTINATION_WEB="${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${CI_COMMIT_BRANCH}-${DATE}" - - export MINOR_WEB_VERSION=`echo ${MINOR_VERSION}-${CI_COMMIT_BRANCH}` - - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - except: [] - only: - - /^feature-*$/ - -push-feature-alpha: - extends: .push - variables: - LINE: "alpha" - -push-feature-beta: - extends: .push - variables: - LINE: "beta" - -push-feature-stable: - extends: .push - variables: - LINE: "stable" \ No newline at end of file + - /^feature.*$/ \ No newline at end of file diff --git a/ci/functions b/ci/functions new file mode 100644 index 0000000..750576c --- /dev/null +++ b/ci/functions @@ -0,0 +1,58 @@ +function prepare_env() { + curl https://api.github.com/repos/nextcloud/server/tags > /tmp/tags + export MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` + export PATCH_NUMBER=`curl https://raw.githubusercontent.com/nextcloud/server/v${MINOR_VERSION}/version.php | grep '$OC_Version =' | cut -d, -f4 | cut -d] -f1 | xargs` + echo "MARKETTING_VERSION=$MARKETTING_VERSION" + echo "MINOR_VERSION=$MINOR_VERSION" + echo "PATCH_VERSION=$MINOR_VERSION.$PATCH_NUMBER" +} + +function build_kaniko() { + /kaniko/executor --context ${CONTEXT} ${DESTINATION} --build-arg MARKETTING_VERSION=$MARKETTING_VERSION --build-arg MINOR_VERSION=$MINOR_VERSION --build-arg PATCH_VERSION=$PATCH_VERSION --build-arg BRANCH=$CI_COMMIT_BRANCH +} + +function print_versions() { + echo "======Building the following version:" + echo $MARKETTING_VERSION + echo $MINOR_VERSION + echo $PATCH_VERSION + echo "======" +} + +function build_base() { + export CONTEXT=${CI_PROJECT_DIR}/base + cd ${CONTEXT} + build_kaniko +} + +function build_web() { + export CONTEXT=${CI_PROJECT_DIR}/web + cd ${CONTEXT} + build_kaniko +} + +function test_build() { + print_versions + export DESTINATION: "--no-push" + build_base +} + +function build() { + print_versions + cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json + export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" + export DATE=`date "+%Y-%m-%dT%H-%M-%SZ"` + + export DESTINATION="\ + ${DESTINATION_PREFIX}:${CI_COMMIT_BRANCH}\ + ${DESTINATION_PREFIX}:${MINOR_VERSION}\ + ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}\ + " + build_base + export DESTINATION="\ + ${DESTINATION_PREFIX}:web-${CI_COMMIT_BRANCH}\ + ${DESTINATION_PREFIX}:web-${MINOR_VERSION}\ + ${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${DATE}\ + " + build_web +} diff --git a/ci/functions.sh b/ci/functions.sh deleted file mode 100644 index 529be72..0000000 --- a/ci/functions.sh +++ /dev/null @@ -1,45 +0,0 @@ - -function marketting_version() { - export CURRENT_MARKETTING_VERSION=`curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | sort -uV | tail -1 | cut -d\. -f1` -} - -function minor_version() { - marketting_version - curl https://api.github.com/repos/nextcloud/server/tags > /tmp/tags - curl https://api.github.com/repos/nextcloud/server/tags?page=2 >> /tmp/tags - curl https://api.github.com/repos/nextcloud/server/tags?page=3 >> /tmp/tags - - export ALPHA_MARKETTING_VERSION=$CURRENT_MARKETTING_VERSION - export BETA_MARKETTING_VERSION=$(($CURRENT_MARKETTING_VERSION - 1)) - export STABLE_MARKETTING_VERSION=$(($CURRENT_MARKETTING_VERSION - 2)) - - export ALPHA_MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${ALPHA_MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` - export BETA_MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${ALPHA_MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` - export STABLE_MINOR_VERSION=`cat /tmp/tags | jq '.[] | select(.name|test("v'${ALPHA_MARKETTING_VERSION}'.")).name' | head -n1 | cut -d\" -f2 | cut -c2-` -} - -function patch_version() { - minor_version - export ALPHA_PATCH_NUMBER=`curl https://raw.githubusercontent.com/nextcloud/server/v${ALPHA_MINOR_VERSION}/version.php | grep '$OC_Version =' | cut -d, -f4 | cut -d] -f1 | xargs` - export ALPHA_PATCH_VERSION=`echo "$ALPHA_MINOR_VERSION.$ALPHA_PATCH_NUMBER"` - export BETA_PATCH_NUMBER=`curl https://raw.githubusercontent.com/nextcloud/server/v${BETA_MINOR_VERSION}/version.php | grep '$OC_Version =' | cut -d, -f4 | cut -d] -f1 | xargs` - export BETA_PATCH_VERSION=`echo "$BETA_MINOR_VERSION.$BETA_PATCH_NUMBER"` - export STABLE_PATCH_NUMBER=`curl https://raw.githubusercontent.com/nextcloud/server/v${STABLE_MINOR_VERSION}/version.php | grep '$OC_Version =' | cut -d, -f4 | cut -d] -f1 | xargs` - export STABLE_PATCH_VERSION=`echo "$STABLE_MINOR_VERSION.$STABLE_PATCH_NUMBER"` -} - -function compute_versions() { - if [ "$LINE" = "alpha" ]; then - export MARKETTING_VERSION=$ALPHA_MARKETTING_VERSION - export MINOR_VERSION=$ALPHA_MINOR_VERSION - export PATCH_VERSION=$ALPHA_PATCH_VERSION - elif [ "$LINE" = "beta" ]; then - export MARKETTING_VERSION=$BETA_MARKETTING_VERSION - export MINOR_VERSION=$BETA_MINOR_VERSION - export PATCH_VERSION=$BETA_PATCH_VERSION - else - export MARKETTING_VERSION=$STABLE_MARKETTING_VERSION - export MINOR_VERSION=$STABLE_MINOR_VERSION - export PATCH_VERSION=$STABLE_PATCH_VERSION - fi -} diff --git a/current_version b/current_version new file mode 100644 index 0000000..ead8e51 --- /dev/null +++ b/current_version @@ -0,0 +1 @@ +export MARKETTING_VERSION=23 \ No newline at end of file diff --git a/fr/Dockerfile b/fr/Dockerfile deleted file mode 100644 index bc937d7..0000000 --- a/fr/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -ARG VERSION -FROM libresh/nextcloud:${VERSION} as builder -COPY --chown=www-data:root _build/html/release/fr/ /var/www/html/core/doc/user/ diff --git a/web/Dockerfile b/web/Dockerfile index 9a8abd8..e15b4e4 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,5 +1,5 @@ -ARG MINOR_VERSION -FROM libresh/nextcloud:${MINOR_VERSION} as builder +ARG BRANCH +FROM libresh/nextcloud:${BRANCH} as builder FROM nginx:alpine COPY --from=builder /usr/src/nextcloud /usr/src/nextcloud COPY default.conf.template /etc/nginx/templates/ -- GitLab From ec76675089a323c9093c5cdb23873f66924ff35f Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Mon, 1 Aug 2022 18:21:47 +0200 Subject: [PATCH 20/22] f --- ci/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/functions b/ci/functions index 750576c..865a605 100644 --- a/ci/functions +++ b/ci/functions @@ -55,4 +55,4 @@ function build() { ${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${DATE}\ " build_web -} +} \ No newline at end of file -- GitLab From 34c92c9e0e4e7516c92721e5e5d54a176ab98cd4 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Mon, 1 Aug 2022 17:48:27 +0000 Subject: [PATCH 21/22] Update .gitlab-ci.yml --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d34c501..f8cda82 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,5 +35,4 @@ push: - source ./ci/functions - build only: - - master - - /^feature.*$/ \ No newline at end of file + - feature-new-versions -- GitLab From 28405ddc810ee05c0d6fea78e0383a16671ca810 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Tue, 2 Aug 2022 18:08:39 +0200 Subject: [PATCH 22/22] f --- .gitlab-ci.yml | 3 +++ ci/functions | 44 +++++++++++++++++++++++++++++++------------- web/Dockerfile | 4 ++-- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f8cda82..21db97f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,6 +29,9 @@ test: - /^feature.*$/ push: + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] dependencies: - prepare script: diff --git a/ci/functions b/ci/functions index 865a605..223954f 100644 --- a/ci/functions +++ b/ci/functions @@ -8,7 +8,12 @@ function prepare_env() { } function build_kaniko() { - /kaniko/executor --context ${CONTEXT} ${DESTINATION} --build-arg MARKETTING_VERSION=$MARKETTING_VERSION --build-arg MINOR_VERSION=$MINOR_VERSION --build-arg PATCH_VERSION=$PATCH_VERSION --build-arg BRANCH=$CI_COMMIT_BRANCH + echo "======Building kaniko with following env:" + echo $CONTEXT + echo $DESTINATION + echo $BASE_TAG + echo "======" + /kaniko/executor --context ${CONTEXT} ${DESTINATION} --build-arg MARKETTING_VERSION=$MARKETTING_VERSION --build-arg MINOR_VERSION=$MINOR_VERSION --build-arg PATCH_VERSION=$PATCH_VERSION --build-arg BASE_TAG=$BASE_TAG } function print_versions() { @@ -42,17 +47,30 @@ function build() { cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json export DESTINATION_PREFIX="--destination ${DOCKER_HUB_REPO}" export DATE=`date "+%Y-%m-%dT%H-%M-%SZ"` - - export DESTINATION="\ - ${DESTINATION_PREFIX}:${CI_COMMIT_BRANCH}\ - ${DESTINATION_PREFIX}:${MINOR_VERSION}\ - ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}\ - " - build_base + + if [ "$VAR1" = "master" ]; then + export BASE_TAG=${MINOR_VERSION} + export DESTINATION="\ + ${DESTINATION_PREFIX}:${MINOR_VERSION}\ + ${DESTINATION_PREFIX}:${MINOR_VERSION}-${DATE}\ + " + build_base + export DESTINATION="\ + ${DESTINATION_PREFIX}:web-${MINOR_VERSION}\ + ${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${DATE}\ + " + build_web + else # feature branch + export BASE_TAG=${CI_COMMIT_BRANCH} export DESTINATION="\ - ${DESTINATION_PREFIX}:web-${CI_COMMIT_BRANCH}\ - ${DESTINATION_PREFIX}:web-${MINOR_VERSION}\ - ${DESTINATION_PREFIX}:web-${MINOR_VERSION}-${DATE}\ - " - build_web + ${DESTINATION_PREFIX}:${CI_COMMIT_BRANCH}\ + ${DESTINATION_PREFIX}:${CI_COMMIT_BRANCH}-${DATE}\ + " + build_base + export DESTINATION="\ + ${DESTINATION_PREFIX}:web-${CI_COMMIT_BRANCH}\ + ${DESTINATION_PREFIX}:web-${CI_COMMIT_BRANCH}-${DATE}\ + " + build_web + fi } \ No newline at end of file diff --git a/web/Dockerfile b/web/Dockerfile index e15b4e4..108d308 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,5 +1,5 @@ -ARG BRANCH -FROM libresh/nextcloud:${BRANCH} as builder +ARG BASE_TAG +FROM libresh/nextcloud:${BASE_TAG} as builder FROM nginx:alpine COPY --from=builder /usr/src/nextcloud /usr/src/nextcloud COPY default.conf.template /etc/nginx/templates/ -- GitLab