forked from gokuu/nordvpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
54 lines (50 loc) · 2.68 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
os: linux
language: shell
services: docker
install: sudo apt-get -y install jq sed curl
env:
global:
- REPO=${DOCKER_USERNAME}/nordvpn
jobs:
- ARCH=i386
- ARCH=amd64
- ARCH=armv5e
- ARCH=armv7hf
- ARCH=aarch64
before_script:
- DOCKER_VERSION=$(curl -sSL "https://registry.hub.docker.com/v2/repositories/$REPO/tags?page_size=1024" | jq -r '."results"[]["name"]' | grep '^[0-9].*[0-9]$' | sort | uniq | tail -n 1)
- NORDVPN_VERSION=$(curl https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/ | grep amd64.deb | sed 's/\(<a.*nordvpn_\)\([0-9.-]\+\).*/\2/' | sort | uniq | tail -n 1)
- if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] && [ "${NORDVPN_VERSION}" == "${DOCKER_VERSION}" ]; then exit 0 ; fi
- if [ -z "${DOCKER_VERSION}" ] || [ -z "${NORDVPN_VERSION}" ]; then exit 0; fi
- VERSION="${NORDVPN_VERSION}" ; BRANCH="latest"
- if [ "${TRAVIS_BRANCH}" != "master" ]; then VERSION+="${TRAVIS_BRANCH}" ; BRANCH="${TRAVIS_BRANCH}" ; fi
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- if [ "${ARCH}" == "armv5e" ] || [ "${ARCH}" == "armv7hf" ] || [ "${ARCH}" == "aarch64" ]; then sed -i 's/^#CROSSRUN/RUN/g' Dockerfile ; fi
stage: "Build"
script:
- docker build --build-arg ARCH=${ARCH} --build-arg NORDVPN_VERSION=${NORDVPN_VERSION} -t $REPO:${ARCH}-${VERSION} .
- if [ "${BRANCH}" != "dev" ]; then docker push $REPO:${ARCH}-${VERSION} ; fi
- docker tag $REPO:${ARCH}-${VERSION} $REPO:${ARCH}-${BRANCH}
- docker push $REPO:${ARCH}-${BRANCH}
jobs:
fast_finish: true
include:
- stage: "Deploy"
name: "Manifest"
git:
clone: false
script:
- cat <<< $(jq '.+{"experimental":"enabled"}' ~/.docker/config.json) > ~/.docker/config.json
- |
push() {
docker pull $REPO:i386-${1} & docker pull $REPO:amd64-${1} & docker pull $REPO:armv5e-${1} & docker pull $REPO:armv7hf-${1} & docker pull $REPO:aarch64-${1}
docker manifest create $REPO:${1} $REPO:i386-${1} $REPO:amd64-${1} $REPO:armv5e-${1} $REPO:armv7hf-${1} $REPO:aarch64-${1}
docker manifest annotate $REPO:${1} $REPO:i386-${1} --os linux --arch 386
docker manifest annotate $REPO:${1} $REPO:amd64-${1} --os linux --arch amd64
docker manifest annotate $REPO:${1} $REPO:armv5e-${1} --os linux --arch arm --variant v5
docker manifest annotate $REPO:${1} $REPO:armv7hf-${1} --os linux --arch arm --variant v7
docker manifest annotate $REPO:${1} $REPO:aarch64-${1} --os linux --arch arm64 --variant v8
docker manifest push --purge $REPO:${1}
}
- if [ "${BRANCH}" != "dev" ]; then push ${VERSION} ; fi
- push ${BRANCH}