forked from jpochyla/psst
-
Notifications
You must be signed in to change notification settings - Fork 0
343 lines (288 loc) · 11 KB
/
build.yml
File metadata and controls
343 lines (288 loc) · 11 KB
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
VERSION_DATE: ${{ format('{0}.{1}.{2}', github.run_number, github.run_id, github.run_attempt) }}
VERSION_TIMESTAMP: ${{ github.event.repository.updated_at }}
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
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-latest
- os: windows-latest
runs-on: ${{ matrix.os }}
env:
MACOSX_DEPLOYMENT_TARGET: 11.0
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Version Info
id: version
shell: bash
env:
FULL_SHA: ${{ github.sha }}
run: |
echo "BUILD_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
echo "VERSION=0.1.0,$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV
SHORT_SHA=${FULL_SHA::7}
echo "RELEASE_VERSION=$(date +'%Y.%m.%d')-$SHORT_SHA" >> $GITHUB_ENV
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ hashFiles('Cross.toml') }}
- name: Install Cross
if: runner.os == 'Linux'
run: cargo install cross
- name: Build (Linux)
if: runner.os == 'Linux'
run: cross build --release --target ${{ matrix.target }}
- 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 and Homebrew
id: cache-tools
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/cargo-bundle
~/Library/Caches/Homebrew
/usr/local/Cellar/create-dmg
key: ${{ runner.os }}-tools-${{ hashFiles('**/Cargo.lock', '.github/workflows/build.yml') }}
restore-keys: |
${{ runner.os }}-tools-
- name: Install cargo-bundle
if: runner.os == 'macOS' && !steps.cache-tools.outputs.cache-hit
run: cargo install cargo-bundle
- name: Install create-dmg
if: runner.os == 'macOS' && !steps.cache-tools.outputs.cache-hit
run: brew install create-dmg
- name: Create macOS universal binary
if: runner.os == 'macOS'
run: |
mkdir -p psst-gui/target/release
lipo -create -output psst-gui/target/release/psst-gui \
target/x86_64-apple-darwin/release/psst-gui \
target/aarch64-apple-darwin/release/psst-gui
- name: Bundle macOS Release
if: runner.os == 'macOS'
run: cargo bundle --release
working-directory: psst-gui
- name: Create DMG
if: runner.os == 'macOS'
run: |
brew install create-dmg
create-dmg \
--volname "Psst" \
--volicon "assets/logo.icns" \
--window-pos 200 120 \
--window-size 600 400 \
--icon-size 100 \
--icon "Psst.app" 150 160 \
--hide-extension "Psst.app" \
--app-drop-link 450 160 \
"Psst.dmg" \
"../target/release/bundle/osx/Psst.app"
working-directory: psst-gui
- name: Upload macOS DMG
uses: actions/upload-artifact@v4
if: runner.os == 'macOS'
with:
name: Psst.dmg
path: ./psst-gui/Psst.dmg
- name: Make Linux Binary Executable
if: runner.os == 'Linux'
run: chmod +x target/${{ matrix.target }}/release/psst-gui
- name: Rename Linux Binary
if: runner.os == 'Linux'
run: mv target/${{ matrix.target }}/release/psst-gui target/${{ matrix.target }}/release/psst
- name: Upload Linux Binary
uses: actions/upload-artifact@v4
if: runner.os == 'Linux'
with:
name: psst-${{ matrix.target }}
path: target/${{ matrix.target }}/release/psst
- 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:
include:
- arch: amd64
target: x86_64-unknown-linux-gnu
- arch: arm64
target: aarch64-unknown-linux-gnu
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get full history to count number of commits for package version
- name: Download Linux Binaries
uses: actions/download-artifact@v4
with:
name: psst-${{ matrix.target }}
path: binaries
- name: Move Binary
run: |
mkdir -p pkg/usr/bin/
mv binaries/psst pkg/usr/bin/
- name: Move Desktop Entry
run: mkdir -p pkg/usr/share/applications/; mv .pkg/psst.desktop pkg/usr/share/applications/
- 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 "pkg/usr/share/icons/hicolor/${LOGO_SIZE}x${LOGO_SIZE}/"
cp "./psst-gui/assets/${LOGO}" "pkg/usr/share/icons/hicolor/${LOGO_SIZE}x${LOGO_SIZE}/psst.png"
done
mkdir -p "pkg/usr/share/icons/hicolor/scalable/apps/"
cp "./psst-gui/assets/logo.svg" "pkg/usr/share/icons/hicolor/scalable/apps/psst.svg"
- name: Set Permissions
run: chmod 755 pkg/usr/bin/psst
- name: Move License
run: mkdir -p pkg/usr/share/doc/psst-gui/; mv .pkg/copyright pkg/usr/share/doc/psst-gui/
- name: Write Package Config
run: |
mkdir -p pkg/DEBIAN
export ARCHITECTURE=${{ matrix.arch }}
SANITIZED_BRANCH="$(echo ${GITHUB_HEAD_REF:+.$GITHUB_HEAD_REF}|tr '_/' '-')"
export VERSION=0.1.0"$SANITIZED_BRANCH"+r"$(git rev-list --count HEAD)"-0
envsubst < .pkg/DEBIAN/control > pkg/DEBIAN/control
- name: Build Package
run: |
cat pkg/DEBIAN/control
dpkg-deb -b pkg/ psst-${{ 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
# Downloads to the root of the workspace by default if path is omitted or '.',
# so removing explicit path to ${{github.workspace}}
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse2
- name: Create Workspace
run: mkdir -p 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=appimage -c $latest_release_appimage_url
- name: Create Path to pkg2appimage
run: |
pkg2appimage_executable=$(ls appimage)
app_path=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=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: out/*.AppImage
release:
needs: [build, deb]
runs-on: ubuntu-latest
permissions:
contents: write
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Set Version Info and Paths
id: set_paths
env:
FULL_SHA: ${{ github.sha }}
run: |
echo "BUILD_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
echo "VERSION=0.1.0,$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV
SHORT_SHA=${FULL_SHA::7}
echo "RELEASE_VERSION=$(date +'%Y.%m.%d')-$SHORT_SHA" >> $GITHUB_ENV
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare Release Body Data
id: release_data
run: |
echo "CURRENT_DATE_STR=$(date)" >> $GITHUB_ENV
- name: Prepare Release Assets
id: prep_assets
run: |
set -e
mkdir -p artifacts_final
find artifacts -type f -name 'Psst.dmg' -exec mv {} artifacts_final/Psst.dmg \;
find artifacts -type f -name 'psst-gui.exe' -exec mv {} artifacts_final/Psst.exe \;
find artifacts -type f -name 'psst-amd64.deb' -exec mv {} artifacts_final/psst-amd64.deb \;
find artifacts -type f -name 'psst-arm64.deb' -exec mv {} artifacts_final/psst-arm64.deb \;
find artifacts -type f -name 'psst' -path '*/psst-x86_64-unknown-linux-gnu/*' -exec mv {} artifacts_final/psst-linux-x86_64 \;
find artifacts -type f -name 'psst' -path '*/psst-aarch64-unknown-linux-gnu/*' -exec mv {} artifacts_final/psst-linux-aarch64 \;
rm -rf artifacts
mv artifacts_final artifacts
ls -l artifacts/
- name: Create Main Release
uses: softprops/action-gh-release@v2
with:
name: Continuous release (${{ env.RELEASE_VERSION }})
tag_name: rolling
make_latest: true
prerelease: false
body: |
This is a rolling release of Psst, published automatically on every commit to main.
Version: ${{ env.RELEASE_VERSION }}
Commit: ${{ github.sha }}
Built: ${{ env.CURRENT_DATE_STR }}
Workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
See the release assets for SHA256 checksums.
files: artifacts/*
generate_release_notes: false