Skip to content

Commit aecd471

Browse files
完善 CI 并新增 release 工作流。
补全多平台 CI 的触发、并发控制和 release 构建流程,新增手动发布并自动创建 GitHub Release 的工作流。 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4580868 commit aecd471

2 files changed

Lines changed: 184 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@ on:
55
branches: [main, master]
66
pull_request:
77
branches: [main, master]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
816

917
jobs:
1018
build-linux:
1119
runs-on: ubuntu-latest
20+
timeout-minutes: 20
1221
steps:
1322
- name: Checkout
1423
uses: actions/checkout@v4
@@ -35,7 +44,8 @@ jobs:
3544
- name: Build
3645
run: |
3746
export PATH=/home/xlings/.xlings_data/bin:$PATH
38-
xmake -y -vv
47+
xmake f -m release -y
48+
xmake -j$(nproc)
3949
4050
- name: Test
4151
run: |
@@ -48,27 +58,31 @@ jobs:
4858
xmake run basic
4959
5060
build-macos:
51-
runs-on: macos-latest
61+
runs-on: macos-14
62+
timeout-minutes: 20
5263
steps:
5364
- name: Checkout
5465
uses: actions/checkout@v4
5566

56-
- name: Setup xmake
57-
uses: xmake-io/github-action-setup-xmake@v1
58-
with:
59-
xmake-version: latest
60-
package-cache: true
61-
62-
- name: Install LLVM 20
63-
run: brew install llvm@20
67+
- name: Install dependencies
68+
run: brew install xmake llvm@20
6469

6570
- name: Build
6671
run: |
67-
xmake f --toolchain=llvm --sdk=/opt/homebrew/opt/llvm@20
68-
xmake -y -vv
72+
export PATH=/opt/homebrew/opt/llvm@20/bin:$PATH
73+
xmake f --toolchain=llvm --sdk=/opt/homebrew/opt/llvm@20 -y
74+
xmake -m release -y
75+
xmake -j$(sysctl -n hw.ncpu)
76+
77+
- name: Test
78+
run: xmake run templates_test
79+
80+
- name: Run examples
81+
run: xmake run basic
6982

7083
build-windows:
7184
runs-on: windows-latest
85+
timeout-minutes: 20
7286
steps:
7387
- name: Checkout
7488
uses: actions/checkout@v4
@@ -80,7 +94,9 @@ jobs:
8094
package-cache: true
8195

8296
- name: Build
83-
run: xmake -y -vv
97+
run: |
98+
xmake f -m release -y
99+
xmake -j$env:NUMBER_OF_PROCESSORS
84100
85101
- name: Test
86102
run: xmake run templates_test

.github/workflows/release.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Release version (e.g., 0.1.1)"
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build-linux:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 25
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup xmake
20+
uses: xmake-io/github-action-setup-xmake@v1
21+
with:
22+
xmake-version: latest
23+
24+
- name: Install dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y build-essential
28+
29+
- name: Install Xlings
30+
run: curl -fsSL https://d2learn.org/xlings-install.sh | bash
31+
32+
- name: Install GCC 15.1 with Xlings
33+
run: |
34+
export PATH=/home/xlings/.xlings_data/bin:$PATH
35+
xlings install gcc@15.1 -y
36+
37+
- name: Build with xmake
38+
run: |
39+
export PATH=/home/xlings/.xlings_data/bin:$PATH
40+
xmake f -m release -y
41+
xmake -j$(nproc)
42+
43+
- name: Run tests
44+
run: |
45+
export PATH=/home/xlings/.xlings_data/bin:$PATH
46+
xmake run templates_test
47+
48+
- name: Create release package
49+
run: |
50+
PKG="mcpplibs-templates-${{ inputs.version }}-linux-x86_64"
51+
mkdir -p "$PKG"
52+
cp build/linux/x86_64/release/libmcpplibs-templates.a "$PKG/"
53+
cp src/templates.cppm README.md LICENSE "$PKG/"
54+
tar -czf "${PKG}.tar.gz" "$PKG"
55+
56+
- name: Upload artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: templates-linux-x86_64
60+
path: mcpplibs-templates-${{ inputs.version }}-linux-x86_64.tar.gz
61+
62+
build-macos:
63+
runs-on: macos-14
64+
timeout-minutes: 25
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v4
68+
69+
- name: Install dependencies
70+
run: brew install xmake llvm@20
71+
72+
- name: Build with xmake (LLVM 20)
73+
run: |
74+
export PATH=/opt/homebrew/opt/llvm@20/bin:$PATH
75+
xmake f -p macosx -m release --toolchain=llvm --sdk=/opt/homebrew/opt/llvm@20 -y
76+
xmake -j$(sysctl -n hw.ncpu)
77+
78+
- name: Run tests
79+
run: xmake run templates_test
80+
81+
- name: Create release package
82+
run: |
83+
PKG="mcpplibs-templates-${{ inputs.version }}-macosx-arm64"
84+
mkdir -p "$PKG"
85+
cp build/macosx/arm64/release/libmcpplibs-templates.a "$PKG/"
86+
cp src/templates.cppm README.md LICENSE "$PKG/"
87+
tar -czf "${PKG}.tar.gz" "$PKG"
88+
89+
- name: Upload artifact
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: templates-macosx-arm64
93+
path: mcpplibs-templates-${{ inputs.version }}-macosx-arm64.tar.gz
94+
95+
build-windows:
96+
runs-on: windows-latest
97+
timeout-minutes: 25
98+
steps:
99+
- name: Checkout
100+
uses: actions/checkout@v4
101+
102+
- name: Setup xmake
103+
uses: xmake-io/github-action-setup-xmake@v1
104+
with:
105+
xmake-version: latest
106+
107+
- name: Build with xmake
108+
run: |
109+
xmake f -m release -y
110+
xmake -j$env:NUMBER_OF_PROCESSORS
111+
112+
- name: Run tests
113+
run: xmake run templates_test
114+
115+
- name: Create release package
116+
shell: pwsh
117+
run: |
118+
$pkg = "mcpplibs-templates-${{ inputs.version }}-windows-x86_64"
119+
New-Item -ItemType Directory -Path $pkg -Force | Out-Null
120+
Copy-Item "build\windows\x64\release\mcpplibs-templates.lib" -Destination "$pkg\"
121+
Copy-Item "src\templates.cppm" -Destination "$pkg\"
122+
Copy-Item "README.md" -Destination "$pkg\"
123+
Copy-Item "LICENSE" -Destination "$pkg\"
124+
Compress-Archive -Path $pkg -DestinationPath "$pkg.zip"
125+
126+
- name: Upload artifact
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: templates-windows-x86_64
130+
path: mcpplibs-templates-${{ inputs.version }}-windows-x86_64.zip
131+
132+
create-release:
133+
needs: [build-linux, build-macos, build-windows]
134+
runs-on: ubuntu-latest
135+
permissions:
136+
contents: write
137+
steps:
138+
- name: Download all artifacts
139+
uses: actions/download-artifact@v4
140+
with:
141+
path: artifacts
142+
143+
- name: Create Release
144+
uses: softprops/action-gh-release@v1
145+
with:
146+
tag_name: v${{ inputs.version }}
147+
name: ${{ inputs.version }}
148+
draft: false
149+
prerelease: false
150+
files: |
151+
artifacts/templates-linux-x86_64/mcpplibs-templates-${{ inputs.version }}-linux-x86_64.tar.gz
152+
artifacts/templates-macosx-arm64/mcpplibs-templates-${{ inputs.version }}-macosx-arm64.tar.gz
153+
artifacts/templates-windows-x86_64/mcpplibs-templates-${{ inputs.version }}-windows-x86_64.zip
154+
env:
155+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)