This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
/
config.yml
175 lines (168 loc) · 6.75 KB
/
config.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
version: 2
jobs:
helm:
docker:
- image: circleci/golang:1.12
steps:
- checkout
- run:
name: Install kubectl
command: sudo curl -L https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl && sudo chmod +x /usr/local/bin/kubectl
- run:
name: Install helm
command: sudo curl -L https://storage.googleapis.com/kubernetes-helm/helm-v2.14.2-linux-amd64.tar.gz | tar xz && sudo mv linux-amd64/helm /bin/helm && sudo rm -rf linux-amd64
- run:
name: Initialize helm
command: helm init --client-only --kubeconfig=$HOME/.kube/kubeconfig
- run:
name: Lint chart
command: |
helm lint ./chart/flux
- run:
name: Package chart
command: |
mkdir $HOME/chart
helm package ./chart/flux --destination $HOME/chart
- run:
name: Publish chart
command: |
git config --global user.email fluxcdbot@users.noreply.github.com
git config --global user.name fluxcdbot
# Push to fluxcd/flux gh-pages branch
if echo "${CIRCLE_TAG}" | grep -Eq "chart-[0-9]+(\.[0-9]+)*(-[a-z]+)?$"; then
REPOSITORY="https://fluxcdbot:${GITHUB_TOKEN}@github.com/fluxcd/flux.git"
git remote set-url origin ${REPOSITORY}
git checkout gh-pages
cp $HOME/chart/*.tgz .
helm repo index . --url https://fluxcd.github.io/flux
git add .
git commit -m "Publish Helm chart"
git push origin gh-pages
else
echo "Not a chart release! Skip chart publish"
fi
# Push to fluxcd/charts gh-pages branch
if echo "${CIRCLE_TAG}" | grep -Eq "chart-[0-9]+(\.[0-9]+)*(-[a-z]+)?$"; then
REPOSITORY="https://fluxcdbot:${GITHUB_TOKEN}@github.com/fluxcd/charts.git"
mkdir $HOME/fluxcd-charts
cd $HOME/fluxcd-charts && git clone ${REPOSITORY}
cd $HOME/fluxcd-charts/charts
git checkout gh-pages
mv $HOME/chart/*.tgz .
helm repo index . --url https://charts.fluxcd.io
git add .
git commit -m "Publish chart to fluxcd/charts"
git push origin gh-pages
else
echo "Not a chart release! Skip chart publish"
fi
build:
working_directory: /home/circleci/go/src/github.com/fluxcd/flux
machine:
image: ubuntu-1604:201903-01
environment:
GO_VERSION: 1.12.5
# We don't need a GOPATH but CircleCI defines it, so we override it
GOPATH: /home/circleci/go
GO111MODULE: 'on'
PATH: /bin:/usr/bin:/usr/local/go/bin:/home/circleci/go/bin
steps:
- checkout
- run:
name: Install Golang
command: |
curl -OL https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz
tar -xf go${GO_VERSION}.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo mv go /usr/local
mkdir -p "$HOME/go/bin"
rm -rf go${GO_VERSION}.linux-amd64.tar.gz
go version
- run:
name: Update packages and start Memcached
no_output_timeout: 10m
command: |
# Kill any apt-get processes that may be hanging due to
# networking related issues, and thus holding on to
# `/var/lib/apt/lists/lock`.
# https://support.circleci.com/hc/en-us/articles/360021256633-Apt-Get-Update-Is-Slow-Or-Locked
sudo killall apt-get || true
sudo apt-get update
sudo apt-get install -y git rng-tools memcached
git version
docker version
- restore_cache:
keys:
- cache-{{ checksum "Makefile" }}
- cache-
- restore_cache:
keys:
- go-build-{{ .Branch }}-{{ .Revision }}
- go-build-{{ .Branch }}-
- go-build-
- restore_cache:
keys:
- go-mod-{{ checksum "go.mod" }}
- go-mod-
- run: make test TEST_FLAGS="-race -tags integration -timeout 60s"
- run: make check-generated
- run: make all
- run: make e2e
- run: make test-docs
- save_cache:
key: cache-{{ checksum "Makefile" }}
paths:
- "cache"
- save_cache:
key: go-build-{{ .Branch }}-{{ .Revision }}
paths:
- "~/.cache/go-build/"
- save_cache:
key: go-mod-{{ checksum "go.mod" }}
paths:
- "~/go/pkg/mod/"
- deploy:
name: Maybe push prerelease images
command: |
if [ -z "${CIRCLE_TAG}" -a "${CIRCLE_BRANCH}" == "master" ]; then
# Push to weaveworks org
echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username "$DOCKER_REGISTRY_USER" --password-stdin
docker tag "docker.io/fluxcd/flux:$(docker/image-tag)" "docker.io/weaveworks/flux-prerelease:$(docker/image-tag)"
docker push "docker.io/weaveworks/flux-prerelease:$(docker/image-tag)"
# Push to fluxcd org
echo "$DOCKER_FLUXCD_PASSWORD" | docker login --username "$DOCKER_FLUXCD_USER" --password-stdin
docker tag "docker.io/fluxcd/flux:$(docker/image-tag)" "docker.io/fluxcd/flux-prerelease:$(docker/image-tag)"
docker push "docker.io/fluxcd/flux-prerelease:$(docker/image-tag)"
fi
- deploy:
name: Maybe push release image and upload binaries
command: |
if echo "${CIRCLE_TAG}" | grep -Eq "^[0-9]+(\.[0-9]+)*(-[a-z0-9]+)?$"; then
go get github.com/weaveworks/github-release
make release-bins
bin/upload-binaries
# Push to weaveworks org
echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username "$DOCKER_REGISTRY_USER" --password-stdin
docker tag "docker.io/fluxcd/flux:${CIRCLE_TAG}" "docker.io/weaveworks/flux:${CIRCLE_TAG}"
docker push "docker.io/weaveworks/flux:${CIRCLE_TAG}"
# Push to fluxcd org
echo "$DOCKER_FLUXCD_PASSWORD" | docker login --username "$DOCKER_FLUXCD_USER" --password-stdin
docker push "docker.io/fluxcd/flux:${CIRCLE_TAG}"
fi
workflows:
version: 2
build-and-push:
jobs:
- helm
- build:
filters:
tags:
only: /[0-9]+(\.[0-9]+)*(-[a-z0-9]+)?/
release-helm:
jobs:
- helm:
filters:
branches:
ignore: /.*/
tags:
only: /^chart.*/