3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 13:09:23 +01:00

Add Drone CI pipeline for building Docker image

This commit is contained in:
James Lu 2020-04-10 13:13:46 -07:00
parent ba22b18cc4
commit c14fc5cf07
2 changed files with 67 additions and 0 deletions

30
.drone-write-tags.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# Write Docker tags for Drone CI: version-YYMMDD, version, major version, latest
VERSION="$1"
if test -z "$VERSION"; then
echo "Usage: $0 <version>"
exit 1
fi
if [[ "$VERSION" == *"alpha"* || "$VERSION" == *"dev"* ]]; then
# This should never trigger if reference based tagging is enabled
echo "ERROR: Pushing alpha / dev tags is not supported"
exit 1
fi
major_version="$(printf '%s' "$VERSION" | cut -d . -f 1)"
# Date based tag
printf '%s' "$VERSION-$(date +%Y%m%d),"
# Program version
printf '%s' "$VERSION,"
if [[ "$VERSION" == *"beta"* ]]; then
printf '%s' "$major_version-beta,"
printf '%s' "latest-beta"
else # Stable or rc build
printf '%s' "$major_version,"
printf '%s' "latest"
fi

37
.drone.yml Normal file
View File

@ -0,0 +1,37 @@
---
kind: pipeline
type: docker
name: build
steps:
- name: "test"
image: python:3.8
commands:
- "git submodule update --recursive --remote --init"
- "pip install -r requirements-docker.txt"
- "python3 setup.py install"
- "python3 -m unittest discover test/ --verbose"
- name: "set Docker image tags"
image: bash
commands:
- "bash .drone-write-tags.sh $DRONE_TAG > .tags"
- "# Will build the following tags:"
- "cat .tags"
- name: "build Docker image"
image: plugins/docker
settings:
repo: jlu5/pylink
username:
from_secret: docker_user
password:
from_secret: docker_token
trigger:
event:
- tag
ref:
exclude:
- refs/tags/*alpha*
- refs/tags/*dev*