-
Notifications
You must be signed in to change notification settings - Fork 6
337 lines (270 loc) · 11 KB
/
Copy pathnewm-admin-release.yml
File metadata and controls
337 lines (270 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
# Release workflow for NEWM Admin - runs only on version tags (v*)
# For CI on PRs/pushes, see newm-admin.yml
on:
push:
tags:
- 'v*'
name: NEWM Admin Release
jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
job:
- { os: ubuntu-24.04, label: ubuntu24, target: x86_64-unknown-linux-gnu }
- { os: macos-latest, label: macos, target: aarch64-apple-darwin }
- { os: windows-latest, label: windows, target: x86_64-pc-windows-msvc }
rust: [ stable ]
runs-on: ${{ matrix.job.os }}
defaults:
run:
working-directory: newm-admin
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "newm-admin -> target"
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libxkbcommon-x11-dev libxkbcommon-dev libwayland-dev libfuse2
- name: Run cargo check
if: ${{ matrix.job.target == 'x86_64-unknown-linux-gnu' }}
run: cargo check
- name: Run cargo fmt
if: ${{ matrix.job.target == 'x86_64-unknown-linux-gnu' }}
run: cargo fmt --all -- --check
- name: Run cargo clippy
run: cargo clippy --release --target ${{ matrix.job.target }} -- -D warnings
- name: Run cargo test
run: cargo test --release --target ${{ matrix.job.target }}
- name: Build Release
run: cargo build --release --target ${{ matrix.job.target }} --locked
- name: Package (basic archive)
id: package
shell: bash
run: |
PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml)
PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
if [[ "${{ matrix.job.target }}" == *-pc-windows-* ]]; then
PKG_SUFFIX=".zip"
else
PKG_SUFFIX=".tar.gz"
fi
PKG_NAME=${PROJECT_NAME}-${PROJECT_VERSION}-${{ matrix.job.label }}-${{ matrix.job.target }}${PKG_SUFFIX}
if [[ "${{ matrix.job.target }}" == *-pc-windows-* ]]; then
7z -y a "${PKG_NAME}" ./target/${{matrix.job.target}}/release/newm-admin.exe | tail -2
else
tar -C target/${{matrix.job.target}}/release -czf "${PKG_NAME}" newm-admin
fi
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT
echo "PKG_PATH=${PKG_NAME}" >> $GITHUB_OUTPUT
echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_OUTPUT
- name: Upload Artifacts (basic archive)
uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.PKG_NAME }}
path: newm-admin/${{ steps.package.outputs.PKG_PATH }}
package-macos:
name: Package macOS DMG (Universal)
needs: build
runs-on: macos-latest
defaults:
run:
working-directory: newm-admin
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: aarch64-apple-darwin,x86_64-apple-darwin
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "newm-admin -> target"
- name: Install create-dmg
run: brew install create-dmg
- name: Build ARM64 (Apple Silicon)
run: cargo build --release --target aarch64-apple-darwin --locked
- name: Build x86_64 (Intel)
run: cargo build --release --target x86_64-apple-darwin --locked
- name: Get version
id: version
run: |
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Import Code Signing Certificate
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# Ensure certificate file is cleaned up on exit (success or failure)
trap 'rm -f certificate.p12' EXIT
# Create a temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security set-keychain-settings -t 3600 -u build.keychain
# Decode certificate
echo "$MACOS_CERTIFICATE" | base64 --decode > certificate.p12
# Verify the p12 file is valid with openssl using a generic error message
if ! openssl pkcs12 -in certificate.p12 -nokeys -passin env:MACOS_CERTIFICATE_PWD >/dev/null 2>&1; then
echo "ERROR: Failed to validate macOS code signing certificate or password."
exit 1
fi
# Import certificate
security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign -T /usr/bin/security
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
# Verify certificate was imported and show what identities are available
echo "Available signing identities in keychain:"
security find-identity -v -p codesigning build.keychain
# Also make sure we can find it in the login keychain search list
security list-keychains -d user -s build.keychain login.keychain
- name: Create Universal App Bundle and DMG
env:
MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
run: |
chmod +x packaging/macos/bundle.sh
packaging/macos/bundle.sh ${{ steps.version.outputs.VERSION }} aarch64-apple-darwin
- name: Notarize App
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
DMG_PATH="target/aarch64-apple-darwin/release/NEWM-Admin-${{ steps.version.outputs.VERSION }}-macos.dmg"
echo "Submitting DMG for notarization..."
xcrun notarytool submit "$DMG_PATH" \
--apple-id "$APPLE_ID" \
--password "$APPLE_APP_PASSWORD" \
--team-id "$APPLE_TEAM_ID" \
--wait
echo "Stapling notarization ticket to DMG..."
xcrun stapler staple "$DMG_PATH"
echo "Verifying notarization..."
xcrun stapler validate "$DMG_PATH"
- name: Upload DMG
uses: actions/upload-artifact@v4
with:
name: NEWM-Admin-${{ steps.version.outputs.VERSION }}-macos.dmg
path: newm-admin/target/aarch64-apple-darwin/release/NEWM-Admin-${{ steps.version.outputs.VERSION }}-macos.dmg
package-linux:
name: Package Linux AppImage
needs: build
runs-on: ubuntu-22.04
defaults:
run:
working-directory: newm-admin
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "newm-admin -> target"
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y libxkbcommon-x11-dev libxkbcommon-dev libwayland-dev libfuse2
- name: Build Release
run: cargo build --release --target x86_64-unknown-linux-gnu --locked
- name: Get version
id: version
run: |
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Create AppImage
run: |
chmod +x packaging/linux/build-appimage.sh
packaging/linux/build-appimage.sh ${{ steps.version.outputs.VERSION }} x86_64-unknown-linux-gnu
- name: Upload AppImage
uses: actions/upload-artifact@v4
with:
name: NEWM-Admin-${{ steps.version.outputs.VERSION }}-x86_64.AppImage
path: newm-admin/target/x86_64-unknown-linux-gnu/release/NEWM-Admin-${{ steps.version.outputs.VERSION }}-x86_64.AppImage
package-windows:
name: Package Windows MSI
needs: build
runs-on: windows-latest
defaults:
run:
working-directory: newm-admin
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "newm-admin -> target"
- name: Install WiX Toolset
run: |
dotnet tool install --global wix
cargo install cargo-wix
- name: Build Release
run: cargo build --release --target x86_64-pc-windows-msvc --locked
- name: Get version
id: version
shell: bash
run: |
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Build MSI
shell: pwsh
run: |
./packaging/windows/build-msi.ps1 -Version "${{ steps.version.outputs.VERSION }}" -Target "x86_64-pc-windows-msvc"
- name: Upload MSI
uses: actions/upload-artifact@v4
with:
name: NEWM-Admin-${{ steps.version.outputs.VERSION }}-windows.msi
path: newm-admin/target/x86_64-pc-windows-msvc/release/NEWM-Admin-${{ steps.version.outputs.VERSION }}-windows.msi
release:
name: Create Release
needs: [package-macos, package-linux, package-windows]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Get version
id: version
run: |
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' newm-admin/Cargo.toml | head -n1)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List artifacts
run: find artifacts -type f
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: NEWM Admin v${{ steps.version.outputs.VERSION }}
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
files: |
artifacts/**/*.dmg
artifacts/**/*.AppImage
artifacts/**/*.msi
artifacts/**/*.tar.gz
artifacts/**/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}