From 72bab017c1167b8ab35cef3cc709ff83686eaca4 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 25 Mar 2019 11:07:44 +0100 Subject: [PATCH 1/8] Remove the Docker login registry, globally install bash --- .gitlab-ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8efc417..434a92c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,11 +6,11 @@ services: stages: - build_publish +before-script: + - apk add bash + staging: stage: build_publish - before_script: - - apk add bash - - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin script: - /bin/bash utils/publish/staging.sh only: @@ -18,12 +18,9 @@ staging: production: stage: build_publish - before_script: - - apk add bash - - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin script: - /bin/bash utils/publish/production.sh only: - tags except: - - branches \ No newline at end of file + - branches From a52559ddb38a64d7fceaa8bf9b8afd7356ccc439 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 25 Mar 2019 11:08:19 +0100 Subject: [PATCH 2/8] Fix the build target detection --- utils/publish/production.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/publish/production.sh b/utils/publish/production.sh index 819e47a..a84f82d 100755 --- a/utils/publish/production.sh +++ b/utils/publish/production.sh @@ -28,9 +28,9 @@ fi if [ $CI_PIPELINE_SOURCE == "push" ]; then BUILD_LATEST=true elif [ $CI_PIPELINE_SOURCE == "trigger" ]; then - if [ -z $BUILD_LATEST ] || \ - [ -z $BUILD_MAJOR ] || \ - [ -z $BUILD_MINOR ] || \ + if [ -z $BUILD_LATEST ] && \ + [ -z $BUILD_MAJOR ] && \ + [ -z $BUILD_MINOR ] && \ [ -z $BUILD_REVISION ]; then echo "You must provide build targets to this stage when ran from Pipeline Triggers." exit 1 From f69483354a4cf8afdbea89ef2bb1d9a9b7b2ac10 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 25 Mar 2019 11:10:03 +0100 Subject: [PATCH 3/8] Login to the Docker Registry within the script, drop non-mandatory variables --- utils/publish/production.sh | 11 +++++++---- utils/publish/staging.sh | 7 +++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/utils/publish/production.sh b/utils/publish/production.sh index a84f82d..ad49a8d 100755 --- a/utils/publish/production.sh +++ b/utils/publish/production.sh @@ -60,8 +60,11 @@ docker build \ -t $CI_REGISTRY_IMAGE:$MINOR \ -t $CI_REGISTRY_IMAGE:$REVISION . +# Login with Docker Registry. +echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER docker.io --password-stdin + # Only push requested builds. -if [ $BUILD_LATEST ]; then docker push $CI_REGISTRY_IMAGE:latest; fi -if [ $BUILD_MAJOR ]; then docker push $CI_REGISTRY_IMAGE:$MAJOR; fi -if [ $BUILD_MINOR ]; then docker push $CI_REGISTRY_IMAGE:$MINOR; fi -if [ $BUILD_REVISION ]; then docker push $CI_REGISTRY_IMAGE:$REVISION; fi \ No newline at end of file +if [ $BUILD_LATEST ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:latest; fi +if [ $BUILD_MAJOR ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:$MAJOR; fi +if [ $BUILD_MINOR ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:$MINOR; fi +if [ $BUILD_REVISION ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:$REVISION; fi \ No newline at end of file diff --git a/utils/publish/staging.sh b/utils/publish/staging.sh index 0c220cf..ba28fcf 100755 --- a/utils/publish/staging.sh +++ b/utils/publish/staging.sh @@ -22,6 +22,9 @@ if [ $CI_PIPELINE_SOURCE != "push" ]; then exit 1 fi +# Login with Docker Registry. +echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin + # Build and push as staging. -docker build -t $CI_REGISTRY_IMAGE:staging . -docker push $CI_REGISTRY_IMAGE:staging \ No newline at end of file +docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging . +docker push index.docker.io/$CI_REGISTRY_IMAGE:staging \ No newline at end of file From 8cb49cbc8253368701d718c2e38017790c78ceca Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 25 Mar 2019 11:28:53 +0100 Subject: [PATCH 4/8] Add a script that push the README.md into the Docker Hub full_description --- .../update-docker-hub-full-description.sh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 utils/publish/update-docker-hub-full-description.sh diff --git a/utils/publish/update-docker-hub-full-description.sh b/utils/publish/update-docker-hub-full-description.sh new file mode 100644 index 0000000..32bd90c --- /dev/null +++ b/utils/publish/update-docker-hub-full-description.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Based upon https://gist.github.com/jlhawn/8f218e7c0b14c941c41f +# and https://github.com/moikot/golang-dep/blob/master/.travis/push.sh + +# Get a token from hub.docker.com with the owner credentials. +token=$(curl -s \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{"username": "'"$CI_REGISTRY_OWNER_USERNAME"'", "password": "'"$CI_REGISTRY_OWNER_PASSWORD"'"}' \ + https://hub.docker.com/v2/users/login/ | jq -r .token) + +# Generate a JSON with the README.md as the full_description. +json=$(jq -n \ + --arg readme "$( Date: Mon, 25 Mar 2019 11:29:21 +0100 Subject: [PATCH 5/8] Run the script from @8cb49cbc8253368701d718c2e38017790c78ceca on all commits from the master branch --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 434a92c..7525dec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,3 +24,10 @@ production: - tags except: - branches + +update_docker_hub_full_description: + stage: build_publish + script: + - /bin/bash utils/publish/update-docker-hub-full-description.sh + only: + - master \ No newline at end of file From 2aa3cae006ac093ff4b30ab35f9161bd740f0b77 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 25 Mar 2019 11:30:07 +0100 Subject: [PATCH 6/8] Document changes in v1.0.4 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5998dde..53d2145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### [1.0.4] - 2019/03/25 +- Fix the build target detection (@a52559ddb38a64d7fceaa8bf9b8afd7356ccc439) +- Login to the Docker Hub from within the script, not the gitlab-ci.yml, using (@72bab017c1167b8ab35cef3cc709ff83686eaca4, @f69483354a4cf8afdbea89ef2bb1d9a9b7b2ac10) +- Require Bash on all Gitlab CI stages (@72bab017c1167b8ab35cef3cc709ff83686eaca4) +- Add a script to push the README.md into the Docker Hub repository's full_description (@8cb49cbc8253368701d718c2e38017790c78ceca, @ca6128fb96602da71f3b7a560e834d1b7587abac) ### [1.0.3] - 2019/03/19 - Restrict staging pipelines to pushed pipelines - Restrict production pipelines to pushed and triggered pipelines From 905262749754e102eb3a31bbbfad26fc74d0c4f4 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 25 Mar 2019 11:31:16 +0100 Subject: [PATCH 7/8] Push the weekly stable to v1.0.4, add v1.0.3 as a permanent stable --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f001880..771acc9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![1.0.3 status](https://gitlab.com/flwgns-docker/seafile-client/badges/1.0.3/pipeline.svg)](https://gitlab.com/flwgns-docker/seafile-client/commits/1.0.3) +[![1.0.4 status](https://gitlab.com/flwgns-docker/seafile-client/badges/1.0.4/pipeline.svg)](https://gitlab.com/flwgns-docker/seafile-client/commits/1.0.4) [![docker pulls](https://img.shields.io/docker/pulls/flowgunso/seafile-client.svg)](https://hub.docker.com/r/flowgunso/seafile-client) # Available tags @@ -9,13 +9,15 @@ Permanent stable releases will not be built again. You can rely on the weekly stable releases. They are stable. ## Weekly stable releases. -[`1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.3), -[`1.0`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.3), -[`1.0.3`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.3), -[`latest`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.3) -(see tag/release [1.0.3](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.3)) +[`1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.4), +[`1.0`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.4), +[`1.0.4`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.4), +[`latest`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.4) +(see tag/release [1.0.4](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.4)) ## Permanent stable releases. +[`1.0.3`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.3) +(see tag/release [1.0.3](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.3)) [`1.0.2`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.2) (see tag/release [1.0.2](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.2)) [`1.0.0`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.0.0) From 184ef9f418738391f59e94579daf4b201675a6da Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 25 Mar 2019 11:34:53 +0100 Subject: [PATCH 8/8] Fix with an underscore --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7525dec..09d9c34 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,8 +6,8 @@ services: stages: - build_publish -before-script: - - apk add bash +before_script: +- apk add bash staging: stage: build_publish