This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
config.yml
111 lines (105 loc) · 4.16 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
version: 2
jobs:
build:
working_directory: /home/circleci/go/src/github.com/fluxcd/flux
machine:
image: ubuntu-2004:202010-01
resource_class: large
environment:
GO_VERSION: 1.17.12
# 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 parallel
# avoid needing to invoke parallel with --will-cite,
# see e.g see https://bugs.launchpad.net/ubuntu/+source/parallel/+bug/1779764
mkdir -p "$HOME/.parallel" && touch "$HOME/.parallel/will-cite"
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 all
- 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
# Re-tag image as prerelease and publish on DockerHub
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 images and upload binaries
command: |
if echo "${CIRCLE_TAG}" | grep -Eq "^[0-9]+(\.[0-9]+)*(-[a-z0-9]+)?$"; then
# Publish binaries to GitHub
go get github.com/github-release/github-release
make build-fluxctl
bin/upload-binaries
# Publish images on DockerHub
echo "$DOCKER_FLUXCD_PASSWORD" | docker login --username "$DOCKER_FLUXCD_USER" --password-stdin
docker push "docker.io/fluxcd/flux:${CIRCLE_TAG}"
docker push "docker.io/fluxcd/fluxctl:${CIRCLE_TAG}"
# Republish tag with v prefix so it is available to Go Mod
git config --global user.email [email protected]
git config --global user.name fluxcdbot
REPOSITORY="https://fluxcdbot:${GITHUB_TOKEN}@github.com/fluxcd/flux.git"
git remote set-url origin ${REPOSITORY}
V_TAG="v${CIRCLE_TAG}"
git tag ${V_TAG} $(git rev-list -n1 ${CIRCLE_TAG})
git push origin ${V_TAG}
fi
workflows:
version: 2
build-and-push:
jobs:
- build:
filters:
tags:
only: /[0-9]+(\.[0-9]+)*(-[a-z0-9]+)?/