From f451b9b83ca892938a8c5ece2e5d5ce91e647a99 Mon Sep 17 00:00:00 2001 From: Justin Harringa Date: Wed, 15 Sep 2021 13:31:12 -0700 Subject: [PATCH 1/7] Add goreleaser to workflows/ci.yaml --- .github/workflows/ci.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8757e59..24cc2e7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,4 +26,10 @@ jobs: - name: build and test binary run: make ci - name: docker build - run: make local-docker-build \ No newline at end of file + run: make local-docker-build + - name: GoReleaser Build + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: build --rm-dist \ No newline at end of file From bba85d18666f2fded837f3d357744f7c340ba91d Mon Sep 17 00:00:00 2001 From: Justin Harringa Date: Wed, 15 Sep 2021 14:05:53 -0700 Subject: [PATCH 2/7] Switch workflows/ci.yaml ref checkout->fetch-depth --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 24cc2e7..1a4cacb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: - name: checkout uses: actions/checkout@master with: - ref: ${{ github.ref }} + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v2 with: From 07feb8956326cd57b5d0cc7b7d8c39ca3ab6e59e Mon Sep 17 00:00:00 2001 From: Justin Harringa Date: Wed, 15 Sep 2021 14:29:29 -0700 Subject: [PATCH 3/7] goreleaser should run in --snapshot for CI --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1a4cacb..d4f94f0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,4 +32,4 @@ jobs: with: distribution: goreleaser version: latest - args: build --rm-dist \ No newline at end of file + args: build --snapshot --rm-dist From 140303c629702deb6c067060855fb9a4d3e1a6c1 Mon Sep 17 00:00:00 2001 From: Justin Harringa Date: Wed, 15 Sep 2021 14:38:08 -0700 Subject: [PATCH 4/7] Use goreleaser release without publish --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d4f94f0..74e3356 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,4 +32,4 @@ jobs: with: distribution: goreleaser version: latest - args: build --snapshot --rm-dist + args: release --skip-publish --snapshot --rm-dist From fde6935281537276a45e4156831c6d92359006ab Mon Sep 17 00:00:00 2001 From: Justin Harringa Date: Wed, 15 Sep 2021 14:56:14 -0700 Subject: [PATCH 5/7] Remove bin dir for ci-result-to-slack --- .gitignore | 2 +- .goreleaser.yml | 1 - Dockerfile | 2 +- Makefile | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index eb0abc5..063ec93 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ .idea # Build / CI artifacts -bin +/ci-result-to-slack coverage.out diff --git a/.goreleaser.yml b/.goreleaser.yml index 1da8b63..d300ca1 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,7 +2,6 @@ project_name: ci-result-to-slack builds: - env: [CGO_ENABLED=0] main: ./cmd/ci-result-to-slack - binary: bin/ci-result-to-slack goos: - linux - windows diff --git a/Dockerfile b/Dockerfile index e2ca579..2647819 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM gcr.io/distroless/base-debian11 -COPY ./bin/ci-result-to-slack /ci-result-to-slack +COPY ./ci-result-to-slack /ci-result-to-slack ENTRYPOINT ["/ci-result-to-slack"] diff --git a/Makefile b/Makefile index 0d169d2..013b606 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ ci: build test build: clean @echo "Building..." - CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o bin/$(BINARY_NAME) ./cmd/$(BINARY_NAME)/main.go + CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o $(BINARY_NAME) ./cmd/$(BINARY_NAME)/main.go test: clean @echo "Running unit tests..." @@ -23,7 +23,7 @@ lint: clean: @echo "Cleaning..." - rm -rf ./bin/$(BINARY_NAME) + rm -rf .$(BINARY_NAME) rm -rf coverage.out local-docker-test: ## Build and run unit tests in docker container like CI without building the container From 72a5e63e241c88930efc3eee341d7242fba538d9 Mon Sep 17 00:00:00 2001 From: Justin Harringa Date: Wed, 15 Sep 2021 14:56:48 -0700 Subject: [PATCH 6/7] Add go module cache to CI --- .github/workflows/ci.yaml | 7 +++++++ .github/workflows/release.yml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 74e3356..9eebd0d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,6 +23,13 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.17 + - name: Cache Go modules + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - name: build and test binary run: make ci - name: docker build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7779886..df48d4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,13 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.17 + - name: Cache Go modules + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - name: Docker Login uses: docker/login-action@v1 with: From 528beda7d54224fad4492de2912eba1ec2be616c Mon Sep 17 00:00:00 2001 From: Justin Harringa Date: Wed, 15 Sep 2021 15:01:26 -0700 Subject: [PATCH 7/7] GoReleaser will build container, remove redundant --- .github/workflows/ci.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9eebd0d..0074ce4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,8 +32,6 @@ jobs: ${{ runner.os }}-go- - name: build and test binary run: make ci - - name: docker build - run: make local-docker-build - name: GoReleaser Build uses: goreleaser/goreleaser-action@v2 with: