-
Notifications
You must be signed in to change notification settings - Fork 0
379 lines (316 loc) · 12.9 KB
/
release.yml
File metadata and controls
379 lines (316 loc) · 12.9 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
name: Release Build
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.0)'
required: true
type: string
env:
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
fi
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event_name == 'workflow_dispatch' && format('v{0}', github.event.inputs.version) || github.ref }}
name: StreamLib v${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
source-archive:
name: Create Source Archive
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create source archive
run: |
VERSION="${{ needs.create-release.outputs.version }}"
mkdir -p streamlib-${VERSION}
# Copy source files
cp -r src include examples tests CMakeLists.txt streamlib-${VERSION}/
cp README.md LICENSE TODO.md streamlib-${VERSION}/
# Create archives
tar czf streamlib-${VERSION}-source.tar.gz streamlib-${VERSION}/
zip -r streamlib-${VERSION}-source.zip streamlib-${VERSION}/
- name: Upload source archives
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.create-release.outputs.version }}
files: |
streamlib-*.tar.gz
streamlib-*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-windows:
name: Build Windows (${{ matrix.config.name }})
needs: create-release
runs-on: windows-latest
strategy:
matrix:
config:
- name: "Static"
static: "ON"
shared: "OFF"
suffix: "static"
- name: "DLL"
static: "OFF"
shared: "ON"
suffix: "dll"
steps:
- uses: actions/checkout@v4
# Export GitHub Actions cache environment variables for vcpkg
- name: Setup vcpkg binary caching
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
# Dependencies are declared in vcpkg.json and installed automatically by CMake
- name: Configure CMake
run: |
cmake -B build -S . `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" `
-DBUILD_SHARED_LIBS=${{ matrix.config.shared }} `
-DENABLE_ZLIB=ON `
-DENABLE_BZIP2=ON `
-DENABLE_LZMA=ON `
-DENABLE_ZSTD=ON `
-DENABLE_LIBARCHIVE=ON
- name: Build
run: cmake --build build --config Release --parallel
- name: Run tests
shell: pwsh
run: |
# Add DLL directories to PATH
$env:PATH = "${{ github.workspace }}\build\Release;${{ github.workspace }}\vcpkg\installed\x64-windows\bin;$env:PATH"
cd build
ctest -C Release --output-on-failure
- name: Package
shell: pwsh
run: |
$VERSION = "${{ needs.create-release.outputs.version }}"
$SUFFIX = "${{ matrix.config.suffix }}"
$PKG_DIR = "streamlib-${VERSION}-windows-x64-${SUFFIX}"
# Create package structure
New-Item -ItemType Directory -Force -Path "${PKG_DIR}/include"
New-Item -ItemType Directory -Force -Path "${PKG_DIR}/lib"
New-Item -ItemType Directory -Force -Path "${PKG_DIR}/bin"
New-Item -ItemType Directory -Force -Path "${PKG_DIR}/examples"
# Copy headers
Copy-Item -Recurse include/* "${PKG_DIR}/include/"
# Copy library files
if ("${{ matrix.config.shared }}" -eq "ON") {
# DLL build
Copy-Item build/Release/stream.dll "${PKG_DIR}/bin/"
Copy-Item build/Release/stream.lib "${PKG_DIR}/lib/"
# Copy dependency DLLs
$VCPKG_ROOT = "${{ github.workspace }}/vcpkg/installed/x64-windows/bin"
Copy-Item "${VCPKG_ROOT}/zlib1.dll" "${PKG_DIR}/bin/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_ROOT}/bz2.dll" "${PKG_DIR}/bin/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_ROOT}/lzma.dll" "${PKG_DIR}/bin/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_ROOT}/zstd.dll" "${PKG_DIR}/bin/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_ROOT}/archive.dll" "${PKG_DIR}/bin/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_ROOT}/liblzma.dll" "${PKG_DIR}/bin/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_ROOT}/charset.dll" "${PKG_DIR}/bin/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_ROOT}/iconv.dll" "${PKG_DIR}/bin/" -ErrorAction SilentlyContinue
} else {
# Static build
Copy-Item build/Release/stream.lib "${PKG_DIR}/lib/"
# Copy dependency static libs
$VCPKG_LIB = "${{ github.workspace }}/vcpkg/installed/x64-windows/lib"
Copy-Item "${VCPKG_LIB}/zlib.lib" "${PKG_DIR}/lib/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_LIB}/bz2.lib" "${PKG_DIR}/lib/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_LIB}/lzma.lib" "${PKG_DIR}/lib/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_LIB}/zstd.lib" "${PKG_DIR}/lib/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_LIB}/archive.lib" "${PKG_DIR}/lib/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_LIB}/liblzma.lib" "${PKG_DIR}/lib/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_LIB}/charset.lib" "${PKG_DIR}/lib/" -ErrorAction SilentlyContinue
Copy-Item "${VCPKG_LIB}/iconv.lib" "${PKG_DIR}/lib/" -ErrorAction SilentlyContinue
}
# Copy example source files
Copy-Item examples/*.c "${PKG_DIR}/examples/"
# Copy documentation
Copy-Item README.md, LICENSE "${PKG_DIR}/"
# Create README for the package
$BUILD_TYPE = "${{ matrix.config.name }}"
$readme = "${PKG_DIR}/README.md"
"StreamLib Library v${VERSION} - Windows x64 (${BUILD_TYPE})" | Out-File -FilePath $readme -Encoding UTF8
"===============================================================" | Out-File -FilePath $readme -Append -Encoding UTF8
"" | Out-File -FilePath $readme -Append -Encoding UTF8
"This package contains the StreamLib library built for Windows x64." | Out-File -FilePath $readme -Append -Encoding UTF8
"" | Out-File -FilePath $readme -Append -Encoding UTF8
"CONTENTS" | Out-File -FilePath $readme -Append -Encoding UTF8
"--------" | Out-File -FilePath $readme -Append -Encoding UTF8
"- include/ - Header files" | Out-File -FilePath $readme -Append -Encoding UTF8
"- lib/ - Library files (.lib)" | Out-File -FilePath $readme -Append -Encoding UTF8
"- bin/ - DLL files (DLL build only)" | Out-File -FilePath $readme -Append -Encoding UTF8
"- examples/ - Example source code" | Out-File -FilePath $readme -Append -Encoding UTF8
"" | Out-File -FilePath $readme -Append -Encoding UTF8
"USAGE" | Out-File -FilePath $readme -Append -Encoding UTF8
"For DLL build: Add include/ and lib/ to your paths, link against stream.lib" | Out-File -FilePath $readme -Append -Encoding UTF8
"For static build: Link against stream.lib and all dependency .lib files" | Out-File -FilePath $readme -Append -Encoding UTF8
"" | Out-File -FilePath $readme -Append -Encoding UTF8
"VERSION: StreamLib v${VERSION} (${BUILD_TYPE}) - Windows x64" | Out-File -FilePath $readme -Append -Encoding UTF8
# Create archive
Compress-Archive -Path "${PKG_DIR}" -DestinationPath "${PKG_DIR}.zip"
- name: Upload Windows package
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.create-release.outputs.version }}
files: streamlib-*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-linux:
name: Build Linux
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
zlib1g-dev \
libbz2-dev \
liblzma-dev \
libzstd-dev \
libarchive-dev
- name: Configure
run: |
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_ZLIB=ON \
-DENABLE_BZIP2=ON \
-DENABLE_LZMA=ON \
-DENABLE_ZSTD=ON \
-DENABLE_LIBARCHIVE=ON
- name: Build
run: cmake --build build --parallel
- name: Run tests
run: |
cd build
ctest --output-on-failure
- name: Package
run: |
VERSION="${{ needs.create-release.outputs.version }}"
PKG_DIR="streamlib-${VERSION}-linux-x64"
mkdir -p ${PKG_DIR}/{include,lib,examples}
# Copy files
cp -r include/* ${PKG_DIR}/include/
cp build/libstream.a ${PKG_DIR}/lib/
cp examples/*.c ${PKG_DIR}/examples/
cp README.md LICENSE ${PKG_DIR}/
# Create README for package
cat > ${PKG_DIR}/README.md << 'EOFREADME'
StreamLib Library - Linux x64
==============================
CONTENTS
--------
- include/ - Header files
- lib/ - Static library (libstream.a)
- examples/ - Example source code
DEPENDENCIES
------------
This library requires: zlib, bzip2, liblzma, libzstd, libarchive
Install on Ubuntu/Debian:
sudo apt-get install zlib1g-dev libbz2-dev liblzma-dev libzstd-dev libarchive-dev
USAGE
-----
include_directories(/path/to/streamlib/include)
target_link_libraries(your_target /path/to/streamlib/lib/libstream.a z bz2 lzma zstd archive)
For more information, see the main README.md
EOFREADME
tar czf ${PKG_DIR}.tar.gz ${PKG_DIR}/
- name: Upload Linux package
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.create-release.outputs.version }}
files: streamlib-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-macos:
name: Build macOS
needs: create-release
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: brew install zlib bzip2 xz zstd libarchive
- name: Configure
run: |
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_ZLIB=ON \
-DENABLE_BZIP2=ON \
-DENABLE_LZMA=ON \
-DENABLE_ZSTD=ON \
-DENABLE_LIBARCHIVE=ON
- name: Build
run: cmake --build build --parallel
- name: Run tests
run: |
cd build
ctest --output-on-failure
- name: Package
run: |
VERSION="${{ needs.create-release.outputs.version }}"
PKG_DIR="streamlib-${VERSION}-macos-x64"
mkdir -p ${PKG_DIR}/{include,lib,examples}
# Copy files
cp -r include/* ${PKG_DIR}/include/
cp build/libstream.a ${PKG_DIR}/lib/
cp examples/*.c ${PKG_DIR}/examples/
cp README.md LICENSE ${PKG_DIR}/
# Create README for package
cat > ${PKG_DIR}/README.md << 'EOFREADME'
StreamLib Library - macOS x64
==============================
CONTENTS
--------
- include/ - Header files
- lib/ - Static library (libstream.a)
- examples/ - Example source code
DEPENDENCIES
------------
This library requires: zlib, bzip2, xz, zstd, libarchive
Install with Homebrew:
brew install zlib bzip2 xz zstd libarchive
USAGE
-----
include_directories(/path/to/streamlib/include)
target_link_libraries(your_target /path/to/streamlib/lib/libstream.a z bz2 lzma zstd archive)
For more information, see the main README.md
EOFREADME
tar czf ${PKG_DIR}.tar.gz ${PKG_DIR}/
- name: Upload macOS package
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.create-release.outputs.version }}
files: streamlib-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}