-
Notifications
You must be signed in to change notification settings - Fork 2
/
.travis.yml
97 lines (87 loc) · 3.47 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
88
89
90
91
92
93
94
95
96
97
# Not go, and jus tminimal because the code is compiled in the dirat stage of
# the multi-stage Dcokerfile.
language: minimal
sudo: required
services:
- docker
branches:
only:
- master
cache:
directories: ~/.npm
before_script:
# Install semantic-release, helm and configure docker hub login to publish
# image.
- nvm install lts/*
- npm install
semantic-release
@semantic-release/changelog
@semantic-release/exec
@semantic-release/git
@semantic-release/github
@commitlint/cli
@commitlint/config-conventional
- curl -L https://git.io/get_helm.sh | bash; helm init --client-only
- echo "$DOCKER_PASSWORD" | docker login -u "bergerx" --password-stdin
script:
# The repo is using a multi-stage Dockerfile, compile happens on the first
# stage, and there will only be compiled binary file in the final image.
- echo 'Compile and build docker image ...' && echo -en 'travis_fold:start:build\\r'
- docker build
--build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
--build-arg VCS_REF=$TRAVIS_COMMIT
-t bergerx/tillerless-helm-release-exporter
.
- echo -en 'travis_fold:end:build\\r'
# Release new version, semantic-release will decide the next version number,
# also see .releaserc file for some more details about how semantic-release is
# configured.
- echo 'Release new version ...' && echo -en 'travis_fold:start:release\\r'
- npx semantic-release
- VERSION=$(git describe --abbrev=0 --tags); echo $VERSION
- echo -en 'travis_fold:end:release\\r'
# Publish the Docker image for the release.
- echo "Publish Docker image with tag $VERSION ..." && echo -en 'travis_fold:start:publish-docker-image\\r'
# Terminate the rest if there is a docker image with the new version already
# exists.
- >
if curl -s https://hub.docker.com/v2/repositories/bergerx/tillerless-helm-release-exporter/tags/?page_size=10000 |
jq -r "[.results | .[] | .name == \"$VERSION\"] | any" | grep true; then
echo "There is already an image with $VERSION tag, terminating Travis job."
travis_terminate 0
fi
- docker tag
bergerx/tillerless-helm-release-exporter
bergerx/tillerless-helm-release-exporter:$VERSION
- docker push
bergerx/tillerless-helm-release-exporter:$VERSION
- docker push
bergerx/tillerless-helm-release-exporter
- echo -en 'travis_fold:end:pusblish-docker-image\\r'
# Publish new Helm Chart with new release. Helm Charts versions will be
# matching the project versions.
- echo 'Publish Helm Chart with version $VERSION ...' && echo -en 'travis_fold:start:publish-helm-chart\\r'
# Travis is currently configured to run only on master for now.
#- git co master
- rm -rf charts-dup; cp -ar charts charts-dup
# There is GITHUB_TOKEN for auth with github, so we explicitly add the HTTPS
# endpoint as a new remote.
- git remote add origin-pages https://${GITHUB_TOKEN}@github.com/bergerx/tillerless-helm-release-exporter.git
- git fetch origin-pages
- git checkout --track origin-pages/gh-pages
- >
set -x;
CHART_PACKAGE=tillerless-helm-release-exporter-${VERSION//v}.tgz;
if ! test -f $CHART_PACKAGE; then
helm package charts-dup/tillerless-helm-release-exporter/
helm repo index .
git add index.yaml $CHART_PACKAGE
git commit -m "chore(release): $VERSION [skip ci]" -m "Travis build: $TRAVIS_BUILD_WEB_URL"
git push origin-pages gh-pages
else
echo "Helm Chart with version $VERSION already exists, skipped Helm Chart publish step."
fi;
set +x
- git checkout master
- echo -en 'travis_fold:end:pusblish-helm-chart\\r'
- echo 'All Done.'