Skip to content

Commit 894b9bf

Browse files
authored
Add GoReleaser
1 parent 9afb581 commit 894b9bf

File tree

7 files changed

+55
-9
lines changed

7 files changed

+55
-9
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: build
2-
on: push
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
38
jobs:
49
ci-build:
510
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Unshallow
14+
run: git fetch --prune --unshallow
15+
- name: Release
16+
run: make docker args="-e GITHUB_TOKEN" run="make all publish"
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
1616

17+
# Output of GoReleaser
18+
dist/
19+
1720
# Visual Studio Code files
1821
.vscode/*
1922
!.vscode/settings.json

.goreleaser.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build:
2+
skip: true
3+
release:
4+
github:
5+
prerelease: auto

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
.PHONY: all
44
all: ## full build
5-
all: clean install build fmt lint test
5+
all: clean install build fmt lint test release
66

77
.PHONY: dev
88
dev: ## fast build
9-
dev: install build fmt lint-fast test
9+
dev: build fmt lint-fast test
1010

1111
.PHONY: clean
1212
clean: ## go clean
@@ -43,9 +43,20 @@ test: ## go test with race detector and code covarage
4343
$(call print-target)
4444
go test -race -covermode=atomic ./...
4545

46+
.PHONY: release
47+
release: ## goreleaser --snapshot --skip-publish --rm-dist
48+
$(call print-target)
49+
goreleaser --snapshot --skip-publish --rm-dist
50+
51+
.PHONY: publish
52+
publish:
53+
$(call print-target)
54+
@test -n "$(CI)" || (echo "$@ should be running only on CI Server" && exit 1)
55+
goreleaser --rm-dist
56+
4657
.PHONY: docker
4758
docker: ## run in golang container, example: make docker run="make all"
48-
docker run --rm -v $(CURDIR):/app golang:1.14 sh -c "cd /app && $(run)"
59+
docker run --rm -v $(CURDIR):/app golang:1.14 $(args) sh -c "cd /app && $(run)"
4960

5061
.PHONY: help
5162
help:

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ It includes:
1515
- [Visual Studio Code](https://code.visualstudio.com) configuration with [Go](https://code.visualstudio.com/docs/languages/go) and [Remote Container](https://code.visualstudio.com/docs/remote/containers) support,
1616
- dependency management using [Go Modules](https://github.com/golang/go/wiki/Modules),
1717
- linting with [GolangCI-Lint](https://github.com/golangci/golangci-lint),
18-
- build automation via [Make](https://www.gnu.org/software/make), [Docker](https://docs.docker.com/engine), [GitHub Actions](https://github.com/features/actions).
18+
- build automation via [Make](https://www.gnu.org/software/make), [Docker](https://docs.docker.com/engine), [GitHub Actions](https://github.com/features/actions),
19+
- releasing using [GoReleaser](https://github.com/goreleaser/goreleaser).
1920

2021
`Star` this repository if you find it valuable and worth maintaining.
2122

@@ -57,6 +58,7 @@ It includes:
5758
1. Update Go version in [Makefile](Makefile) and [devcontainer.json](.devcontainer/devcontainer.json).
5859
1. Update and add additional build tools in [install.sh](install.sh).
5960
1. Configure linters via [.golangci.yml](.golangci.yml).
61+
1. Update release configuration in [.goreleaser.yml](.goreleaser.yml).
6062
1. Develop Make targets in [Makefile](Makefile).
6163

6264
Notable files:

install.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
echo Installing goimports...
45
cd && GO111MODULE=on go get golang.org/x/tools/cmd/goimports@master && cd - > /dev/null
56

6-
if ! [ -x "$(command -v golangci-lint)" ] || [ "$(golangci-lint --version)" != "golangci-lint has version 1.27.0 built from fb74c2e on 2020-05-13T18:48:26Z" ] ; then
7-
echo Installing golangci-lint...
8-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
9-
fi
7+
echo Installing GolangCI-Lint...
8+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)/bin" v1.26.0
9+
10+
echo Installing GoReleaser...
11+
curl -sSfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh -s -- -b "$(go env GOPATH)/bin" v0.137.0

0 commit comments

Comments
 (0)