Skip to content

Commit

Permalink
feat: add release CI build
Browse files Browse the repository at this point in the history
* Uses goreleaser to generate binaries for different platforms and post
it on github releases
* Triggers on tagging (done manually for now)
* Changes go-build make targets to build to /dev/null as we are mostly
interested in checking whether we are able to build and not generating
any binaries
  • Loading branch information
alethenorio committed May 19, 2021
1 parent 3d2490d commit d055cbb
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .cloudbuild/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ gcp_build_project := einride-build
.PHONY: all
all: \
triggers-create-review \
triggers-create-release \

.PHONY: triggers-create-review
triggers-create-review: $(cloudbuild_cwd)/triggers/review.yaml $(cloudbuild_cwd)/configs/review.yaml
gcloud beta builds triggers create github --project $(gcp_build_project) --trigger-config=$<

.PHONY: triggers-create-release
triggers-create-release: $(cloudbuild_cwd)/triggers/release.yaml $(cloudbuild_cwd)/configs/release.yaml
gcloud beta builds triggers create github --project $(gcp_build_project) --trigger-config=$<
34 changes: 34 additions & 0 deletions .cloudbuild/configs/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
steps:
- id: fetch github token
name: gcr.io/cloud-builders/gcloud
entrypoint: "bash"
args:
- "-c"
- "gcloud secrets versions access latest --secret=einride-bot-github-token --project=einride-terraform > github.token"

- id: setup git credentials
name: gcr.io/cloud-builders/gcloud
entrypoint: "bash"
args:
- "-c"
- |
echo -e "https://git:$(cat github.token)@github.com" > $${HOME}/.git-credentials \
&& git config --global credential.helper store \
&& git fetch --unshallow
volumes:
- name: "home-folder"
path: /root

- id: make
name: golang:1.16
args: ["make"]

- id: release go binaries
name: goreleaser/goreleaser
entrypoint: "/bin/sh"
args:
- "-c"
- 'export GITHUB_TOKEN="$(cat github.token)" && goreleaser'
volumes:
- name: "home-folder"
path: /root
5 changes: 3 additions & 2 deletions .cloudbuild/configs/review.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
steps:
- name: golang:1.16
args: ["make"]
- id: make
name: golang:1.16
args: ["make"]
8 changes: 8 additions & 0 deletions .cloudbuild/triggers/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: ghcomment-release
description: "Release pipeline"
filename: .cloudbuild/configs/release.yaml
github:
owner: einride
name: ghcomment
push:
tag: "^v.*"
2 changes: 1 addition & 1 deletion .cloudbuild/triggers/review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ github:
owner: einride
name: ghcomment
push:
branch: ".*"
branch: ".*"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
github.token
4 changes: 4 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
release:
github:
owner: einride
name: ghcomment
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ go-test:

.PHONY: go-build
go-build:
GOOS=darwin go build ./...
GOOS=windows go build ./...
GOOS=linux go build ./...
GOOS=darwin go build -o /dev/null ./...
GOOS=windows go build -o /dev/null ./...
GOOS=linux go build -o /dev/null ./...

.PHONY: go-mod-tidy
go-mod-tidy:
Expand Down

0 comments on commit d055cbb

Please sign in to comment.