This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
202 lines (195 loc) · 7.84 KB
/
build.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
name: Build
on:
workflow_run:
workflows: ["Run Tests"]
branches: [main]
types:
- completed
env:
APP_NAME: icy_term
CARGO_TERM_COLOR: always
jobs:
build_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install gtk
run: |
sudo apt-get update
sudo apt-get install build-essential libgtk-3-dev libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev
- name: Install cargo deb & get
run: |
cargo install cargo-deb
cargo install cargo-get
- name: Build deb
id: build-deb
run: |
export VERSION="$(cargo get package.version)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
export DEB=$(cargo deb)
echo "Copy $DEB to ${{ env.APP_NAME }}_${VERSION}_amd64.deb"
mv $DEB ${{ env.APP_NAME }}_${VERSION}_amd64.deb
sed "s/#VERSION/$VERSION/g" <build/file_id.diz >file_id.diz
- name: 'Upload deb'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}_linux_${{ env.VERSION }}
path: |
${{ env.APP_NAME }}_${{ env.VERSION }}_amd64.deb
file_id.diz
build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Build exe
run: |
cargo build --release
- name: Install WiX
run: dotnet tool install --global wix --version 4.0.1
- name: Create PFX certificate
id: create-pfx
shell: pwsh
env:
PFX_CONTENT: ${{ secrets.WINDOWS_CERTIFICATE_BASE64 }}
run: |
$encodedBytes=[System.Convert]::FromBase64String($env:PFX_CONTENT);
Set-Content "./cert.pfx" -Value $encodedBytes
$VERSION=$(cargo pkgid | foreach-object { $_ -replace '(.*)#','' })
echo "Version: $VERSION"
Add-Content -Path $env:GITHUB_ENV -Value "VERSION=$VERSION"
get-content .\build\file_id.diz | %{$_ -replace "#VERSION","$VERSION"} >file_id.diz
- name: Build MSI installer.
run: |
echo "Building ${{ env.VERSION }} installer…"
wix extension add WixToolset.UI.wixext WixToolset.Util.wixext
wix build -arch "x64" -ext WixToolset.UI.wixext -ext WixToolset.Util.wixext -d "PATH=./cert.pfx" -d "VERSION=${{ env.VERSION }}" -out "./${{ env.APP_NAME }}-${{ env.VERSION }}-installer.msi" "build/windows/installer.wxs"
- name: Delete PFX certificate
run: del "./cert.pfx"
- name: 'Upload installer'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}_${{ env.VERSION }}_windows_msi
path: |
${{ env.APP_NAME }}-${{ env.VERSION }}-installer.msi
file_id.diz
- name: Copy exe
run: cp ".\target\release\${{ env.APP_NAME }}.exe" .
- name: 'Upload plain exe'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}_${{ env.VERSION }}_windows_exe
path: |
.\${{ env.APP_NAME }}.exe
file_id.diz
### 32 bit
build_windows_32bit:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Build exe
run: |
rustup install i686-pc-windows-gnu
rustup default i686-pc-windows-gnu
cargo build --release
- name: Install WiX
run: dotnet tool install --global wix --version 4.0.1
- name: Create PFX certificate
id: create-pfx
shell: pwsh
env:
PFX_CONTENT: ${{ secrets.WINDOWS_CERTIFICATE_BASE64 }}
run: |
$encodedBytes=[System.Convert]::FromBase64String($env:PFX_CONTENT);
Set-Content "./cert.pfx" -Value $encodedBytes
$VERSION=$(cargo pkgid | foreach-object { $_ -replace '(.*)#','' })
echo "Version: $VERSION"
Add-Content -Path $env:GITHUB_ENV -Value "VERSION=$VERSION"
get-content .\build\file_id.diz | %{$_ -replace "#VERSION","$VERSION"} >file_id.diz
- name: Build MSI installer.
run: |
echo "Building ${{ env.VERSION }} installer…"
wix extension add WixToolset.UI.wixext WixToolset.Util.wixext
wix build -arch "x64" -ext WixToolset.UI.wixext -ext WixToolset.Util.wixext -d "PATH=./cert.pfx" -d "VERSION=${{ env.VERSION }}" -out "./${{ env.APP_NAME }}-${{ env.VERSION }}-installer.msi" "build/windows/installer.wxs"
- name: Delete PFX certificate
run: del "./cert.pfx"
- name: 'Upload installer'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}_${{ env.VERSION }}_32bit_windows_msi
path: |
${{ env.APP_NAME }}-${{ env.VERSION }}-installer.msi
file_id.diz
- name: Copy exe
run: cp ".\target\release\${{ env.APP_NAME }}.exe" .
- name: 'Upload plain exe'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}_${{ env.VERSION }}_32bit_windows_exe
path: |
.\${{ env.APP_NAME }}.exe
file_id.diz
###
build_mac:
strategy:
matrix:
target: [aarch64-apple-darwin, x86_64-apple-darwin]
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Install cargo bundle & get
run: |
rustup target add ${{ matrix.target }}
cargo install cargo-bundle
cargo install cargo-get
brew install create-dmg
- name: Build dmg
run: |
cargo bundle --release --target ${{ matrix.target }}
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.OSX_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.OSX_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.OSX_CERTIFICATE_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
- name: Sign dmg
id: sign-bundle
run: |
export version="$(cargo get package.version)"
echo "VERSION=$version" >> $GITHUB_ENV
sed "s/#VERSION/$version/g" <build/file_id.diz >file_id.diz
export MAC_APP=$(cat Cargo.toml | grep "name" | awk -F"\"" '{print $2}' | head -n 2 | tail -n 1)
codesign --force --deep --verbose --sign "mkrueger@posteo.de" "target/${{ matrix.target }}/release/bundle/osx/${MAC_APP}.app/"
create-dmg \
--volname "${MAC_APP} Installer" \
--volicon "target/${{ matrix.target }}/release/bundle/osx/${MAC_APP}.app/Contents/Resources/${MAC_APP}.icns" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--hide-extension "${MAC_APP}.app" \
--app-drop-link 600 185 \
"${{ env.APP_NAME }}-$version-${{ matrix.target }}.dmg" \
"target/${{ matrix.target }}/release/bundle/osx/${MAC_APP}.app/"
- name: Clean up keychain and provisioning profile
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
# rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
- name: 'Upload dmg'
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}_osx_${{ env.VERSION }}_${{ matrix.target }}
path: |
${{ env.APP_NAME }}-${{ env.VERSION }}-${{ matrix.target }}.dmg
file_id.diz