Skip to content

Commit

Permalink
Refine GH workflows and Makefile (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared authored Oct 12, 2022
1 parent 487dafd commit 9d10bbd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 47 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ jobs:
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage
name: coverage-${{ matrix.os }}
path: coverage.*

- run: goreleaser release --rm-dist --snapshot
if: ${{ runner.os == 'Linux' }}

- name: Upload dist
uses: actions/upload-artifact@v3
with:
name: dist
name: dist-${{ matrix.os }}
path: dist

- name: Upload coverage to Codecov
Expand All @@ -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
11 changes: 9 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ jobs:
with:
go-version: 1.19

- run: make install

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Release
run: make release
- run: goreleaser release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload dist
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ 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)

### Fixed

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

### 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))
- 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
Expand All @@ -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))
Expand Down
39 changes: 13 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
SHELL := /bin/bash

.DEFAULT_GOAL := dev

.PHONY: dev
dev: ## dev build
dev: clean mod-tidy install misspell generate lint test
dev: mod-tidy install misspell generate lint test build

.PHONY: ci
ci: ## CI build
ci: dev diff

.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.*
rm -f '"$(shell go env GOCACHE)/../golangci-lint"'
go clean -i -cache -testcache -modcache -fuzzcache -x

.PHONY: mod-tidy
mod-tidy: ## go mod tidy
Expand Down Expand Up @@ -48,36 +53,18 @@ 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)
git diff --exit-code
RES=$$(git status --porcelain) ; if [ -n "$$RES" ]; then echo $$RES && exit 1 ; fi

.PHONY: build
build: ## goreleaser --snapshot --skip-publish --rm-dist
build: install
$(call print-target)
goreleaser --snapshot --skip-publish --rm-dist

.PHONY: release
release: ## goreleaser --rm-dist
release: install
$(call print-target)
goreleaser --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"
Expand Down

0 comments on commit 9d10bbd

Please sign in to comment.