-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (109 loc) · 4.48 KB
/
release.yml
File metadata and controls
129 lines (109 loc) · 4.48 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
name: BitCal ${{ github.ref_name }}
body: |
## BitCal ${{ github.ref_name }}
### 安装
BitCal 是 header-only 库,下载 `bitcal-*-headers.zip` 后,将 `include/bitcal/` 目录复制到你的项目中即可。
```cpp
#include <bitcal/bitcal.hpp>
```
### 平台包说明
| 包名 | 平台 | 说明 |
|------|------|------|
| `bitcal-*-headers.zip` | 全平台 | 仅头文件(推荐) |
| `bitcal-*-linux-x64.tar.gz` | Linux x64 | 含头文件 + 测试和示例 |
| `bitcal-*-windows-x64.zip` | Windows x64 | 含头文件 + 测试和示例 |
| `bitcal-*-macos-x64.tar.gz` | macOS x64 | 含头文件 + 测试和示例 |
| `bitcal-*-macos-arm64.tar.gz` | macOS ARM64 | 含头文件 + 测试和示例 |
package-headers:
name: Package Headers
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Package
run: |
mkdir -p bitcal-${{ github.ref_name }}-headers/include
cp -r include/bitcal bitcal-${{ github.ref_name }}-headers/include/
cp LICENSE README.md CHANGELOG.md bitcal-${{ github.ref_name }}-headers/
cp -r cmake bitcal-${{ github.ref_name }}-headers/ 2>/dev/null || true
cp CMakeLists.txt bitcal-${{ github.ref_name }}-headers/
zip -r bitcal-${{ github.ref_name }}-headers.zip bitcal-${{ github.ref_name }}-headers/
- name: Upload
uses: softprops/action-gh-release@v2
with:
files: bitcal-${{ github.ref_name }}-headers.zip
package-platform:
needs: create-release
strategy:
matrix:
include:
- os: ubuntu-latest
name: linux-x64
ext: tar.gz
- os: windows-latest
name: windows-x64
ext: zip
- os: macos-13
name: macos-x64
ext: tar.gz
- os: macos-latest
name: macos-arm64
ext: tar.gz
name: Package ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Build
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBITCAL_NATIVE_ARCH=ON
cmake --build build --config Release
- name: Test
run: ctest --test-dir build --output-on-failure -C Release
- name: Package (Unix)
if: matrix.ext == 'tar.gz'
run: |
PKG=bitcal-${{ github.ref_name }}-${{ matrix.name }}
mkdir -p $PKG/include $PKG/bin
cp -r include/bitcal $PKG/include/
cp LICENSE README.md CHANGELOG.md $PKG/
# Copy test and example binaries from build directory
if [ -f build/tests/test_bitcal ]; then cp build/tests/test_bitcal $PKG/bin/; fi
if [ -f build/examples/basic_usage ]; then cp build/examples/basic_usage $PKG/bin/; fi
if [ -f build/examples/performance_comparison ]; then cp build/examples/performance_comparison $PKG/bin/; fi
tar czf $PKG.tar.gz $PKG/
- name: Package (Windows)
if: matrix.ext == 'zip'
shell: pwsh
run: |
$PKG = "bitcal-${{ github.ref_name }}-${{ matrix.name }}"
New-Item -ItemType Directory -Path "$PKG/include", "$PKG/bin" -Force
Copy-Item -Recurse include/bitcal "$PKG/include/"
Copy-Item LICENSE, README.md, CHANGELOG.md "$PKG/"
# Copy test and example binaries from build directory
if (Test-Path "build/tests/test_bitcal.exe") { Copy-Item "build/tests/test_bitcal.exe" "$PKG/bin/" }
if (Test-Path "build/examples/basic_usage.exe") { Copy-Item "build/examples/basic_usage.exe" "$PKG/bin/" }
if (Test-Path "build/examples/performance_comparison.exe") { Copy-Item "build/examples/performance_comparison.exe" "$PKG/bin/" }
Compress-Archive -Path "$PKG" -DestinationPath "$PKG.zip"
- name: Upload
uses: softprops/action-gh-release@v2
with:
files: bitcal-${{ github.ref_name }}-${{ matrix.name }}.${{ matrix.ext }}