-
Notifications
You must be signed in to change notification settings - Fork 9
/
.travis.yml
87 lines (79 loc) · 2.98 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
dist: focal
language: python
python: "3.10"
git:
depth: false
env:
global:
- IMAGE_NAME=tardigrade-ci-test
if: branch = master OR type = pull_request OR tag is present
stages:
- lint
- test
- deploy
services:
- docker
jobs:
include:
- stage: lint
name: Project Syntax Verification
install: make lint/install
script: make -o docs/lint lint
- stage: test
name: Run Makefile unit tests
install: docker build --quiet --build-arg GITHUB_ACCESS_TOKEN=$GITHUB_ACCESS_TOKEN -t "$IMAGE_NAME" -f Dockerfile .
script: docker run "$IMAGE_NAME" bats/test
- stage: deploy
name: Deploy to GitHub Releases
if: branch = master AND type = push AND repo = plus3it/tardigrade-ci
before_script:
- |
PRIOR_VERSION=$(git describe --abbrev=0 --tags)
RELEASE_VERSION=$(grep current_version $TRAVIS_BUILD_DIR/.bumpversion.cfg | sed 's/^.*= //' )
RELEASE_BODY="* [tardigrade-ci v$RELEASE_VERSION CHANGELOG](https://github.com/plus3it/tardigrade-ci/blob/$RELEASE_VERSION/CHANGELOG.md)"
export PRIOR_VERSION RELEASE_VERSION RELEASE_BODY
script: skip
before_deploy:
# Per https://travis-ci.community/t/deployments-are-failing-due-to-uri-dependency/14375
- yes | gem update --system --force
- gem install bundler
# Travis-CI is so broken, https://travis-ci.community/t/cannot-load-such-file-faraday-net-http-loaderror/14455
- gem install faraday-net_http -v '3.3.0' # Fix faraday version
- gem install uri
- gem install logger
- (set -x; git tag -a $RELEASE_VERSION -m $RELEASE_VERSION)
deploy:
provider: releases
api_key: $GH_RELEASES_TOKEN
name: $RELEASE_VERSION
body: $RELEASE_BODY
tag_name: $RELEASE_VERSION
target_commitish: $TRAVIS_COMMIT
draft: false
on:
branch: master
repo: plus3it/tardigrade-ci
condition: '"$PRIOR_VERSION" != "$RELEASE_VERSION"'
- stage: deploy
name: Deploy docker image to dockerhub
if: (branch = master OR tag is present) AND type != pull_request AND repo = plus3it/tardigrade-ci
script: docker build --build-arg GITHUB_ACCESS_TOKEN=$GITHUB_ACCESS_TOKEN -t "$IMAGE_NAME" -f Dockerfile .
before_deploy:
- export DOCKERHUB_TARGET="plus3it/tardigrade-ci:${TRAVIS_TAG:-latest}"
- docker tag "$IMAGE_NAME" "$DOCKERHUB_TARGET"
- echo Pushing image "$DOCKERHUB_TARGET"
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
after_deploy: echo Pushed image "$DOCKERHUB_TARGET"
deploy:
- provider: script
# push "latest" to dockerhub
script: docker push "$DOCKERHUB_TARGET"
skip_cleanup: true
on:
branch: master
- provider: script
# push "tag" to dockerhub
script: docker push "$DOCKERHUB_TARGET"
skip_cleanup: true
on:
tags: true