From bc041a8a45da524e2d649e84f7f741b08903482e Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 1 Mar 2020 00:17:44 -0800 Subject: [PATCH] Add Drone CI configuration --- .drone.yml | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ write-tags.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .drone.yml create mode 100755 write-tags.sh diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..5d76075 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,51 @@ +--- +kind: pipeline +name: default + +steps: +- name: "set image tags (normal build)" + image: alpine + environment: + VERSION: "7.2.10-r2" + commands: + - "./write-tags.sh $VERSION > .tags" + - "echo Will build the following tags:" + - "cat .tags" + +- name: "build docker image" + image: plugins/docker + settings: + repo: ovdnet/atheme + username: + from_secret: docker_user + password: + from_secret: docker_password + build_args: + - VERSION=7.2.10-r2 + trigger: + branch: + - master + +- name: "set image tags (build with contrib)" + image: alpine + environment: + VERSION: "7.2.10-r2" + commands: + - "./write-tags.sh $VERSION contrib > .tags" + - "echo Will build the following tags:" + - "cat .tags" + +- name: "build docker image (contrib)" + image: plugins/docker + settings: + repo: ovdnet/atheme + username: + from_secret: docker_user + password: + from_secret: docker_password + build_args: + - VERSION=7.2.10-r2 + - BUILD_CONTRIB_MODULES=true + trigger: + branch: + - master diff --git a/write-tags.sh b/write-tags.sh new file mode 100755 index 0000000..e6ed249 --- /dev/null +++ b/write-tags.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Write Docker tags for Drone CI: version-YYMMDD, version, maj.min, maj, latest + +VERSION="$1" +SUFFIX="$2" + +if test -z "$VERSION"; then + echo "Usage: $0 []" + exit 1 +fi + +if test -n "$SUFFIX"; then + case $SUFFIX in + "-"*) SUFFIX_HYPHENATED="$SUFFIX" ;; + *) SUFFIX_HYPHENATED="-$SUFFIX" ;; + esac +fi + +# Date based tag +printf '%s' "$VERSION-$(date +%Y%m%d)$SUFFIX_HYPHENATED," +# Program version +printf '%s' "$VERSION$SUFFIX_HYPHENATED," +# Major program version +printf '%s' "$(printf '%s' "$VERSION" | cut -d . -f 1)" +printf '%s' "$SUFFIX_HYPHENATED," +# maj.min pair. FIXME: failover if program version is not in the form x.y.z +printf '%s' "$(printf '%s' "$VERSION" | cut -d . -f 1-2)" +printf '%s' "$SUFFIX_HYPHENATED," + +if test -z "$SUFFIX"; then + echo latest +else + echo "$SUFFIX" +fi