This repository was archived by the owner on Mar 7, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +128
-0
lines changed
Expand file tree Collapse file tree 3 files changed +128
-0
lines changed Original file line number Diff line number Diff line change 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+ - 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 : Add $GOPATH/bin to $PATH
20+ run : echo "::add-path::$(go env GOPATH)/bin"
21+ - name : Test
22+ run : make test
23+ - name : Lint
24+ run : make lint
Original file line number Diff line number Diff line change 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 : Add $GOPATH/bin to $PATH
20+ run : echo "::add-path::$(go env GOPATH)/bin"
21+ - name : Cross build
22+ run : 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 : make upload
33+ env :
34+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1+ BIN := code2img
2+ VERSION := $$(make -s show-version )
3+ VERSION_PATH := .
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 )
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/x-motemen/gobump/cmd/gobump
26+
27+ .PHONY : cross
28+ cross : $(GOBIN ) /goxz
29+ goxz -n $(BIN ) -pv=v$(VERSION ) -build-ldflags=$(BUILD_LDFLAGS )
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
You can’t perform that action at this time.
0 commit comments