-
Notifications
You must be signed in to change notification settings - Fork 0
276 lines (232 loc) · 9.87 KB
/
Copy pathrelease.yml
File metadata and controls
276 lines (232 loc) · 9.87 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
UI_BIN_NAME: rustickers
CLI_BIN_NAME: rusticker
MACOS_APP_NAME: Rustickers
jobs:
build-and-upload:
name: Build (${{ matrix.artifact_suffix }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_suffix: windows-x86_64
binary_ext: ".exe"
artifact_ext: ".zip"
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_suffix: linux-x86_64
binary_ext: ""
artifact_ext: ".tar.gz"
- os: macos-14
target: aarch64-apple-darwin
artifact_suffix: macos-aarch64
binary_ext: ""
artifact_ext: ".zip"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: release-${{ matrix.target }}
- name: Install Linux build dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
if apt-cache show libwebkit2gtk-4.1-dev >/dev/null 2>&1; then
WEBKIT_DEV=libwebkit2gtk-4.1-dev
JSCORE_DEV=libjavascriptcoregtk-4.1-dev
else
WEBKIT_DEV=libwebkit2gtk-4.0-dev
JSCORE_DEV=libjavascriptcoregtk-4.0-dev
fi
sudo apt-get install -y --no-install-recommends \
zip \
pkg-config \
libglib2.0-dev \
libgtk-3-dev \
libasound2-dev \
"$WEBKIT_DEV" \
"$JSCORE_DEV" \
libx11-dev \
libxcursor-dev \
libxrandr-dev \
libxi-dev \
libxkbcommon-dev \
libwayland-dev \
libfontconfig1-dev \
libfreetype6-dev \
libegl1-mesa-dev \
libgl1-mesa-dev
- name: Build (release)
run: |
cargo build --release --locked --target ${{ matrix.target }} --bin ${{ env.UI_BIN_NAME }}
cargo build --release --locked --target ${{ matrix.target }} --bin ${{ env.CLI_BIN_NAME }} --no-default-features --features cli
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$safeRef = ($env:GITHUB_REF_NAME -replace '[\\/:*?"<>|]', '-')
$artifact = "${env:UI_BIN_NAME}-${safeRef}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}"
$uiBin = "${env:UI_BIN_NAME}${{ matrix.binary_ext }}"
$uiSrc = "target\${{ matrix.target }}\release\$uiBin"
if (-not (Test-Path $uiSrc)) {
throw "UI binary not found at $uiSrc"
}
$cliBin = "${env:CLI_BIN_NAME}${{ matrix.binary_ext }}"
$cliSrc = "target\${{ matrix.target }}\release\$cliBin"
if (-not (Test-Path $cliSrc)) {
throw "CLI binary not found at $cliSrc"
}
Remove-Item -Recurse -Force dist -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item $uiSrc -Destination dist\ -Force
Copy-Item $cliSrc -Destination dist\ -Force
# Include common docs if present
Get-ChildItem -Path . -Filter "README*" -File -ErrorAction SilentlyContinue | ForEach-Object {
Copy-Item $_.FullName -Destination dist\ -Force
}
if (Test-Path "LICENSE") {
Copy-Item "LICENSE" -Destination dist\ -Force
}
if (Test-Path $artifact) { Remove-Item $artifact -Force }
Compress-Archive -Path "dist\*" -DestinationPath $artifact -Force
- name: Package (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
safe_ref="$(echo "$GITHUB_REF_NAME" | tr '/\\:*?"<>|' '-')"
ui_src="target/${{ matrix.target }}/release/${UI_BIN_NAME}"
if [[ ! -f "$ui_src" ]]; then
echo "UI binary not found at $ui_src" >&2
exit 1
fi
cli_src="target/${{ matrix.target }}/release/${CLI_BIN_NAME}"
if [[ ! -f "$cli_src" ]]; then
echo "CLI binary not found at $cli_src" >&2
exit 1
fi
rm -rf dist
mkdir -p dist
cp "$ui_src" "dist/${UI_BIN_NAME}"
chmod +x "dist/${UI_BIN_NAME}"
cp "$cli_src" "dist/${CLI_BIN_NAME}"
chmod +x "dist/${CLI_BIN_NAME}"
# Linux desktop integration helpers
cp "assets/icon.png" "dist/${UI_BIN_NAME}.png"
cp "packaging/linux/${UI_BIN_NAME}.desktop" "dist/${UI_BIN_NAME}.desktop"
cp "packaging/linux/install.sh" "dist/install.sh"
chmod +x "dist/install.sh"
if [[ -f "README.md" ]]; then cp README.md dist/; fi
if [[ -f "README" ]]; then cp README dist/; fi
if [[ -f "LICENSE" ]]; then cp LICENSE dist/; fi
artifact="${UI_BIN_NAME}-${safe_ref}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}"
tar -C dist -czf "$artifact" .
- name: Package (macOS)
if: runner.os == 'macOS'
shell: bash
run: |
set -euo pipefail
safe_ref="$(echo "$GITHUB_REF_NAME" | tr '/\\:*?"<>|' '-')"
ui_src="target/${{ matrix.target }}/release/${UI_BIN_NAME}"
if [[ ! -f "$ui_src" ]]; then
echo "UI binary not found at $ui_src" >&2
exit 1
fi
cli_src="target/${{ matrix.target }}/release/${CLI_BIN_NAME}"
if [[ ! -f "$cli_src" ]]; then
echo "CLI binary not found at $cli_src" >&2
exit 1
fi
version="${GITHUB_REF_NAME#v}"
rm -rf dist
mkdir -p dist
app_dir="dist/${MACOS_APP_NAME}.app"
mkdir -p "$app_dir/Contents/MacOS" "$app_dir/Contents/Resources"
cp "$ui_src" "$app_dir/Contents/MacOS/${UI_BIN_NAME}"
chmod +x "$app_dir/Contents/MacOS/${UI_BIN_NAME}"
cp "$cli_src" "dist/${CLI_BIN_NAME}"
chmod +x "dist/${CLI_BIN_NAME}"
# Build icon.icns from assets/icon.png
tmp_icon_dir="$(mktemp -d)"
iconset_dir="$tmp_icon_dir/icon.iconset"
mkdir -p "$iconset_dir"
# Force png output format; avoids occasional sips rename/suffix issues on CI.
sips -s format png -z 16 16 "assets/icon.png" --out "$iconset_dir/icon_16x16.png" >/dev/null
sips -s format png -z 32 32 "assets/icon.png" --out "$iconset_dir/icon_16x16@2x.png" >/dev/null
sips -s format png -z 32 32 "assets/icon.png" --out "$iconset_dir/icon_32x32.png" >/dev/null
sips -s format png -z 64 64 "assets/icon.png" --out "$iconset_dir/icon_32x32@2x.png" >/dev/null
sips -s format png -z 128 128 "assets/icon.png" --out "$iconset_dir/icon_128x128.png" >/dev/null
sips -s format png -z 256 256 "assets/icon.png" --out "$iconset_dir/icon_128x128@2x.png" >/dev/null
sips -s format png -z 256 256 "assets/icon.png" --out "$iconset_dir/icon_256x256.png" >/dev/null
sips -s format png -z 512 512 "assets/icon.png" --out "$iconset_dir/icon_256x256@2x.png" >/dev/null
sips -s format png -z 512 512 "assets/icon.png" --out "$iconset_dir/icon_512x512.png" >/dev/null
sips -s format png -z 1024 1024 "assets/icon.png" --out "$iconset_dir/icon_512x512@2x.png" >/dev/null
iconutil -c icns "$iconset_dir" -o "$app_dir/Contents/Resources/icon.icns"
rm -rf "$tmp_icon_dir"
cat > "$app_dir/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${UI_BIN_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.slaveoftime.rustickers</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${MACOS_APP_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${version}</string>
<key>CFBundleVersion</key>
<string>${version}</string>
<key>CFBundleIconFile</key>
<string>icon</string>
<key>LSMinimumSystemVersion</key>
<string>11.0</string>
</dict>
</plist>
EOF
if [[ -f "README.md" ]]; then cp README.md dist/; fi
if [[ -f "README" ]]; then cp README dist/; fi
if [[ -f "LICENSE" ]]; then cp LICENSE dist/; fi
ui_artifact="${UI_BIN_NAME}-${safe_ref}-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}"
if [[ -f "$ui_artifact" ]]; then rm -f "$ui_artifact"; fi
ditto -c -k --sequesterRsrc --keepParent "dist" "$ui_artifact"
- name: Upload to GitHub Release (Windows/Linux)
if: runner.os != 'macOS'
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.UI_BIN_NAME }}-*-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}
fail_on_unmatched_files: true
- name: Upload to GitHub Release (macOS)
if: runner.os == 'macOS'
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.UI_BIN_NAME }}-*-${{ matrix.artifact_suffix }}${{ matrix.artifact_ext }}
fail_on_unmatched_files: true