-
Notifications
You must be signed in to change notification settings - Fork 6
274 lines (220 loc) · 8.14 KB
/
Copy pathnewm-admin-release.yml
File metadata and controls
274 lines (220 loc) · 8.14 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
# 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
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
- 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 Release
run: cargo build --release --target aarch64-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: Create DMG
run: |
chmod +x packaging/macos/bundle.sh
packaging/macos/bundle.sh ${{ steps.version.outputs.VERSION }} aarch64-apple-darwin
- 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 }}