Skip to content

Commit 1a62a9f

Browse files
authored
Move build (#294)
* moved build pipeline to here
1 parent 0c4ec48 commit 1a62a9f

File tree

6 files changed

+316
-5
lines changed

6 files changed

+316
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Changelog:
22

3-
* Reverted pre-install network check to Job
3+
* Moved Codefresh ci pipeline into the repo

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.269
1+
VERSION=v0.0.270
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

build/Dockerfile.helper

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM golang:1.17.8-alpine3.15
2+
3+
RUN apk -U add --no-cache \
4+
bash \
5+
ca-certificates \
6+
curl \
7+
g++ \
8+
gcc \
9+
git \
10+
jq \
11+
make \
12+
openssl \
13+
&& update-ca-certificates
14+
15+
ARG GH_VERSION=2.5.2
16+
RUN curl -L https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz --output gh.tar.gz \
17+
&& tar -xzf gh.tar.gz \
18+
&& mv gh_${GH_VERSION}_linux_amd64/bin/gh /usr/local/bin \
19+
&& rm gh.tar.gz \
20+
&& rm -rf gh_${GH_VERSION}_linux_amd64
21+
22+
RUN curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash \
23+
&& mv /go/kustomize /usr/bin
24+
25+
ENTRYPOINT [ "/bin/bash" ]

build/ci.yaml

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
version: "1.0"
2+
mode: parallel
3+
4+
stages:
5+
- Prepare
6+
- Test
7+
- Build
8+
- Push Dev
9+
- Release
10+
11+
steps:
12+
main_clone:
13+
stage: Prepare
14+
title: clone repository
15+
type: git-clone
16+
git: cf_github
17+
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
18+
revision: ${{CF_BRANCH}}
19+
20+
prepare_env_vars: &deps
21+
stage: Prepare
22+
title: prepare-env
23+
image: quay.io/codefresh/golang-ci-helper:latest
24+
commands:
25+
- cf_export GO111MODULE=on
26+
- cf_export GOCACHE=/codefresh/volume/gocache # change gopath to codefresh shared volume
27+
- cf_export GOPATH=/codefresh/volume/gopath
28+
- cf_export GOPRIVATE=github.com/codefresh-io/argo-platform
29+
- cf_export GOSUMDB=off
30+
- cf_export PATH=$PATH:/codefresh/volume/gopath/bin
31+
- cf_export LATEST_VERSION=$(curl --silent -H "Authorization:Bearer ${{GITHUB_TOKEN}}" "https://api.github.com/repos/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/releases/latest" | jq -r ".tag_name")
32+
- cf_export VERSION=$(make cur-version)
33+
when:
34+
steps:
35+
- name: main_clone
36+
on:
37+
- success
38+
39+
compare_versions:
40+
stage: Prepare
41+
title: compare versions
42+
image: alpine/semver
43+
commands:
44+
- semver "${{VERSION}}" -r ">${{LATEST_VERSION}}" || (echo "bump version! current is ${{VERSION}} latest is ${{LATEST_VERSION}}" && exit 1)
45+
when:
46+
steps:
47+
- name: prepare_env_vars
48+
on:
49+
- success
50+
51+
download_modules:
52+
<<: *deps
53+
stage: Prepare
54+
title: download modules
55+
commands:
56+
- git config --global url."https://github:${GITHUB_TOKEN}@github.com".insteadOf "https://github.com"
57+
- go mod tidy
58+
- make clean
59+
when:
60+
steps:
61+
- name: compare_versions
62+
on:
63+
- success
64+
65+
lint:
66+
<<: *deps
67+
stage: Test
68+
title: lint
69+
commands:
70+
- make lint
71+
- make check-worktree
72+
when:
73+
steps:
74+
- name: download_modules
75+
on:
76+
- success
77+
78+
codegen:
79+
<<: *deps
80+
stage: Test
81+
title: check codegen
82+
commands:
83+
- make codegen
84+
- make check-worktree
85+
when:
86+
steps:
87+
- name: download_modules
88+
on:
89+
- success
90+
91+
test:
92+
<<: *deps
93+
stage: Test
94+
title: run tests
95+
commands:
96+
- make test
97+
when:
98+
steps:
99+
- name: lint
100+
on:
101+
- success
102+
103+
codecov-report:
104+
stage: Test
105+
type: codecov-reporter
106+
title: report code coverage
107+
arguments:
108+
codecov_integration: ${{CODECOV_INTEGRATION}}
109+
when:
110+
steps:
111+
- name: test
112+
on:
113+
- success
114+
115+
build:
116+
stage: Build
117+
title: build docker image
118+
type: build
119+
image_name: ${{IMAGE_NAME}}
120+
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
121+
buildkit: true
122+
disable_push: true
123+
build_arguments:
124+
- GITHUB_TOKEN=${{GITHUB_TOKEN}}
125+
- SEGMENT_WRITE_KEY=${{SEGMENT_WRITE_KEY}}
126+
when:
127+
condition:
128+
all:
129+
isBinary: '"${{REPO_TYPE}}" != "lib"'
130+
steps:
131+
- name: compare_versions
132+
on:
133+
- success
134+
135+
push_dev:
136+
stage: Push Dev
137+
title: push with dev tags
138+
type: push
139+
candidate: ${{build}}
140+
tags:
141+
- dev-${{CF_BRANCH_TAG_NORMALIZED}}
142+
when:
143+
steps:
144+
- name: build
145+
on:
146+
- success
147+
branch:
148+
ignore: ["main"]
149+
scale:
150+
push_quay_dev:
151+
title: push to quay
152+
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
153+
154+
build_binaries:
155+
<<: *deps
156+
stage: Build
157+
title: build binaries
158+
commands:
159+
- make ./dist/cf-${TARGET}.sha256 DEV_MODE=false SEGMENT_WRITE_KEY=${{SEGMENT_WRITE_KEY}}
160+
scale:
161+
linux_amd64:
162+
title: linux_amd64
163+
environment:
164+
- TARGET=linux-amd64
165+
linux_arm64:
166+
title: linux_arm64
167+
environment:
168+
- TARGET=linux-arm64
169+
windows_amd64:
170+
title: windows_amd64
171+
environment:
172+
- TARGET=windows-amd64
173+
darwin_amd64:
174+
title: darwin_amd64
175+
environment:
176+
- TARGET=darwin-amd64
177+
darwin_arm64:
178+
title: darwin_arm64
179+
environment:
180+
- TARGET=darwin-arm64
181+
retry:
182+
maxAttempts: 3
183+
delay: 1
184+
when:
185+
condition:
186+
all:
187+
isBinary: '"${{REPO_TYPE}}" != "lib"'
188+
branch:
189+
only: ["main"]
190+
steps:
191+
- name: test
192+
on:
193+
- success
194+
- name: codegen
195+
on:
196+
- success
197+
- name: lint
198+
on:
199+
- success
200+
201+
create_release_lib:
202+
<<: *deps
203+
stage: Release
204+
title: create github release - lib
205+
commands:
206+
- export GIT_REPO=${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
207+
- export GIT_BRANCH=${{CF_BRANCH}}
208+
- make release
209+
when:
210+
condition:
211+
all:
212+
isBinary: '"${{REPO_TYPE}}" == "lib"'
213+
steps:
214+
- name: test
215+
on:
216+
- success
217+
- name: codegen
218+
on:
219+
- success
220+
221+
create_release_bin:
222+
<<: *deps
223+
stage: Release
224+
title: create github release - bin
225+
commands:
226+
- export GIT_REPO=${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
227+
- export GIT_BRANCH=${{CF_BRANCH}}
228+
- make release
229+
when:
230+
branch:
231+
only: ["main"]
232+
steps:
233+
- name: build_binaries
234+
on:
235+
- success
236+
- name: build
237+
on:
238+
- success
239+
240+
bump_brew_formula:
241+
stage: Release
242+
title: bump brew formula version
243+
image: codefresh/build-cli
244+
commands:
245+
- echo "generate formula from template ..."
246+
- sed -e "s/{{ version }}/${{VERSION}}/g" -e "s/{{ revision }}/${{CF_REVISION}}/g" ./brew/template.rb > ${{BREW_NAME}}.rb
247+
- echo "Updating file in GitHub"
248+
- FORMULA_SHA256=$(curl -X GET https://api.github.com/repos/codefresh-io/homebrew-cli/contents/Formula/${{BREW_NAME}}.rb | jq .sha)
249+
- |
250+
curl -v -i -X PUT -H 'Authorization: token '$GITHUB_TOKEN'' -d "{ \
251+
\"message\": \"update formula version $VERSION\", \
252+
\"content\": \"$(openssl base64 -A -in ${{BREW_NAME}}.rb)\", \
253+
\"sha\": $FORMULA_SHA256 \
254+
}" https://api.github.com/repos/codefresh-io/homebrew-cli/contents/Formula/${{BREW_NAME}}.rb
255+
when:
256+
steps:
257+
- name: create_release_bin
258+
on:
259+
- success
260+
condition:
261+
all:
262+
whenVarExists: 'includes("${{BREW_NAME}}", "{{BREW_NAME}}") == false'
263+
264+
265+
push_prod:
266+
stage: Release
267+
title: promote image
268+
type: push
269+
candidate: ${{build}}
270+
tags:
271+
- latest
272+
- ${{VERSION}}
273+
when:
274+
condition:
275+
all:
276+
isBinary: '"${{REPO_TYPE}}" != "lib"'
277+
steps:
278+
- name: create_release_bin
279+
on:
280+
- success
281+
branch:
282+
only: ["main"]
283+
scale:
284+
push_quay:
285+
title: push to quay
286+
registry: "${{REGISTRY_INTEGRATION_QUAY}}"

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.269/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.270/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.269/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.270/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

manifests/runtime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: "{{ namespace }}"
66
spec:
77
defVersion: 1.0.1
8-
version: 0.0.269
8+
version: 0.0.270
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

0 commit comments

Comments
 (0)