1
+ # GitHub release workflow.
2
+ #
3
+ # This workflow is a bit complicated because we have to build darwin binaries on
4
+ # a mac runner, but the mac runners are extremely slow. So instead of running
5
+ # the entire release on a mac (which will take an hour to run), we run only the
6
+ # mac build on a mac, and the rest on a linux runner. The final release is then
7
+ # published using a final linux runner.
1
8
name : release
2
9
on :
3
10
push :
4
11
tags :
5
12
- " v*"
6
13
workflow_dispatch :
14
+ inputs :
15
+ snapshot :
16
+ description : Allow a +dev version to be generated, implies dry_run.
17
+ type : boolean
18
+ required : true
19
+ dry_run :
20
+ description : Perform a dry-run release.
21
+ type : boolean
22
+ required : true
23
+
24
+ # In a non-snapshot we want the ./scripts/version.sh script to never generate a
25
+ # +dev version.
26
+ env :
27
+ CODER_NO_DEV_VERSION : ${{ github.event.inputs.snapshot || 'true' }}
7
28
8
29
jobs :
9
- goreleaser :
10
- runs-on : macos-latest
11
- env :
12
- # Necessary for Docker manifest
13
- DOCKER_CLI_EXPERIMENTAL : " enabled"
30
+ linux-windows :
31
+ runs-on : ubuntu-latest
14
32
steps :
15
- # Docker is not included on macos-latest
16
- - uses : docker-practice/actions-setup-docker@1.0.10
17
-
18
33
- uses : actions/checkout@v3
19
34
with :
20
35
fetch-depth : 0
21
36
22
- - name : Set up QEMU
23
- uses : docker/setup-qemu-action@v2
37
+ - uses : actions/setup-go@v3
38
+ with :
39
+ go-version : " ~1.18"
24
40
25
- - name : Docker Login
26
- uses : docker/login-action@v2
41
+ - name : Cache Node
42
+ id : cache-node
43
+ uses : actions/cache@v3
27
44
with :
28
- registry : ghcr.io
29
- username : ${{ github.repository_owner }}
30
- password : ${{ secrets.GITHUB_TOKEN }}
45
+ path : |
46
+ **/node_modules
47
+ .eslintcache
48
+ key : js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
49
+ restore-keys : |
50
+ js-${{ runner.os }}-
51
+
52
+ - name : Build Site
53
+ run : make site/out/index.html
54
+
55
+ - name : Build Slim Binaries
56
+ run : make bin
57
+
58
+ - name : Build Linux and Windows Binaries
59
+ run : |
60
+ ./scripts/build_go_matrix.sh \
61
+ --output ./dist/ \
62
+ --archive \
63
+ --package-linux \
64
+ linux:amd64,armv7,arm64 \
65
+ windows:amd64,arm64
66
+
67
+ - name : Upload binary artifacts
68
+ uses : actions/upload-artifact@v3
69
+ with :
70
+ name : linux
71
+ path : |
72
+ dist/*.zip
73
+ dist/*.tar.gz
74
+ dist/*.apk
75
+ dist/*.deb
76
+ dist/*.rpm
77
+
78
+ # The mac binaries get built on mac runners because they need to be signed,
79
+ # and the signing tool only runs on mac. This darwin job only builds the Mac
80
+ # binaries and uploads them as job artifacts used by the publish step.
81
+ darwin :
82
+ runs-on : macos-latest
83
+ steps :
84
+ - uses : actions/checkout@v3
85
+ with :
86
+ fetch-depth : 0
31
87
32
88
- uses : actions/setup-go@v3
33
89
with :
34
90
go-version : " ~1.18"
35
91
36
- - name : Install Gon
92
+ - name : Install gon
37
93
run : |
38
94
brew tap mitchellh/gon
39
95
brew install mitchellh/gon/gon
@@ -44,24 +100,6 @@ jobs:
44
100
p12-file-base64 : ${{ secrets.AC_CERTIFICATE_P12_BASE64 }}
45
101
p12-password : ${{ secrets.AC_CERTIFICATE_PASSWORD }}
46
102
47
- - name : Echo Go Cache Paths
48
- id : go-cache-paths
49
- run : |
50
- echo "::set-output name=go-build::$(go env GOCACHE)"
51
- echo "::set-output name=go-mod::$(go env GOMODCACHE)"
52
-
53
- - name : Go Build Cache
54
- uses : actions/cache@v3
55
- with :
56
- path : ${{ steps.go-cache-paths.outputs.go-build }}
57
- key : ${{ runner.os }}-release-go-build-${{ hashFiles('**/go.sum') }}
58
-
59
- - name : Go Mod Cache
60
- uses : actions/cache@v3
61
- with :
62
- path : ${{ steps.go-cache-paths.outputs.go-mod }}
63
- key : ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
64
-
65
103
- name : Cache Node
66
104
id : cache-node
67
105
uses : actions/cache@v3
@@ -79,12 +117,72 @@ jobs:
79
117
- name : Build Site
80
118
run : make site/out/index.html
81
119
82
- - name : Run GoReleaser
83
- uses : goreleaser/goreleaser-action@v3
84
- with :
85
- version : latest
86
- args : release --rm-dist --timeout 60m
120
+ - name : Build Slim Binaries
121
+ run : make bin
122
+
123
+ - name : Build darwin Binaries (with signatures)
124
+ run : |
125
+ ./scripts/build_go_matrix.sh \
126
+ --output ./dist/ \
127
+ --archive \
128
+ --sign-darwin \
129
+ darwin:amd64,arm64
87
130
env :
88
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
89
131
AC_USERNAME : ${{ secrets.AC_USERNAME }}
90
132
AC_PASSWORD : ${{ secrets.AC_PASSWORD }}
133
+
134
+ - name : Upload Binary Artifacts
135
+ uses : actions/upload-artifact@v3
136
+ with :
137
+ name : darwin
138
+ path : ./dist/coder_*.zip
139
+
140
+ publish :
141
+ runs-on : ubuntu-latest
142
+ needs :
143
+ - linux-windows
144
+ - darwin
145
+ env :
146
+ # Necessary for Docker manifest
147
+ DOCKER_CLI_EXPERIMENTAL : " enabled"
148
+ steps :
149
+ - uses : actions/checkout@v3
150
+ with :
151
+ fetch-depth : 0
152
+
153
+ - name : Docker Login
154
+ uses : docker/login-action@v2
155
+ with :
156
+ registry : ghcr.io
157
+ username : ${{ github.repository_owner }}
158
+ password : ${{ secrets.GITHUB_TOKEN }}
159
+
160
+ - name : mkdir artifacts
161
+ run : mkdir artifacts
162
+
163
+ - name : Download darwin Artifacts
164
+ uses : actions/download-artifact@v3
165
+ with :
166
+ name : darwin
167
+ path : artifacts
168
+
169
+ - name : Download Linux and Windows Artifacts
170
+ uses : actions/download-artifact@v3
171
+ with :
172
+ name : linux
173
+ path : artifacts
174
+
175
+ - name : ls artifacts
176
+ run : ls artifacts
177
+
178
+ - name : Publish Release
179
+ run : |
180
+ ./scripts/publish_release.sh \
181
+ ${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && '--dry-run' }} \
182
+ ./artifacts/*.zip \
183
+ ./artifacts/*.tar.gz \
184
+ ./artifacts/*.apk \
185
+ ./artifacts/*.deb \
186
+ ./artifacts/*.rpm
187
+ env :
188
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments