From 91cda536a1dab79e3483f3672c66a40fecf7a952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 16:32:02 +0200 Subject: [PATCH 01/12] Add goreleaser build to CI workflow --- .github/workflows/release.yml | 2 +- Makefile | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad7cb7d..bd81954 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,6 +29,6 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Release - run: make release + run: make install release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index 348f689..5b24532 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SHELL := /bin/bash .PHONY: dev dev: ## dev build -dev: clean mod-tidy install misspell generate lint test +dev: clean mod-tidy install misspell generate lint test build .PHONY: ci ci: ## CI build @@ -55,16 +55,15 @@ diff: ## git diff RES=$$(git status --porcelain) ; if [ -n "$$RES" ]; then echo $$RES && exit 1 ; fi .PHONY: build -build: ## goreleaser --snapshot --skip-publish --rm-dist -build: install +build: ## goreleaser build +build: $(call print-target) - goreleaser --snapshot --skip-publish --rm-dist + goreleaser build --rm-dist --single-target .PHONY: release -release: ## goreleaser --rm-dist -release: install +release: ## goreleaser release $(call print-target) - goreleaser --rm-dist + goreleaser release --rm-dist .PHONY: run run: ## go run From 5772d9df4b6c6df8cf75806058bde91f688c8cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 16:41:17 +0200 Subject: [PATCH 02/12] Fix --- .github/workflows/build.yml | 16 +++------------- .github/workflows/release.yml | 5 +++-- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed8e6bc..d969b04 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,9 @@ jobs: name: coverage path: coverage.* + - run: goreleaser release --rm-dist --snapshot + if: ${{ runner.os == 'Linux' }} + - name: Upload dist uses: actions/upload-artifact@v3 with: @@ -44,16 +47,3 @@ jobs: file: ./coverage.out flags: ${{ runner.os }} - release-test: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - - name: Release test - run: make build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd81954..d8923cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,8 @@ jobs: with: go-version: 1.19 + - run: make install + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: @@ -28,7 +30,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Release - run: make install release + - run: goreleaser release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ed90fef3bf1cbf4da1c1c938f101c2179b7f656f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 16:48:12 +0200 Subject: [PATCH 03/12] Upload dist when release --- .github/workflows/release.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8923cc..f127034 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,3 +33,9 @@ jobs: - run: goreleaser release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload dist + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist From 8040c0da7861997cb25db16ceb4457be3de0e458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 17:02:34 +0200 Subject: [PATCH 04/12] Cleanup --- Makefile | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 5b24532..a93386e 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,29 @@ SHELL := /bin/bash +### Pipelines: + .DEFAULT_GOAL := dev .PHONY: dev dev: ## dev build -dev: clean mod-tidy install misspell generate lint test build +dev: mod-tidy install misspell generate lint test build .PHONY: ci ci: ## CI build ci: dev diff +### Tasks: + +.PHONY: help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + .PHONY: clean clean: ## remove files created during build pipeline $(call print-target) rm -rf dist rm -f coverage.* + go clean -r -i -cache -testcache -modcache .PHONY: mod-tidy mod-tidy: ## go mod tidy @@ -54,29 +63,6 @@ diff: ## git diff git diff --exit-code RES=$$(git status --porcelain) ; if [ -n "$$RES" ]; then echo $$RES && exit 1 ; fi -.PHONY: build -build: ## goreleaser build -build: - $(call print-target) - goreleaser build --rm-dist --single-target - -.PHONY: release -release: ## goreleaser release - $(call print-target) - goreleaser release --rm-dist - -.PHONY: run -run: ## go run - @go run -race . - -.PHONY: go-clean -go-clean: ## go clean build, test and modules caches - $(call print-target) - go clean -r -i -cache -testcache -modcache - -.PHONY: help -help: - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' define print-target @printf "Executing target: \033[36m$@\033[0m\n" From 077d75cb32fb4381c68cfce53b56b905b4e29522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 17:08:02 +0200 Subject: [PATCH 05/12] Fix --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index a93386e..703d5c1 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,12 @@ test: ## go test go-acc --covermode=atomic --output=coverage.out ./... -- -race go tool cover -html=coverage.out -o coverage.html +.PHONY: build +build: ## goreleaser build +build: + $(call print-target) + goreleaser build --rm-dist --single-target --snapshot + .PHONY: diff diff: ## git diff $(call print-target) From cc87a55e59eab30e38aee8b564befe339e05b2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 17:20:55 +0200 Subject: [PATCH 06/12] Update the changelog --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4481ab..3ddb311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/golang-templates/seed/compare/v0.16.0...HEAD) +### Changed + +- Refine GH workflows and Makefile. ([#217](https://github.com/golang-templates/seed/pull/217)) + ## [0.16.0](https://github.com/golang-templates/seed/releases/tag/v0.16.0) -### Added +### Added - Use go-acc. ([#208](https://github.com/golang-templates/seed/pull/208)) - Add misspell. ([#211](https://github.com/golang-templates/seed/pull/211)) @@ -39,7 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.15.0](https://github.com/golang-templates/seed/releases/tag/v0.15.0) -### Added +### Added - Add [CHANGELOG.md](CHANGELOG.md) based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ([#131](https://github.com/golang-templates/seed/pull/131)) - Add [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) based on [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct/). ([#133](https://github.com/golang-templates/seed/pull/133)) From a847d695205966f8c831cd37c34a51fc16a109ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 17:27:13 +0200 Subject: [PATCH 07/12] Named artifacts --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d969b04..9488a61 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: - name: Upload coverage uses: actions/upload-artifact@v3 with: - name: coverage + name: coverage-${{ matrix.os }} path: coverage.* - run: goreleaser release --rm-dist --snapshot @@ -38,7 +38,7 @@ jobs: - name: Upload dist uses: actions/upload-artifact@v3 with: - name: dist + name: dist-${{ matrix.os }} path: dist - name: Upload coverage to Codecov From 756d02aeb16e641acf747045880786941f0132cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 17:28:21 +0200 Subject: [PATCH 08/12] Fixed --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ddb311..fe8973a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/golang-templates/seed/compare/v0.16.0...HEAD) -### Changed +### Fixed -- Refine GH workflows and Makefile. ([#217](https://github.com/golang-templates/seed/pull/217)) +- Improve GH workflows and Makefile. ([#217](https://github.com/golang-templates/seed/pull/217)) ## [0.16.0](https://github.com/golang-templates/seed/releases/tag/v0.16.0) From d0a7c4f53c03e109b0f1f7dabac6ed6205ea637d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 17:33:25 +0200 Subject: [PATCH 09/12] Update the changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe8973a..46913aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Use go-acc. ([#208](https://github.com/golang-templates/seed/pull/208)) -- Add misspell. ([#211](https://github.com/golang-templates/seed/pull/211)) +- Use [go-acc](https://github.com/ory/go-acc). ([#208](https://github.com/golang-templates/seed/pull/208)) +- Add [misspell](https://github.com/client9/misspell). ([#211](https://github.com/golang-templates/seed/pull/211)) - Document docker vs Git Bash workaround. ([#212](https://github.com/golang-templates/seed/pull/212)) ### Changed From 0530e1b301ee9ac0d3b75038c956ac921f794f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 18:00:15 +0200 Subject: [PATCH 10/12] Improve clean --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 703d5c1..05733fa 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,8 @@ clean: ## remove files created during build pipeline $(call print-target) rm -rf dist rm -f coverage.* - go clean -r -i -cache -testcache -modcache + rm -f '"$(shell go env GOCACHE)/../golangci-lint"' + go clean -i -cache -testcache -modcache -fuzzcache -x .PHONY: mod-tidy mod-tidy: ## go mod tidy From 00f6c9dc4161a5c357778ccf8f35fc90a218a407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 18:04:30 +0200 Subject: [PATCH 11/12] clean --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index 05733fa..2522de1 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ SHELL := /bin/bash -### Pipelines: - .DEFAULT_GOAL := dev .PHONY: dev @@ -12,8 +10,6 @@ dev: mod-tidy install misspell generate lint test build ci: ## CI build ci: dev diff -### Tasks: - .PHONY: help help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' From eeb1682b2f5cea5fc5cf5d82d957e3e168448c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 12 Oct 2022 18:04:54 +0200 Subject: [PATCH 12/12] clean --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 2522de1..7aee9f5 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ SHELL := /bin/bash .DEFAULT_GOAL := dev - .PHONY: dev dev: ## dev build dev: mod-tidy install misspell generate lint test build