Skip to content

Commit b0fcb11

Browse files
committed
Updated workflow
1 parent 99671dd commit b0fcb11

File tree

3 files changed

+44
-67
lines changed

3 files changed

+44
-67
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
1-
name: Build
1+
name: Build and test
22
on: [push]
33
jobs:
4-
54
build:
6-
name: Build
75
runs-on: ubuntu-latest
86
steps:
9-
10-
- name: Set up Go 1.13
11-
uses: actions/setup-go@v1
7+
- uses: actions/setup-go@v1
128
with:
139
go-version: 1.13
14-
id: go
15-
16-
- name: Check out code into the Go module directory
17-
uses: actions/checkout@v2
18-
19-
- name: Get dependencies
20-
run: |
21-
go get -v -t -d ./...
22-
if [ -f Gopkg.toml ]; then
23-
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
24-
dep ensure
25-
fi
26-
27-
- name: Build
28-
run: go build -v .
10+
- uses: actions/checkout@v2
11+
- run: make -j all
12+
- run: make -j test

.github/workflows/release.yml

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,16 @@
1-
name: Release
2-
on: release
1+
name: Build and release
2+
on:
3+
release:
4+
types: [published]
35
jobs:
4-
release-linux-amd64:
5-
name: release linux/amd64
6+
build:
67
runs-on: ubuntu-latest
78
steps:
8-
- uses: actions/checkout@master
9-
- name: compile and release
10-
11-
env:
12-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13-
GOARCH: amd64
14-
GOOS: linux
15-
release-darwin-amd64:
16-
name: release darwin/amd64
17-
runs-on: ubuntu-latest
18-
steps:
19-
- uses: actions/checkout@master
20-
- name: compile and release
21-
22-
env:
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24-
GOARCH: amd64
25-
GOOS: darwin
26-
release-windows-386:
27-
name: release windows/386
28-
runs-on: ubuntu-latest
29-
steps:
30-
- uses: actions/checkout@master
31-
- name: compile and release
32-
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
GOARCH: "386"
36-
GOOS: windows
37-
release-windows-amd64:
38-
name: release windows/amd64
39-
runs-on: ubuntu-latest
40-
steps:
41-
- uses: actions/checkout@master
42-
- name: compile and release
43-
44-
env:
45-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46-
GOARCH: amd64
47-
GOOS: windows
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-go@v1
11+
with:
12+
go-version: 1.13
13+
- run: make -j upload
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
GITHUB_RELEASE_UPLOAD_URL: ${{ github.event.release.upload_url }}

Makefile

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,36 @@ win64:
1717
win32:
1818
GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
1919

20+
21+
test: test-linux test-macos test-win64 test-win32
22+
23+
test-linux:
24+
GOARCH=amd64 GOOS=linux go test
25+
26+
test-macos:
27+
GOARCH=amd64 GOOS=darwin go test
28+
29+
test-win64:
30+
GOARCH=amd64 GOOS=windows go test
31+
32+
test-win32:
33+
GOARCH=386 GOOS=windows go test
34+
2035
releases: linux macos win64 win32
2136
chmod +x $(BINDIR)/$(NAME)-*
2237
gzip $(BINDIR)/$(NAME)-linux
2338
gzip $(BINDIR)/$(NAME)-macos
24-
zip -m -j $(BINDIR)/$(NAME)-win64.zip $(BINDIR)/$(NAME)-win64.exe
2539
zip -m -j $(BINDIR)/$(NAME)-win32.zip $(BINDIR)/$(NAME)-win32.exe
40+
zip -m -j $(BINDIR)/$(NAME)-win64.zip $(BINDIR)/$(NAME)-win64.exe
2641

2742
clean:
28-
rm $(BINDIR)/*
43+
rm $(BINDIR)/*
44+
45+
# Remove trailing {} from the release upload url
46+
GITHUB_UPLOAD_URL=$(shell echo $${GITHUB_RELEASE_UPLOAD_URL%\{*})
47+
48+
upload: releases
49+
curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/gzip" --data-binary @$(BINDIR)/$(NAME)-linux.gz "$(GITHUB_UPLOAD_URL)?name=$(NAME)-linux.gz"
50+
curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/gzip" --data-binary @$(BINDIR)/$(NAME)-macos.gz "$(GITHUB_UPLOAD_URL)?name=$(NAME)-macos.gz"
51+
curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/zip" --data-binary @$(BINDIR)/$(NAME)-win64.zip "$(GITHUB_UPLOAD_URL)?name=$(NAME)-win64.zip"
52+
curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/zip" --data-binary @$(BINDIR)/$(NAME)-win32.zip "$(GITHUB_UPLOAD_URL)?name=$(NAME)-win32.zip"

0 commit comments

Comments
 (0)