Skip to content

Commit 6a7915f

Browse files
committed
cd: build and upload binaries on release
1 parent 6f420c1 commit 6a7915f

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

.github/workflows/cd.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CD
2+
3+
on:
4+
# Versioned Tags
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
9+
jobs:
10+
# Build and test everything
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
# Checkout the code
15+
- name: Checkout Code
16+
uses: actions/checkout@v2
17+
18+
# Set up the GoLang environment
19+
- name: Set up Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.16
23+
24+
# Download all the tools used in the steps that follow
25+
- name: Set up Tools
26+
run: |
27+
go get -u github.com/mitchellh/gox
28+
go get -u golang.org/x/lint/golint
29+
30+
# Run all the unit-tests
31+
- name: Test
32+
run: |
33+
make test
34+
35+
# Build all the binaries for upload
36+
- name: Build Binaries
37+
run: |
38+
make dist
39+
40+
# Release binaries
41+
- name: Release
42+
uses: softprops/action-gh-release@v1
43+
with:
44+
files: |
45+
dist/go-sudoku*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
*.swp
33
.coverprofile
44
/.idea/
5+
/dist
56
/go-sudoku
67
/go-sudoku.exe

Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
.PHONY: all test
1+
.PHONY: all test dist
2+
3+
TOOLS := github.com/mitchellh/[email protected] \
4+
golang.org/x/lint/golint \
5+
6+
VERSION ?= dev
7+
ifdef GITHUB_REF_NAME
8+
VERSION = $(GITHUB_REF_NAME)
9+
endif
10+
211

312
default: run
413

@@ -15,7 +24,14 @@ demo-generate: build
1524
demo-solve: build
1625
./go-sudoku -format csv generate | ./go-sudoku -progress solve
1726

18-
fmt:
27+
dist:
28+
gox -ldflags="-s -w -X main.version=${VERSION}" \
29+
-os="linux darwin windows" \
30+
-arch="amd64" \
31+
-output="./dist/{{.Dir}}_{{.OS}}_{{.Arch}}" \
32+
.
33+
34+
fmt: tidy
1935
go fmt $(shell go list ./...)
2036

2137
gen: gen-readme
@@ -32,6 +48,9 @@ run:
3248
test: gen fmt lint vet build
3349
go test -cover -coverprofile=.coverprofile $(shell go list ./...)
3450

51+
tidy:
52+
go mod tidy
53+
3554
vet:
3655
go vet $(shell go list ./...)
3756

go-sudoku.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ var (
4949
flagSeed = flag.Int64("seed", 0, "RNG Seed (0 => random number based on time) [$SEED]")
5050
flagTheme = flag.String("theme", "none", "Table formatting theme ("+themes+")")
5151
flagType = flag.String("type", "default", "Sudoku Type ("+types+")")
52+
53+
// version
54+
version = "dev"
5255
)
5356

5457
func main() {
@@ -257,6 +260,8 @@ func printHelp() {
257260
258261
Usage: go-sudoku [flags] <action>
259262
263+
Version: ` + version + `
264+
260265
Actions:
261266
--------
262267
* generate: Generate a Sudoku Grid and apply the specified difficulty on it

0 commit comments

Comments
 (0)