Skip to content

Commit 9d10bbd

Browse files
authored
Refine GH workflows and Makefile (golang-templates#217)
1 parent 487dafd commit 9d10bbd

File tree

4 files changed

+35
-47
lines changed

4 files changed

+35
-47
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ jobs:
2929
- name: Upload coverage
3030
uses: actions/upload-artifact@v3
3131
with:
32-
name: coverage
32+
name: coverage-${{ matrix.os }}
3333
path: coverage.*
3434

35+
- run: goreleaser release --rm-dist --snapshot
36+
if: ${{ runner.os == 'Linux' }}
37+
3538
- name: Upload dist
3639
uses: actions/upload-artifact@v3
3740
with:
38-
name: dist
41+
name: dist-${{ matrix.os }}
3942
path: dist
4043

4144
- name: Upload coverage to Codecov
@@ -44,16 +47,3 @@ jobs:
4447
file: ./coverage.out
4548
flags: ${{ runner.os }}
4649

47-
release-test:
48-
runs-on: ubuntu-20.04
49-
steps:
50-
- uses: actions/checkout@v3
51-
with:
52-
fetch-depth: 0
53-
54-
- uses: actions/setup-go@v3
55-
with:
56-
go-version: 1.19
57-
58-
- name: Release test
59-
run: make build

.github/workflows/release.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ jobs:
2121
with:
2222
go-version: 1.19
2323

24+
- run: make install
25+
2426
- name: Login to GitHub Container Registry
2527
uses: docker/login-action@v2
2628
with:
2729
registry: ghcr.io
2830
username: ${{ github.actor }}
2931
password: ${{ secrets.GITHUB_TOKEN }}
3032

31-
- name: Release
32-
run: make release
33+
- run: goreleaser release
3334
env:
3435
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Upload dist
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: dist
41+
path: dist

CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased](https://github.com/golang-templates/seed/compare/v0.16.0...HEAD)
99

10+
### Fixed
11+
12+
- Improve GH workflows and Makefile. ([#217](https://github.com/golang-templates/seed/pull/217))
13+
1014
## [0.16.0](https://github.com/golang-templates/seed/releases/tag/v0.16.0)
1115

12-
### Added
16+
### Added
1317

14-
- Use go-acc. ([#208](https://github.com/golang-templates/seed/pull/208))
15-
- Add misspell. ([#211](https://github.com/golang-templates/seed/pull/211))
18+
- Use [go-acc](https://github.com/ory/go-acc). ([#208](https://github.com/golang-templates/seed/pull/208))
19+
- Add [misspell](https://github.com/client9/misspell). ([#211](https://github.com/golang-templates/seed/pull/211))
1620
- Document docker vs Git Bash workaround. ([#212](https://github.com/golang-templates/seed/pull/212))
1721

1822
### Changed
@@ -39,7 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3943

4044
## [0.15.0](https://github.com/golang-templates/seed/releases/tag/v0.15.0)
4145

42-
### Added
46+
### Added
4347

4448
- 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))
4549
- 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))

Makefile

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
SHELL := /bin/bash
22

33
.DEFAULT_GOAL := dev
4-
54
.PHONY: dev
65
dev: ## dev build
7-
dev: clean mod-tidy install misspell generate lint test
6+
dev: mod-tidy install misspell generate lint test build
87

98
.PHONY: ci
109
ci: ## CI build
1110
ci: dev diff
1211

12+
.PHONY: help
13+
help:
14+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
15+
1316
.PHONY: clean
1417
clean: ## remove files created during build pipeline
1518
$(call print-target)
1619
rm -rf dist
1720
rm -f coverage.*
21+
rm -f '"$(shell go env GOCACHE)/../golangci-lint"'
22+
go clean -i -cache -testcache -modcache -fuzzcache -x
1823

1924
.PHONY: mod-tidy
2025
mod-tidy: ## go mod tidy
@@ -48,36 +53,18 @@ test: ## go test
4853
go-acc --covermode=atomic --output=coverage.out ./... -- -race
4954
go tool cover -html=coverage.out -o coverage.html
5055

56+
.PHONY: build
57+
build: ## goreleaser build
58+
build:
59+
$(call print-target)
60+
goreleaser build --rm-dist --single-target --snapshot
61+
5162
.PHONY: diff
5263
diff: ## git diff
5364
$(call print-target)
5465
git diff --exit-code
5566
RES=$$(git status --porcelain) ; if [ -n "$$RES" ]; then echo $$RES && exit 1 ; fi
5667

57-
.PHONY: build
58-
build: ## goreleaser --snapshot --skip-publish --rm-dist
59-
build: install
60-
$(call print-target)
61-
goreleaser --snapshot --skip-publish --rm-dist
62-
63-
.PHONY: release
64-
release: ## goreleaser --rm-dist
65-
release: install
66-
$(call print-target)
67-
goreleaser --rm-dist
68-
69-
.PHONY: run
70-
run: ## go run
71-
@go run -race .
72-
73-
.PHONY: go-clean
74-
go-clean: ## go clean build, test and modules caches
75-
$(call print-target)
76-
go clean -r -i -cache -testcache -modcache
77-
78-
.PHONY: help
79-
help:
80-
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
8168

8269
define print-target
8370
@printf "Executing target: \033[36m$@\033[0m\n"

0 commit comments

Comments
 (0)