Add new CI scripts that check, build, test and publish the images, move the .utilities
This commit is contained in:
32
.utilities/build.sh
Normal file
32
.utilities/build.sh
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Hard reset to the latest tag.
|
||||||
|
latest_version=$(git describe --abbrev=0)
|
||||||
|
git reset --hard $latest_version
|
||||||
|
|
||||||
|
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
|
||||||
47
.utilities/check.sh
Normal file
47
.utilities/check.sh
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Check the CI pipeline sources.
|
||||||
|
if ! [[ "$CI_PIPELINE_SOURCE" == "push" || "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
|
||||||
|
echo "CI pipelines are only allowed from the push and schedule sources"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check the schedule target for the scheduled CI pipelines.
|
||||||
|
if [[ "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
|
||||||
|
if [[ -z "$SCHEDULE_TARGET" ]]; then
|
||||||
|
echo "\$SCHELUDE_TARGET was not provided."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ "$SCHEDULE_TARGET" == "weekly" ]]; then
|
||||||
|
echo "\$SCHEDULE_TARGET $SCHEDULE_TARGET is not known."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check the tag is properly defined on job other than update_docker_hub_full_description job,
|
||||||
|
# on pushed CI pipelines.
|
||||||
|
if [[ "$CI_PIPELINE_SOURCE" == "push" ]]; then
|
||||||
|
if ! [[ "$CI_JOB_NAME" == "update_docker_hub_full_description" ]]; then
|
||||||
|
if [[ -z "$CI_COMMIT_TAG" && "$CI_COMMIT_TAG" =~ ^[0-9]+[.][0-9]+[.][0-9]+$ ]]
|
||||||
|
echo "The \$CI_COMMIT_TAG $CI_COMMIT_TAG does not match the MAJOR.Minor.revision layout."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
34
.utilities/publish.sh
Normal file
34
.utilities/publish.sh
Normal file
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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
|
||||||
26
.utilities/test.sh
Normal file
26
.utilities/test.sh
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# !/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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
SCRIPT_DIRECTORY=$(dirname ${BASH_SOURCE[0]})
|
||||||
|
source $SCRIPT_DIRECTORY/utilities.sh
|
||||||
|
load_images_artifacts
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
--interactive \
|
||||||
|
--attach stderr \
|
||||||
|
$CI_PROJECT_NAME:build /test/test_binaries.sh
|
||||||
46
.utilities/update-docker-hub-full-description.sh
Normal file
46
.utilities/update-docker-hub-full-description.sh
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Based upon https://gist.github.com/jlhawn/8f218e7c0b14c941c41f
|
||||||
|
# and https://github.com/moikot/golang-dep/blob/master/.travis/push.sh
|
||||||
|
|
||||||
|
# This action can only be done with the actual owner of the repository,
|
||||||
|
# unless you can extend the collaborator's permissions but as far as I know, you can't.
|
||||||
|
|
||||||
|
# Install required system packages.
|
||||||
|
apk add curl jq
|
||||||
|
|
||||||
|
# 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 "$(<README.md)" \
|
||||||
|
'{"full_description": $readme}')
|
||||||
|
|
||||||
|
# Update the Docker Hub repository's full_description.
|
||||||
|
curl -s -L \
|
||||||
|
-X PATCH \
|
||||||
|
-d "$json" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: JWT $token" \
|
||||||
|
https://cloud.docker.com/v2/repositories/$CI_REGISTRY_IMAGE/
|
||||||
21
.utilities/utilities.sh
Normal file
21
.utilities/utilities.sh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# !/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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
load_images_artifacts() {
|
||||||
|
docker load --input $CI_PROJECT_NAME.tar
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user