-
Notifications
You must be signed in to change notification settings - Fork 224
255 lines (211 loc) · 8.03 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
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
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
CARGO_TERM_COLOR: always
jobs:
code-style:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libssl-dev libasound2-dev
- name: Check Formatting
run: cargo clippy -- -D warnings
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cross_arch: amd64
deps: libgtk-3-dev libssl-dev libasound2-dev
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
cross_arch: arm64
- os: macOS-latest
- os: windows-latest
runs-on: ${{ matrix.os }}
env:
MACOSX_DEPLOYMENT_TARGET: 11.0
PKG_CONFIG_SYSROOT_DIR: /
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Run Tests
run: cargo test
continue-on-error: true
- name: Install Linux dependencies
if: matrix.deps
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.deps }}
- name: Build Release (Linux)
if: runner.os == 'Linux'
uses: clechasseur/rs-cargo@v2
with:
use-cross: ${{ matrix.cross_arch }}
command: build
args: --release --target ${{ matrix.target }}
env:
PKG_CONFIG_ALLOW_CROSS: 1
PKG_CONFIG_SYSROOT_DIR: /
PKG_CONFIG_PATH: /
- name: Build Release (macOS)
if: runner.os == 'macOS'
run: |
rustup target add x86_64-apple-darwin aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin --target aarch64-apple-darwin
- name: Build Release (Windows)
if: runner.os == 'Windows'
run: cargo build --release
- name: Cache cargo-bundle
if: runner.os == 'macOS'
id: cache-cargo-bundle
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-bundle
key: ${{ runner.os }}-cargo-bundle-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-bundle
if: runner.os == 'macOS' && steps.cache-cargo-bundle.outputs.cache-hit != 'true'
run: cargo install cargo-bundle
- name: Bundle macOS Release
if: runner.os == 'macOS'
run: cargo bundle --release
working-directory: psst-gui
- name: Create macOS universal binary
if: runner.os == 'macOS'
run: |
lipo -create -output target/release/bundle/osx/Psst.app/Contents/MacOS/psst-gui \
target/x86_64-apple-darwin/release/psst-gui \
target/aarch64-apple-darwin/release/psst-gui
- name: Create macOS Disk Image
if: runner.os == 'macOS'
run: hdiutil create -volname "Psst" -srcfolder target/release/bundle/osx -ov -format UDZO Psst.dmg
- name: Upload macOS Disk Image
uses: actions/upload-artifact@v4
if: runner.os == 'macOS'
with:
name: Psst.dmg
path: ./Psst.dmg
- name: Make Linux Binary Executable
if: runner.os == 'Linux'
run: |
chmod +x target/${{ matrix.target }}-unknown-linux-gnu/release/psst-gui
- name: Upload Linux Binary
uses: actions/upload-artifact@v4
if: runner.os == 'Linux'
with:
name: psst-gui-${{ matrix.target }}
path: target/${{ matrix.target }}/release/psst-gui
- name: Upload Windows Executable
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
name: Psst.exe
path: target/release/psst-gui.exe
deb:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download Linux Binaries
uses: actions/download-artifact@v4
with:
name: psst-gui
path: ${{runner.workspace}}/binaries
- name: Move Binary
run: |
mkdir -p ${{runner.workspace}}/pkg/usr/bin/
if [ "${{ matrix.arch }}" == "amd64" ]; then
mv ${{runner.workspace}}/binaries/x86_64-unknown-linux-gnu/release/psst-gui ${{runner.workspace}}/pkg/usr/bin/
else
mv ${{runner.workspace}}/binaries/aarch64-unknown-linux-gnu/release/psst-gui ${{runner.workspace}}/pkg/usr/bin/
fi
- name: Move Desktop Entry
run: mkdir -p ${{runner.workspace}}/pkg/usr/share/applications/; mv .pkg/psst.desktop $_
- name: Add Icons
run: |
LOGOS=$(cd ./psst-gui/assets/ && ls logo_*.png)
for LOGO in $LOGOS
do
LOGO_SIZE=$(echo "${LOGO}" | grep -oE '[[:digit:]]{2,}')
mkdir -p "${{runner.workspace}}/pkg/usr/share/icons/hicolor/${LOGO_SIZE}x${LOGO_SIZE}/"
cp "./psst-gui/assets/${LOGO}" "$_/psst.png"
done
mkdir -p "${{runner.workspace}}/pkg/usr/share/icons/hicolor/scalable/apps/"
cp "./psst-gui/assets/logo.svg" "$_/psst.svg"
- name: Set Permissions
run: chmod 755 ${{runner.workspace}}/pkg/usr/bin/psst-gui
- name: Move License
run: mkdir -p ${{runner.workspace}}/pkg/usr/share/doc/psst-gui/; mv .pkg/copyright $_
- name: Move Package Config
run: |
mkdir -p ${{runner.workspace}}/pkg/
cp -r .pkg/DEBIAN $_/
sed -i 's/Architecture: amd64/Architecture: ${{ matrix.arch }}/' ${{runner.workspace}}/pkg/DEBIAN/control
- name: Set Version
run: "echo Version: $(git rev-list --count HEAD) >> ${{runner.workspace}}/pkg/DEBIAN/control"
- name: Build Package
run: |
cat ${{runner.workspace}}/pkg/DEBIAN/control
dpkg-deb -b ${{runner.workspace}}/pkg/ psst_$(git rev-list --count HEAD)_${{ matrix.arch }}.deb
- name: Upload Debian Package
uses: actions/upload-artifact@v4
with:
name: psst-deb-${{ matrix.arch }}
path: "*.deb"
appimage:
if: false # Disable temporarily: https://github.com/jpochyla/psst/actions/runs/3897410142/jobs/6655282029
runs-on: ubuntu-latest
needs: deb
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download Debian Package
uses: actions/download-artifact@v4
with:
name: psst-deb
path: ${{runner.workspace}}
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse2
- name: Create Workspace
run: mkdir -p ${{runner.workspace}}/appimage
- name: Download the Latest pkg2appimage
run: |
latest_release_appimage_url=$(wget -q https://api.github.com/repos/AppImageCommunity/pkg2appimage/releases/latest -O - | jq -r '.assets[0].browser_download_url')
wget --directory-prefix=${{runner.workspace}}/appimage -c $latest_release_appimage_url
- name: Create Path to pkg2appimage
run: |
pkg2appimage_executable=$(ls ${{runner.workspace}}/appimage)
app_path=${{runner.workspace}}/appimage/${pkg2appimage_executable}
chmod +x ${app_path}
echo "app_path=${app_path}" >> $GITHUB_ENV
- name: Create Path to pkg2appimage's Recipe File
run: |
recipe_path=${{runner.workspace}}/psst/.pkg/APPIMAGE/pkg2appimage-ingredients.yml
echo "recipe_path=${recipe_path}" >> $GITHUB_ENV
- name: Run pkg2appimage
run: |
${{env.app_path}} ${{env.recipe_path}}
- name: Upload AppImage
uses: actions/upload-artifact@v4
with:
name: psst-appimage
path: ${{runner.workspace}}/out/*.AppImage