diff --git a/.cloudbuild/Makefile b/.cloudbuild/Makefile index a4decee..07a89a8 100644 --- a/.cloudbuild/Makefile +++ b/.cloudbuild/Makefile @@ -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=$< diff --git a/.cloudbuild/configs/release.yaml b/.cloudbuild/configs/release.yaml new file mode 100644 index 0000000..7a9a4bf --- /dev/null +++ b/.cloudbuild/configs/release.yaml @@ -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 diff --git a/.cloudbuild/configs/review.yaml b/.cloudbuild/configs/review.yaml index bc04052..64d4b98 100644 --- a/.cloudbuild/configs/review.yaml +++ b/.cloudbuild/configs/review.yaml @@ -1,3 +1,4 @@ steps: - - name: golang:1.16 - args: ["make"] \ No newline at end of file + - id: make + name: golang:1.16 + args: ["make"] diff --git a/.cloudbuild/triggers/release.yaml b/.cloudbuild/triggers/release.yaml new file mode 100644 index 0000000..ed067e6 --- /dev/null +++ b/.cloudbuild/triggers/release.yaml @@ -0,0 +1,8 @@ +name: ghcomment-release +description: "Release pipeline" +filename: .cloudbuild/configs/release.yaml +github: + owner: einride + name: ghcomment + push: + tag: "^v.*" diff --git a/.cloudbuild/triggers/review.yaml b/.cloudbuild/triggers/review.yaml index 697b690..abe7fa6 100644 --- a/.cloudbuild/triggers/review.yaml +++ b/.cloudbuild/triggers/review.yaml @@ -5,4 +5,4 @@ github: owner: einride name: ghcomment push: - branch: ".*" \ No newline at end of file + branch: ".*" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..58856ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +github.token diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..3fdb4c7 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,4 @@ +release: + github: + owner: einride + name: ghcomment diff --git a/Makefile b/Makefile index e435532..8745621 100644 --- a/Makefile +++ b/Makefile @@ -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: