1
1
on : release
2
2
3
- name : Upload release assets
3
+ name : Upload release assets when release is published
4
4
jobs :
5
+ onReleasePublished :
6
+ name : On release published
7
+ runs-on : ubuntu-latest
8
+
9
+ steps :
10
+ - name : Is release published?
11
+ if : github.event.action != 'published'
12
+ run : exit 78
13
+
5
14
uploadReleaseAssets :
6
15
name : Upload release assets
7
16
runs-on : ubuntu-latest
8
- steps :
17
+ needs : onReleasePublished
9
18
19
+ steps :
10
20
- name : set up Go 1.12
21
+ id : go
11
22
uses : actions/setup-go@v1
12
23
with :
13
24
go-version : 1.12
14
- id : go
15
25
16
26
- name : Check out code into the Go module directory
17
27
uses : actions/checkout@v1
@@ -20,33 +30,36 @@ jobs:
20
30
env :
21
31
GO_BUILD_OPTIONS : " -a -installsuffix cgo"
22
32
GO_BUILD_LDFLAGS : " -s -w"
23
- CGO_ENABLED : 0
24
33
GOARCH : amd64
25
34
TAG_NAME : ${{ github.event.release.tag_name }}
26
35
run : |
27
- BUILD_DATE=$(date "+%Y-%m-%d")
28
- BUILD_COMMIT_HASH=$(git rev-parse --short HEAD 2> /dev/null)
29
- GO_BUILD_LDFLAGS="${GO_BUILD_LDFLAGS}
36
+ export BUILD_DATE=$(date "+%Y-%m-%d")
37
+ export BUILD_COMMIT_HASH=$(git rev-parse --short HEAD 2> /dev/null)
38
+ export GO_BUILD_LDFLAGS="${GO_BUILD_LDFLAGS}
30
39
-X github.com/inextensodigital/github/cmd.version=${TAG_NAME}
31
40
-X github.com/inextensodigital/github/cmd.buildDate=${BUILD_DATE}
32
41
-X github.com/inextensodigital/github/cmd.commitHash=${BUILD_COMMIT_HASH}
33
42
"
34
43
35
- GOOS=linux
36
- NAME=github-${GOOS}-${GOARCH}
44
+ export GOOS=darwin
45
+ export NAME=github-${GOOS}-${GOARCH}
46
+ printf "Building ${NAME}..."
37
47
go build ${GO_BUILD_OPTIONS} -ldflags "${GO_BUILD_LDFLAGS}" -o release/${NAME}
38
- shasum -a 256 release/" ${NAME}" > "release/${NAME}.sha256"
48
+ shasum -a 256 release/${NAME} > "release/${NAME}.sha256"
39
49
40
- GOOS=darwin
41
- NAME=github-${GOOS}-${GOARCH}
42
- CGO_ENABLED=1 go build ${GO_BUILD_OPTIONS} -ldflags "${GO_BUILD_LDFLAGS}" -o release/${NAME}
43
- shasum -a 256 release/"${NAME}" > "release/${NAME}.sha256"
50
+ export GOOS=windows
51
+ export NAME=github-${GOOS}-${GOARCH}.exe
52
+ printf "Building ${NAME}..."
53
+ go build ${GO_BUILD_OPTIONS} -ldflags "${GO_BUILD_LDFLAGS}" -o release/${NAME}
54
+ shasum -a 256 release/${NAME} > "release/${NAME}.sha256"
44
55
45
- GOOS=windows
46
- NAME=github-${GOOS}-${GOARCH}.exe
56
+ export GOOS=darwin
57
+ export NAME=github-${GOOS}-${GOARCH}
58
+ printf "Building ${NAME}..."
47
59
go build ${GO_BUILD_OPTIONS} -ldflags "${GO_BUILD_LDFLAGS}" -o release/${NAME}
48
- shasum -a 256 release/" ${NAME}" > "release/${NAME}.sha256"
60
+ shasum -a 256 release/${NAME} > "release/${NAME}.sha256"
49
61
62
+ file ./release/*
50
63
./release/github-linux-amd64 version
51
64
52
65
- name : Install hub cli
@@ -58,13 +71,16 @@ jobs:
58
71
- name : Upload artifacts
59
72
env :
60
73
TAG_NAME : ${{ github.event.release.tag_name }}
74
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61
75
run : |
62
- hub release edit
63
- -m ""
64
- -a ./release/github-linux-amd64
65
- -a ./release/github-linux-amd64.sha256
66
- -a ./release/github-darwin-amd64
67
- -a ./release/github-darwin-amd64.sha256
68
- -a ./release/github-windows-amd64.exe
76
+ # https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions
77
+ echo "GITHUB_ACTOR: ${GITHUB_ACTOR}"
78
+ GITHUB_USER=${GITHUB_ACTOR}; hub release edit \
79
+ "${TAG_NAME}" \
80
+ -m "" \
81
+ -a ./release/github-darwin-amd64 \
82
+ -a ./release/github-darwin-amd64.sha256 \
83
+ -a ./release/github-linux-amd64 \
84
+ -a ./release/github-linux-amd64.sha256 \
85
+ -a ./release/github-windows-amd64.exe \
69
86
-a ./release/github-windows-amd64.exe.sha256
70
- ${TAG_NAME}
0 commit comments