-
Notifications
You must be signed in to change notification settings - Fork 5
288 lines (247 loc) · 8.65 KB
/
Copy pathrelease-setup.yml
File metadata and controls
288 lines (247 loc) · 8.65 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
name: release-setup
on:
push:
tags:
- "[0-9]*"
permissions:
contents: write
jobs:
build-matrix:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Windows x64
- os: windows-latest
target: x86_64-pc-windows-msvc
name: win-x64
archive_ext: zip
archive_cmd: 7z a
exe_ext: .exe
# macOS x64 (Intel)
- os: macos-15-intel
target: x86_64-apple-darwin
name: mac-x64
archive_ext: tar.gz
archive_cmd: tar czf
exe_ext: ""
# macOS ARM64 (Apple Silicon)
- os: macos-14
target: aarch64-apple-darwin
name: mac-arm64
archive_ext: tar.gz
archive_cmd: tar czf
exe_ext: ""
# Linux x64 (musl)
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
name: linux-x64-musl
archive_ext: tar.gz
archive_cmd: tar czf
exe_ext: ""
use_cross: true
# Linux ARM64 (musl)
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
name: linux-arm64-musl
archive_ext: tar.gz
archive_cmd: tar czf
exe_ext: ""
use_cross: true
# Linux x64 (gnu) - Mainly for GUI DEB/Tarball
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: linux-x64-gnu
archive_ext: tar.gz
archive_cmd: tar czf
exe_ext: ""
use_cross: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.92.0
target: ${{ matrix.target }}
- name: Install musl-tools (Linux musl)
if: contains(matrix.target, 'musl') && matrix.use_cross == false
run: sudo apt-get install -y musl-tools
- name: Install Cross
if: matrix.use_cross
run: cargo install cross
- name: Build Binaries
shell: bash
run: |
CMD="cargo"
if [ "${{ matrix.use_cross }}" = "true" ]; then
CMD="cross"
fi
echo "Building mgit-cli..."
$CMD build --release --verbose -p mgit-cli --target ${{ matrix.target }}
if [[ "${{ matrix.target }}" != *"musl"* ]]; then
echo "Building mgit-gui..."
$CMD build --release --verbose -p mgit-gui --target ${{ matrix.target }}
fi
- name: Prepare Archives
shell: bash
run: |
mkdir -p dist
CLI_NAME="mgit-cli-${{ github.ref_name }}-${{ matrix.target }}"
GUI_NAME="mgit-gui-${{ github.ref_name }}-${{ matrix.target }}"
# Staging directories
mkdir -p "$CLI_NAME"
# Copy CLI binary
cp "target/${{ matrix.target }}/release/mgit${{ matrix.exe_ext }}" "$CLI_NAME/"
cp README.md "$CLI_NAME/"
if [ "${{ matrix.archive_ext }}" = "zip" ]; then
7z a "dist/${CLI_NAME}.zip" "$CLI_NAME"
else
tar czf "dist/${CLI_NAME}.tar.gz" "$CLI_NAME"
fi
# Handle GUI if not musl
if [[ "${{ matrix.target }}" != *"musl"* ]]; then
mkdir -p "$GUI_NAME"
cp "target/${{ matrix.target }}/release/mgit-gui${{ matrix.exe_ext }}" "$GUI_NAME/"
cp README.md "$GUI_NAME/"
if [ "${{ matrix.archive_ext }}" = "zip" ]; then
7z a "dist/${GUI_NAME}.zip" "$GUI_NAME"
else
tar czf "dist/${GUI_NAME}.tar.gz" "$GUI_NAME"
fi
fi
- name: Upload Release Assets (Archives)
uses: softprops/action-gh-release@v2
with:
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Artifacts (Binaries for Packaging)
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.name }}
path: |
target/${{ matrix.target }}/release/mgit${{ matrix.exe_ext }}
target/${{ matrix.target }}/release/mgit-gui${{ matrix.exe_ext }}
retention-days: 1
if-no-files-found: ignore
package-windows:
name: Package Windows (Installer)
needs: build-matrix
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Windows Binaries
uses: actions/download-artifact@v4
with:
name: binaries-win-x64
path: target/release
- name: Install NSIS
shell: powershell
run: |
choco install nsis
# Add NSIS to PATH for subsequent steps
echo "C:\Program Files (x86)\NSIS" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Create Installer
run: |
"C:\Program Files (x86)\NSIS\makensis.exe" /DVERSION="${{ github.ref_name }}" scripts/windows/mgit.nsi
shell: cmd
- name: Rename Installer
run: |
mv scripts/windows/mgit-setup.exe scripts/windows/mgit-${{ github.ref_name }}-setup.exe
shell: bash
- name: Upload Installer
uses: softprops/action-gh-release@v2
with:
files: scripts/windows/mgit-${{ github.ref_name }}-setup.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package-macos:
name: Package macOS (Universal DMG)
needs: build-matrix
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download macOS x64 Binaries
uses: actions/download-artifact@v4
with:
name: binaries-mac-x64
path: binaries/x64
- name: Download macOS ARM64 Binaries
uses: actions/download-artifact@v4
with:
name: binaries-mac-arm64
path: binaries/arm64
- name: Create Universal Binaries
run: |
mkdir -p target/release
# Debug structure
echo "Listing binaries directory:"
ls -R binaries
# Locate binaries dynamically to avoid path issues
CLI_X64=$(find binaries/x64 -name mgit -type f | head -n 1)
GUI_X64=$(find binaries/x64 -name mgit-gui -type f | head -n 1)
CLI_ARM=$(find binaries/arm64 -name mgit -type f | head -n 1)
GUI_ARM=$(find binaries/arm64 -name mgit-gui -type f | head -n 1)
echo "Found binaries:"
echo "CLI x64: $CLI_X64"
echo "GUI x64: $GUI_X64"
echo "CLI arm: $CLI_ARM"
echo "GUI arm: $GUI_ARM"
lipo -create -output target/release/mgit "$CLI_X64" "$CLI_ARM"
lipo -create -output target/release/mgit-gui "$GUI_X64" "$GUI_ARM"
chmod +x target/release/mgit target/release/mgit-gui
- name: Install create-dmg
run: brew install create-dmg
- name: Create DMG
run: |
chmod +x scripts/macos/build_dmg.sh
./scripts/macos/build_dmg.sh "${{ github.ref_name }}" "scripts/macos/mgit-${{ github.ref_name }}-universal.dmg"
- name: Upload DMG
uses: softprops/action-gh-release@v2
with:
files: scripts/macos/mgit-${{ github.ref_name }}-universal.dmg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package-linux:
name: Package Linux (DEB)
needs: build-matrix
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.92.0
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Download Linux x64 GNU Binaries
# We use GNU binaries for DEB because GUI apps on Linux usually link dynamically against system libs
uses: actions/download-artifact@v4
with:
name: binaries-linux-x64-gnu
path: target/release
- name: Flatten Artifact Path
run: |
# download-artifact preserves directory structure, we need to move binaries to expected location
# Path is target/release/target/x86_64-unknown-linux-gnu/release/
# We need them in target/release/
find target/release -name mgit -exec mv {} target/release/ \;
find target/release -name mgit-gui -exec mv {} target/release/ \;
chmod +x target/release/mgit target/release/mgit-gui
- name: Build DEB Package
run: |
# We use --no-build because we already have the binaries
# We point to mgit-gui because that's where we configured the combined DEB
cargo deb -p mgit-gui --no-build --output target/debian/mgit_${{ github.ref_name }}_amd64.deb
- name: Upload DEB
uses: softprops/action-gh-release@v2
with:
files: target/debian/*.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}