Skip to content

Commit f3f61c2

Browse files
committed
Ready for release binary
1 parent 69b3fe4 commit f3f61c2

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Test
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, macos-latest, windows-latest]
12+
steps:
13+
- uses: actions/checkout@master
14+
- name: Setup Go
15+
uses: actions/setup-go@v1
16+
with:
17+
go-version: 1.x
18+
- name: Test
19+
run: make test
20+
- name: Lint
21+
run: |
22+
export PATH=$PATH:$(go env GOPATH)/bin # will be removed
23+
make lint
24+
if: matrix.os != 'windows-latest'

.github/workflows/release.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@master
15+
- name: Setup Go
16+
uses: actions/setup-go@v1
17+
with:
18+
go-version: 1.x
19+
- name: Cross build
20+
run: |
21+
export PATH=$PATH:$(go env GOPATH)/bin # remove when actions/setup-go does this
22+
make cross
23+
- name: Create Release
24+
id: create_release
25+
uses: actions/create-release@master
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
with:
29+
tag_name: ${{ github.ref }}
30+
release_name: Release ${{ github.ref }}
31+
- name: Upload
32+
run: |
33+
export PATH=$PATH:$(go env GOPATH)/bin # remove when actions/setup-go does this
34+
make upload
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
BIN := godmine
2+
VERSION := $$(make -s show-version)
3+
VERSION_PATH := cmd/$(BIN)
4+
CURRENT_REVISION := $(shell git rev-parse --short HEAD)
5+
BUILD_LDFLAGS := "-s -w -X main.revision=$(CURRENT_REVISION)"
6+
GOBIN ?= $(shell go env GOPATH)/bin
7+
export GO111MODULE=on
8+
9+
.PHONY: all
10+
all: clean build
11+
12+
.PHONY: build
13+
build:
14+
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) ./cmd/$(BIN)
15+
16+
.PHONY: install
17+
install:
18+
go install -ldflags=$(BUILD_LDFLAGS) ./...
19+
20+
.PHONY: show-version
21+
show-version: $(GOBIN)/gobump
22+
@gobump show -r $(VERSION_PATH)
23+
24+
$(GOBIN)/gobump:
25+
@cd && go get github.com/motemen/gobump/cmd/gobump
26+
27+
.PHONY: cross
28+
cross: $(GOBIN)/goxz
29+
goxz -n $(BIN) -pv=v$(VERSION) -build-ldflags=$(BUILD_LDFLAGS) ./cmd/$(BIN)
30+
31+
$(GOBIN)/goxz:
32+
cd && go get github.com/Songmu/goxz/cmd/goxz
33+
34+
.PHONY: test
35+
test: build
36+
go test -v ./...
37+
38+
.PHONY: lint
39+
lint: $(GOBIN)/golint
40+
go vet ./...
41+
golint -set_exit_status ./...
42+
43+
$(GOBIN)/golint:
44+
cd && go get golang.org/x/lint/golint
45+
46+
.PHONY: clean
47+
clean:
48+
rm -rf $(BIN) goxz
49+
go clean
50+
51+
.PHONY: bump
52+
bump: $(GOBIN)/gobump
53+
ifneq ($(shell git status --porcelain),)
54+
$(error git workspace is dirty)
55+
endif
56+
ifneq ($(shell git rev-parse --abbrev-ref HEAD),master)
57+
$(error current branch is not master)
58+
endif
59+
@gobump up -w "$(VERSION_PATH)"
60+
git commit -am "bump up version to $(VERSION)"
61+
git tag "v$(VERSION)"
62+
git push origin master
63+
git push origin "refs/tags/v$(VERSION)"
64+
65+
.PHONY: upload
66+
upload: $(GOBIN)/ghr
67+
ghr "v$(VERSION)" goxz
68+
69+
$(GOBIN)/ghr:
70+
cd && go get github.com/tcnksm/ghr
71+

0 commit comments

Comments
 (0)