Add Drone CI configuration

This commit is contained in:
James Lu 2020-03-01 00:17:44 -08:00
parent 97cfc97c90
commit bc041a8a45
2 changed files with 85 additions and 0 deletions

51
.drone.yml Normal file
View file

@ -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

34
write-tags.sh Executable file
View file

@ -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 <version> [<suffix>]"
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