-
-
Notifications
You must be signed in to change notification settings - Fork 1
478 lines (399 loc) · 17.5 KB
/
release.yml
File metadata and controls
478 lines (399 loc) · 17.5 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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
name: Release
on:
push:
tags:
- "v*"
jobs:
build-release:
# Add permissions for release asset uploads
permissions:
contents: write
strategy:
matrix:
include:
- os: ubuntu-latest
arch: x86_64
cc: clang
cxx: clang++
platform: linux
- os: macos-14
arch: arm64
cc: clang
cxx: clang++
platform: macos
- os: windows-latest
arch: x86_64
cc: cl
cxx: cl
platform: windows
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies (Ubuntu)
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake clang rpm libzstd-dev libsodium-dev
# Install fpm for package creation
sudo gem install fpm
- name: Install dependencies (macOS)
if: matrix.platform == 'macos'
run: |
echo "cmake is already available on macOS runners"
# Install create-dmg for DMG creation, zstd for compression, and libsodium for encryption
brew install create-dmg zstd libsodium
- name: Install dependencies (Windows)
if: matrix.platform == 'windows'
run: |
vcpkg install zstd:x64-windows libsodium:x64-windows
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" >> $env:GITHUB_ENV
- name: Build Release (non-Windows)
if: matrix.platform != 'windows'
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DBFC_WITH_ZSTD=ON \
-DBFC_WITH_SODIUM=ON
cmake --build build --config Release -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)
- name: Build Release (Windows)
if: matrix.platform == 'windows'
run: |
cmake -B build `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DBFC_WITH_ZSTD=ON `
-DBFC_WITH_SODIUM=ON `
-DBFC_BUILD_BENCHMARKS=OFF
cmake --build build --config Release -j4
- name: Run tests (non-Windows)
if: matrix.platform != 'windows'
run: |
cd build
ctest --output-on-failure
- name: Run tests (Windows)
if: matrix.platform == 'windows'
run: |
cd build
ctest --output-on-failure -C Release
- name: Test CLI functionality (non-Windows)
if: matrix.platform != 'windows'
run: |
# Create test data
mkdir -p test_data
echo "Hello World" > test_data/hello.txt
echo "Goodbye" > test_data/bye.txt
mkdir -p test_data/subdir
echo "Nested file" > test_data/subdir/nested.txt
# Test CLI workflow
./build/bin/bfc create test.bfc test_data/
./build/bin/bfc list test.bfc
./build/bin/bfc info test.bfc
./build/bin/bfc verify test.bfc
./build/bin/bfc verify --deep test.bfc
# Test compression functionality
./build/bin/bfc create -c zstd test_compressed.bfc test_data/
./build/bin/bfc info test_compressed.bfc test_data/hello.txt
./build/bin/bfc verify test_compressed.bfc
# Test different compression levels
./build/bin/bfc create -c zstd -l 1 test_fast.bfc test_data/
./build/bin/bfc create -c zstd -l 6 test_balanced.bfc test_data/
./build/bin/bfc info test_balanced.bfc test_data/hello.txt
# Test extraction
mkdir -p extract_test
cd extract_test
../build/bin/bfc extract ../test.bfc
# Verify extracted files
[ -f hello.txt ] && echo "hello.txt extracted"
[ -f bye.txt ] && echo "bye.txt extracted"
[ -f subdir/nested.txt ] && echo "nested.txt extracted"
cd ..
rm -rf extract_test
# Test encryption functionality
echo "Testing encryption features..."
./build/bin/bfc create -e testpassword123 test_encrypted.bfc test_data/
./build/bin/bfc info test_encrypted.bfc
./build/bin/bfc info test_encrypted.bfc test_data/hello.txt | grep -i encrypt
# Test encrypted extraction
mkdir -p extract_encrypted
cd extract_encrypted
../build/bin/bfc extract -p testpassword123 ../test_encrypted.bfc
# Verify extracted files from encrypted container
[ -f hello.txt ] && echo "hello.txt extracted from encrypted container"
[ -f bye.txt ] && echo "bye.txt extracted from encrypted container"
[ -f subdir/nested.txt ] && echo "nested.txt extracted from encrypted container"
cd ..
rm -rf extract_encrypted
# Test wrong password failure
mkdir -p extract_fail_test
cd extract_fail_test
! ../build/bin/bfc extract -p wrongpassword ../test_encrypted.bfc && echo "Correctly failed with wrong password"
cd ..
rm -rf extract_fail_test
# Test key file encryption
echo -n "0123456789abcdef0123456789abcdef" > test.key
./build/bin/bfc create -k test.key test_keyfile.bfc test_data/
./build/bin/bfc info test_keyfile.bfc | grep -i encrypt
mkdir -p extract_keyfile
cd extract_keyfile
../build/bin/bfc extract -K ../test.key ../test_keyfile.bfc
[ -f hello.txt ] && echo "hello.txt extracted with key file"
cd ..
rm -rf extract_keyfile
# Test encryption with compression
echo "This is a larger test file with enough content to be compressed by zstd compression algorithm." > test_data/large.txt
./build/bin/bfc create -e testpass -c zstd test_enc_comp.bfc test_data/
./build/bin/bfc info test_enc_comp.bfc test_data/large.txt | grep -i encrypt
./build/bin/bfc info test_enc_comp.bfc test_data/large.txt | grep -i zstd
# Clean up
rm -rf test.bfc test_data test_compressed.bfc test_fast.bfc test_balanced.bfc
rm -rf test_encrypted.bfc test_keyfile.bfc test_enc_comp.bfc test.key
- name: Test CLI functionality (Windows)
if: matrix.platform == 'windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force test_data\subdir | Out-Null
"Hello World" | Out-File -Encoding utf8 test_data\hello.txt
"Goodbye" | Out-File -Encoding utf8 test_data\bye.txt
"Nested file" | Out-File -Encoding utf8 test_data\subdir\nested.txt
$bfc = Get-ChildItem -Recurse build\bin -Filter bfc.exe | Select-Object -First 1 -ExpandProperty FullName
if (-not $bfc) { Write-Error "bfc.exe not found"; exit 1 }
& $bfc create test.bfc test_data\
& $bfc list test.bfc
& $bfc info test.bfc
& $bfc verify test.bfc
& $bfc verify --deep test.bfc
& $bfc create -c zstd test_compressed.bfc test_data\
& $bfc verify test_compressed.bfc
New-Item -ItemType Directory -Force extract_test | Out-Null
Push-Location extract_test
& $bfc extract ..\test.bfc
if (Test-Path hello.txt) { Write-Output "hello.txt extracted" }
Pop-Location
Remove-Item -Recurse -Force extract_test
& $bfc create -e testpassword123 test_encrypted.bfc test_data\
New-Item -ItemType Directory -Force extract_enc | Out-Null
Push-Location extract_enc
& $bfc extract -p testpassword123 ..\test_encrypted.bfc
if (Test-Path hello.txt) { Write-Output "hello.txt extracted from encrypted container" }
Pop-Location
Remove-Item -Recurse -Force extract_enc
Remove-Item -Recurse -Force test_data, test.bfc, test_compressed.bfc, test_encrypted.bfc -ErrorAction SilentlyContinue
- name: Get version
id: get_version
shell: bash
run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Create release package (non-Windows)
if: matrix.platform != 'windows'
run: |
VERSION=${{ steps.get_version.outputs.version }}
PACKAGE_NAME=bfc-${VERSION#v}-${{ matrix.platform }}-${{ matrix.arch }}
# Create package directory
mkdir -p ${PACKAGE_NAME}
# Copy binaries and libraries
cp build/bin/bfc ${PACKAGE_NAME}/
cp build/lib/libbfc.a ${PACKAGE_NAME}/
if [ "${{ matrix.platform }}" = "linux" ]; then
cp build/lib/libbfc.so ${PACKAGE_NAME}/
else
cp build/lib/libbfc.dylib ${PACKAGE_NAME}/
fi
# Copy headers and documentation
cp include/bfc.h ${PACKAGE_NAME}/
cp README.md ${PACKAGE_NAME}/
cp LICENSE ${PACKAGE_NAME}/
# Create install script
cat > ${PACKAGE_NAME}/install.sh << 'EOF'
#!/bin/bash
set -e
PREFIX=${1:-/usr/local}
echo "Installing BFC to ${PREFIX}"
# Create directories
sudo mkdir -p ${PREFIX}/bin ${PREFIX}/lib ${PREFIX}/include
# Install files
sudo cp bfc ${PREFIX}/bin/
sudo cp libbfc.* ${PREFIX}/lib/
sudo cp bfc.h ${PREFIX}/include/
# Update library cache (Linux only)
if command -v ldconfig >/dev/null 2>&1; then
sudo ldconfig
fi
echo "BFC installed successfully!"
echo "Try: bfc --version"
EOF
chmod +x ${PACKAGE_NAME}/install.sh
# Create tarball
tar -czf ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME}
- name: Create release package (Windows)
if: matrix.platform == 'windows'
shell: pwsh
run: |
$version = "${{ steps.get_version.outputs.version }}"
$versionNoV = $version.TrimStart('v')
$pkgName = "bfc-$versionNoV-windows-x86_64"
New-Item -ItemType Directory -Force $pkgName | Out-Null
# Find and copy binaries
$bfcExe = Get-ChildItem -Recurse build\bin -Filter bfc.exe | Select-Object -First 1 -ExpandProperty FullName
Copy-Item $bfcExe "$pkgName\bfc.exe"
Copy-Item (Get-ChildItem -Recurse build\lib -Filter bfc.lib | Select-Object -First 1 -ExpandProperty FullName) "$pkgName\bfc.lib"
Copy-Item (Get-ChildItem -Recurse build\lib -Filter bfc.dll -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName) "$pkgName\bfc.dll" -ErrorAction SilentlyContinue
# Copy headers and docs
Copy-Item include\bfc.h "$pkgName\"
Copy-Item README.md "$pkgName\"
Copy-Item LICENSE "$pkgName\"
# Create install script
@'
@echo off
echo Installing BFC...
copy bfc.exe "%ProgramFiles%\bfc\bfc.exe" 2>nul || (
mkdir "%ProgramFiles%\bfc"
copy bfc.exe "%ProgramFiles%\bfc\bfc.exe"
)
copy bfc.h "%ProgramFiles%\bfc\bfc.h"
echo BFC installed to %ProgramFiles%\bfc
'@ | Out-File -Encoding ascii "$pkgName\install.bat"
# Create ZIP
Compress-Archive -Path $pkgName -DestinationPath "$pkgName.zip"
- name: Create DEB and RPM packages (Linux only)
if: matrix.platform == 'linux'
run: |
VERSION=${{ steps.get_version.outputs.version }}
VERSION_NO_V=${VERSION#v}
# Create staging directory
mkdir -p staging/usr/bin
mkdir -p staging/usr/lib
mkdir -p staging/usr/include
mkdir -p staging/usr/share/doc/bfc
# Copy files to staging
cp build/bin/bfc staging/usr/bin/
cp build/lib/libbfc.a staging/usr/lib/
cp build/lib/libbfc.so staging/usr/lib/
cp include/bfc.h staging/usr/include/
cp README.md staging/usr/share/doc/bfc/
cp LICENSE staging/usr/share/doc/bfc/
# Create DEB package
fpm -s dir -t deb -n bfc -v ${VERSION_NO_V} \
--description "Binary File Container - High-performance single-file container format with encryption and compression support" \
--url "https://github.com/zombocoder/bfc" \
--maintainer "zombocoder <zombocoder@users.noreply.github.com>" \
--license "Apache-2.0" \
--architecture ${{ matrix.arch }} \
--depends libc6 \
--depends libzstd1 \
--depends libsodium23 \
-C staging \
usr/bin usr/lib usr/include usr/share
# Create RPM package
fpm -s dir -t rpm -n bfc -v ${VERSION_NO_V} \
--description "Binary File Container - High-performance single-file container format with encryption and compression support" \
--url "https://github.com/zombocoder/bfc" \
--maintainer "zombocoder <zombocoder@users.noreply.github.com>" \
--license "Apache-2.0" \
--architecture ${{ matrix.arch }} \
--depends glibc \
--depends libzstd \
--depends libsodium \
-C staging \
usr/bin usr/lib usr/include usr/share
- name: Create macOS DMG package (macOS only)
if: matrix.platform == 'macos'
run: |
VERSION=${{ steps.get_version.outputs.version }}
VERSION_NO_V=${VERSION#v}
DMG_NAME=bfc-${VERSION_NO_V}-${{ matrix.platform }}-${{ matrix.arch }}
# Create app bundle structure
mkdir -p BFC.app/Contents/{MacOS,Resources,Frameworks}
# Create Info.plist
cat > BFC.app/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>CFBundleExecutable</key>
<string>bfc</string>
<key>CFBundleIdentifier</key>
<string>com.zombocoder.bfc</string>
<key>CFBundleName</key>
<string>BFC</string>
<key>CFBundleVersion</key>
<string>${VERSION_NO_V}</string>
<key>CFBundleShortVersionString</key>
<string>${VERSION_NO_V}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
</dict>
</plist>
EOF
# Copy binaries and libraries
cp build/bin/bfc BFC.app/Contents/MacOS/
cp build/lib/libbfc.a BFC.app/Contents/Frameworks/
cp build/lib/libbfc.dylib BFC.app/Contents/Frameworks/
# Create CLI installer package directory
mkdir -p bfc-cli/usr/local/{bin,lib,include}
cp build/bin/bfc bfc-cli/usr/local/bin/
cp build/lib/libbfc.* bfc-cli/usr/local/lib/
cp include/bfc.h bfc-cli/usr/local/include/
# Create installer script
cat > bfc-cli/install.sh << 'EOF'
#!/bin/bash
set -e
echo "Installing BFC CLI tools..."
# Copy files
sudo cp usr/local/bin/bfc /usr/local/bin/
sudo cp usr/local/lib/libbfc.* /usr/local/lib/
sudo cp usr/local/include/bfc.h /usr/local/include/
# Update library cache
sudo update_dyld_shared_cache || true
echo "BFC installed successfully!"
echo "Try: bfc --version"
EOF
chmod +x bfc-cli/install.sh
# Create DMG with both app bundle and CLI tools
mkdir -p dmg-contents
cp -r BFC.app dmg-contents/
cp -r bfc-cli dmg-contents/"BFC CLI Tools"
cp README.md dmg-contents/
cp LICENSE dmg-contents/
# Create symlink to Applications
ln -s /Applications dmg-contents/Applications
# Create DMG
create-dmg \
--volname "BFC ${VERSION_NO_V}" \
--volicon dmg-contents/BFC.app/Contents/Resources/icon.icns \
--window-pos 200 120 \
--window-size 800 600 \
--icon-size 100 \
--icon "BFC.app" 200 190 \
--icon "Applications" 600 190 \
--icon "BFC CLI Tools" 200 350 \
--hide-extension "BFC.app" \
--app-drop-link 600 185 \
--no-internet-enable \
"${DMG_NAME}.dmg" \
dmg-contents/ || \
# Fallback if create-dmg fails
hdiutil create -volname "BFC ${VERSION_NO_V}" -srcfolder dmg-contents -ov -format UDZO "${DMG_NAME}.dmg"
- name: Upload Release Assets
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.get_version.outputs.version }}
run: |
echo "Current directory contents:"
ls -la
echo "Looking for package files..."
find . -maxdepth 1 \( -name "*.tar.gz" -o -name "*.deb" -o -name "*.rpm" -o -name "*.dmg" -o -name "*.zip" \)
shopt -s nullglob
for file in *.tar.gz *.deb *.rpm *.dmg *.zip; do
echo "Uploading $file to release ${VERSION}"
gh release upload "${VERSION}" "$file" --clobber
done