diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eadb103..58e9e9d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,20 +11,28 @@ stages: before_script: - apk add bash git -build: +build.tags: stage: build - script: /bin/bash -e .utilities/build.sh + script: /bin/bash -e utilities/build.tags.sh only: - tags - - schedules - milestone--2.0 artifacts: paths: - $CI_PROJECT_NAME.tar +build.schedules: + stage: build + script: /bin/bash -e utilities/build.schedules.sh + only: + - schedules + artifacts: + paths: + - $CI_PROJECT_NAME.tar + test: stage: test - script: /bin/bash -e .utilities/test.sh + script: /bin/bash -e utilities/test.sh only: - tags - schedules @@ -33,11 +41,19 @@ test: paths: - $CI_PROJECT_NAME.tar -publish: +publish.tags: stage: publish - script: /bin/bash -e .utilities/publish.sh + script: /bin/bash -e utilities/publish.tags.sh only: - tags + artifacts: + paths: + - $CI_PROJECT_NAME.tar + +publish.schedules: + stage: publish + script: /bin/bash -e utilities/publish.schedules.sh + only: - schedules artifacts: paths: @@ -45,6 +61,6 @@ publish: update_docker_hub_full_description: stage: publish - script: /bin/bash -e .utilities/update-docker-hub-full-description.sh + script: /bin/bash -e utilities/update-docker-hub-full-description.sh only: - master diff --git a/.utilities/build.sh b/.utilities/build.schedules.sh similarity index 100% rename from .utilities/build.sh rename to .utilities/build.schedules.sh diff --git a/.utilities/build.tags.sh b/.utilities/build.tags.sh new file mode 100644 index 0000000..2812b0b --- /dev/null +++ b/.utilities/build.tags.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019-2020, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +cp -R tests seafile-client/ +cd seafile-client/ + +docker build \ + --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + --build-arg VCS_REF=$(git rev-parse --short HEAD) \ + --build-arg VERSION=$latest_version \ + --tag $CI_PROJECT_NAME:build . + +docker save --output ../$CI_PROJECT_NAME.tar $CI_PROJECT_NAME:build diff --git a/.utilities/publish.schedules.sh b/.utilities/publish.schedules.sh new file mode 100644 index 0000000..bbdcb02 --- /dev/null +++ b/.utilities/publish.schedules.sh @@ -0,0 +1,34 @@ +# !/bin/bash + +# Docker Seafile client, help you mount a Seafile library as a volume. +# Copyright (C) 2019-2020, flow.gunso@gmail.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +SCRIPT_DIRECTORY=$(dirname ${BASH_SOURCE[0]}) +source $SCRIPT_DIRECTORY/utilities.sh +load_images_artifacts + +tags=("latest") +for version_component in "$(git describe --abbrev=0 | tr '.' '\n')"; do + tag+="$version_component" + tags+=("$tag") + tag+="." +done + +echo $CI_REGISTRY_BOT_PASSWORD | docker login --password-stdin --username $CI_REGISTRY_BOT_USERNAME +for tag in "${tags[@]}"; do + echo "docker tag $CI_PROJECT_NAME:$tag $CI_REGISTRY_IMAGE:build" + echo "docker push $CI_REGISTRY_IMAGE:$tag" +done diff --git a/.utilities/publish.sh b/.utilities/publish.tags.sh similarity index 94% rename from .utilities/publish.sh rename to .utilities/publish.tags.sh index 8c21ad0..e78bdf2 100644 --- a/.utilities/publish.sh +++ b/.utilities/publish.tags.sh @@ -21,7 +21,7 @@ source $SCRIPT_DIRECTORY/utilities.sh load_images_artifacts tags=("latest") -for version_component in $(git describe --abbrev=0 | tr "." "\n"); do +for version_component in "$CI_COMMIT_TAG"; do tag+="$version_component" tags+=("$tag") tag+="."