-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathaction.yml
289 lines (288 loc) · 11 KB
/
action.yml
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
name: "Wails Build Action"
description: "Creates a wails binary"
branding:
icon: 'box'
color: 'purple'
inputs:
build:
description: "Platform to build for"
required: false
default: "true"
sign:
description: "Sign the build"
required: false
default: "false"
package:
description: "Uploads workflow & uploads tag builds to a release"
required: false
default: "true"
nsis:
description: "Build a Windows Installer"
required: false
default: "false"
build-name:
description: "The name of the binary file"
required: true
build-cache:
description: "Cache the build"
required: false
default: "true"
build-platform:
description: "Platform to build for"
required: false
default: "darwin/universal"
build-tags:
description: "Build tags to pass to Go compiler. Must be quoted. Space or comma (but not both) separated"
required: false
default: "false"
build-obfuscate:
description: "Obfuscate the build"
required: false
default: "false"
wails-version:
description: "Wails version to use"
required: false
default: "latest"
wails-build-webview2:
description: "Webview2 installer method [download,embed,browser,error]"
required: false
default: "download"
go-version:
description: "Version of Go to use"
required: false
default: "1.23"
node-version:
description: "Node js version"
required: false
default: "18.x"
deno-build:
description: "This gets run into bash, use the full command"
required: false
default: ""
app-working-directory:
description: "This gets run into bash, use the full command"
required: false
default: "."
deno-working-directory:
description: "This gets run into bash, use the full command"
required: false
default: "."
deno-version:
description: "Deno version to use"
required: false
default: "v1.20.x"
sign-macos-app-id:
description: "MacOS Application Certificate id"
required: false
default: ''
sign-macos-apple-password:
description: "MacOS Apple password"
required: false
default: ''
sign-macos-app-cert:
description: "MacOS Application Certificate"
required: false
default: ''
sign-macos-app-cert-password:
description: "MacOS Application Certificate Password"
required: false
default: ''
sign-macos-installer-id:
description: "MacOS Installer Certificate id"
required: false
default: ''
sign-macos-installer-cert:
description: "MacOS Installer Certificate"
required: false
default: ''
sign-macos-installer-cert-password:
description: "MacOS Installer Certificate Password"
required: false
default: ''
sign-windows-cert:
description: "Windows Signing Certificate"
required: false
default: ''
sign-windows-cert-password:
description: "Windows Signing Certificate Password"
required: false
default: ''
wails-dev-build:
description: "Use provided wails"
required: false
default: "false"
runs:
using: "composite"
steps:
- name: Linux Discovery
if: runner.os == 'Linux'
id: linux_discovery
run: |
sudo apt-get -yq update
DISTRO=$(lsb_release -rs) # Get the distribution version (e.g., "22.04", "24.04")
if [[ "$DISTRO" == "20.04" ]]; then
sudo apt-get -yq install libgtk-3-0 libwebkit2gtk-4.0-dev gcc-aarch64-linux-gnu
elif [[ "$DISTRO" == "22.04" ]]; then
sudo apt-get -yq install libgtk-3-0 libwebkit2gtk-4.0-dev gcc-aarch64-linux-gnu
elif [[ "$DISTRO" == "24.04" ]]; then
sudo apt-get -yq install libgtk-3-0 libwebkit2gtk-4.1-dev gcc-aarch64-linux-gnu
else
echo "Unsupported Linux distribution: $DISTRO"
exit 1 # Fail the workflow if the distribution is not supported
fi
echo "DISTRO=$DISTRO" >> "$GITHUB_OUTPUT"
shell: bash
- name: Setup Build Options
id: build_options
shell: bash
env:
DISTRO: ${{ steps.linux_discovery.outputs.DISTRO }}
run: |
build_options=""
if ${{ inputs.build-obfuscate == 'true' }}; then
build_options+=' -obfuscated'
fi
if [[ "${{ inputs.build-tags }}" != "false" ]]; then
tags_string="${{ inputs.build-tags }}"
if [[ "$DISTRO" == '24.04' ]]; then
tags_string+=" webkit2_41"
fi
build_options+=" -tags $tags_string"
elif [[ "${{ inputs.build-tags }}" == "false" && "$DISTRO" == '24.04' ]]; then
build_options+=" -tags webkit2_41"
fi
if ${{ inputs.nsis == 'true' }}; then
build_options+=' -nsis'
fi
echo "BUILD_OPTIONS=$build_options" >> "$GITHUB_OUTPUT"
# Setup and configure GoLang
- name: Setup GoLang
uses: actions/setup-go@v5
if: inputs.wails-dev-build == 'false'
with:
check-latest: true
cache: ${{ inputs.build-cache }}
cache-dependency-path: 'go.sum'
go-version: ${{ inputs.go-version }}
- name: Install Garble
if: inputs.build-obfuscate == 'true'
run: go install mvdan.cc/garble@latest
shell: bash
- run: go version
shell: bash
# (Optional) Setup and configure Deno
- name: Setup Deno
uses: denoland/setup-deno@v2
if: inputs.deno-build != ''
with:
deno-version: ${{inputs.deno-version}}
- name: Run Deno Command
if: inputs.deno-build != ''
shell: bash
working-directory: ${{inputs.deno-working-directory}}
run: ${{inputs.deno-build}}
# install wails
- name: Install Wails
if: inputs.build == 'true' && inputs.wails-dev-build == 'false'
run: go install github.com/wailsapp/wails/v2/cmd/wails@${{inputs.wails-version}}
shell: bash
- name: Install macOS Wails deps
if: runner.os == 'macOS'
run: brew install mitchellh/gon/gon
shell: bash
# Building step
- name: Build App
if: inputs.build == 'true'
env:
BUILD_OPTIONS: ${{ steps.build_options.outputs.BUILD_OPTIONS }}
working-directory: ${{ inputs.app-working-directory }}
run: wails build --platform ${{inputs.build-platform}} -webview2 ${{inputs.wails-build-webview2}} -o ${{inputs.build-name}} $BUILD_OPTIONS
shell: bash
- name: Add macOS perms
if: inputs.build == 'true' && runner.os == 'macOS'
working-directory: ${{ inputs.app-working-directory }}
run: chmod +x build/bin/*/Contents/MacOS/*
shell: bash
- name: Add Linux perms
if: inputs.build == 'true' && runner.os == 'Linux'
working-directory: ${{ inputs.app-working-directory }}
run: chmod +x build/bin/*
shell: bash
# Package and Sign MacOS
- name: Import Code-Signing Certificates for macOS
if: runner.os == 'macOS' && inputs.sign != 'false' && startsWith(github.ref, 'refs/tags/')
uses: Apple-Actions/import-codesign-certs@v1
with:
keychain-password: ${{ inputs.sign-macos-apple-password }}
p12-file-base64: ${{ inputs.sign-macos-app-cert }}
p12-password: ${{ inputs.sign-macos-app-cert-password }}
- name: Import Code-Signing Certificates for macOS Installer
if: runner.os == 'macOS' && inputs.sign != 'false' && startsWith(github.ref, 'refs/tags/')
uses: Apple-Actions/import-codesign-certs@v1
with:
keychain-password: ${{ inputs.sign-macos-apple-password }}
p12-file-base64: ${{ inputs.sign-macos-installer-cert }}
p12-password: ${{ inputs.sign-macos-installer-cert-password }}
create-keychain: false
- name: Sign our macOS binary
if: runner.os == 'macOS' && inputs.sign != 'false' && startsWith(github.ref, 'refs/tags/')
shell: bash
working-directory: ${{ inputs.app-working-directory }}
env:
APPLE_PASSWORD: ${{ inputs.sign-macos-apple-password }}
run: |
echo "Signing Package"
gon -log-level=info ./build/darwin/gon-sign.json
- name: Build .app zip file
if: runner.os == 'macOS'
working-directory: ${{ inputs.app-working-directory }}
shell: bash
run: |
ditto -c -k --keepParent ${{ inputs.app-working-directory }}/build/bin/${{inputs.build-name}}.app ${{ inputs.app-working-directory }}/build/bin/${{inputs.build-name}}.app.zip
- name: Building Installer
if: runner.os == 'macOS' && inputs.sign != 'false' && inputs.sign-macos-installer-id != '' && startsWith(github.ref, 'refs/tags/')
shell: bash
working-directory: ${{ inputs.app-working-directory }}
run: |
productbuild --sign '${{inputs.sign-macos-installer-id}}' --component ${{ inputs.app-working-directory }}/build/bin/${{inputs.build-name}}.app /Applications ${{ inputs.app-working-directory }}/build/bin/${{inputs.build-name}}.pkg
- name: Building Installer
if: runner.os == 'macOS' && inputs.sign-macos-installer-id == '' && startsWith(github.ref, 'refs/tags/')
shell: bash
working-directory: ${{ inputs.app-working-directory }}
run: |
productbuild --component ${{ inputs.app-working-directory }}/build/bin/${{inputs.build-name}}.app /Applications ${{ inputs.app-working-directory }}/build/bin/${{inputs.build-name}}.pkg
- name: Notarising Installer and zip
if: runner.os == 'macOS' && inputs.sign != 'false' && startsWith(github.ref, 'refs/tags/')
shell: bash
working-directory: ${{ inputs.app-working-directory }}
env:
APPLE_PASSWORD: ${{ inputs.sign-macos-apple-password }}
run: |
gon -log-level=info ${{ inputs.app-working-directory }}/build/darwin/gon-notarize.json
# Windows signing
- name: Sign Windows binaries
shell: powershell
if: runner.os == 'Windows' && inputs.sign != 'false' && inputs.sign-windows-cert != ''
working-directory: ${{ inputs.app-working-directory }}
run: |
echo "Creating certificate file"
New-Item -ItemType directory -Path certificate
Set-Content -Path certificate\certificate.txt -Value '${{ inputs.sign-windows-cert }}'
certutil -decode certificate\certificate.txt certificate\certificate.pfx
echo "Signing our binaries"
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /fd sha256 /tr http://ts.ssl.com /f certificate\certificate.pfx /p '${{ inputs.sign-windows-cert-password }}' .\build\bin\${{inputs.build-name}}.exe
echo "Signing Installer" & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /fd sha256 /tr http://ts.ssl.com /f certificate\certificate.pfx /p '${{ inputs.sign-windows-cert-password }}' .\build\bin\${{inputs.build-name}}-amd64-installer.exe
# Upload build assets
- uses: actions/upload-artifact@v4
if: inputs.package == 'true'
with:
name: Wails Build ${{runner.os}} ${{inputs.build-name}}
path: |
*/bin/
*\bin\*
- name: Release
uses: softprops/action-gh-release@v1
if: inputs.package == 'true' && startsWith(github.ref, 'refs/tags/')
with:
files: |
*/bin/*