-
Notifications
You must be signed in to change notification settings - Fork 4
85 lines (73 loc) · 2.9 KB
/
release.yml
File metadata and controls
85 lines (73 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
on: release
name: upload release assets when release is published
jobs:
onReleasePublished:
name: on release published
runs-on: ubuntu-latest
steps:
- name: is release published?
if: github.event.action != 'published'
run: exit 1
uploadReleaseAssets:
name: upload release assets
runs-on: ubuntu-latest
needs: onReleasePublished
steps:
- name: set up go 1.12
id: go
uses: actions/setup-go@v1
with:
go-version: 1.12
- name: check out code into the go module directory
uses: actions/checkout@v1
- name: build artifacts
env:
GO_BUILD_OPTIONS: "-a -installsuffix cgo"
GO_BUILD_LDFLAGS: "-s -w"
GOARCH: amd64
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
export BUILD_DATE=$(date "+%Y-%m-%d")
export BUILD_COMMIT_HASH=$(git rev-parse --short HEAD 2> /dev/null)
export GO_BUILD_LDFLAGS="${GO_BUILD_LDFLAGS}
-X github.com/fulll/github/cmd.version=${TAG_NAME}
-X github.com/fulll/github/cmd.buildDate=${BUILD_DATE}
-X github.com/fulll/github/cmd.commitHash=${BUILD_COMMIT_HASH}
"
export GOOS=linux
export NAME=github-${GOOS}-${GOARCH}
printf "Building ${NAME}...\n"
go build ${GO_BUILD_OPTIONS} -ldflags "${GO_BUILD_LDFLAGS}" -o release/${NAME}
shasum -a 256 release/${NAME} > "release/${NAME}.sha256"
export GOOS=windows
export NAME=github-${GOOS}-${GOARCH}.exe
printf "Building ${NAME}...\n"
go build ${GO_BUILD_OPTIONS} -ldflags "${GO_BUILD_LDFLAGS}" -o release/${NAME}
shasum -a 256 release/${NAME} > "release/${NAME}.sha256"
export GOOS=darwin
export NAME=github-${GOOS}-${GOARCH}
printf "Building ${NAME}...\n"
go build ${GO_BUILD_OPTIONS} -ldflags "${GO_BUILD_LDFLAGS}" -o release/${NAME}
shasum -a 256 release/${NAME} > "release/${NAME}.sha256"
file ./release/*
./release/github-linux-amd64 version
- name: install hub cli
run: |
curl -s https://api.github.com/repos/github/hub/releases/latest |
jq -r '.assets[] | select(.name | contains("linux-amd64")) | .browser_download_url' |
wget -qi - -O - | sudo tar xzpf - -C / --strip-components=1
- name: upload artifacts
env:
TAG_NAME: ${{ github.event.release.tag_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions
hub release edit \
"${TAG_NAME}" \
-m "" \
-a ./release/github-darwin-amd64 \
-a ./release/github-darwin-amd64.sha256 \
-a ./release/github-linux-amd64 \
-a ./release/github-linux-amd64.sha256 \
-a ./release/github-windows-amd64.exe \
-a ./release/github-windows-amd64.exe.sha256