1+ name : Build Wheels
2+ on :
3+ push :
4+ workflow_dispatch :
5+ pull_request :
6+ branches :
7+ - master
8+
9+ jobs :
10+ build :
11+ strategy :
12+ fail-fast : false
13+ matrix :
14+ name : [manylinux-x64, manylinux-arm64, windows-x64, macos-arm64]
15+ include :
16+ - before-build : " "
17+ container : null
18+ repair : " "
19+ activate : " source .venv/bin/activate"
20+ replace-name : " "
21+ pick-wheel : " $(ls ../plugin-htmlkit/wheelhouse/*.whl | head -n1)"
22+ - name : manylinux-x64
23+ os : ubuntu-latest
24+ container :
25+ image : quay.io/pypa/manylinux_2_34_x86_64
26+ repair : " auditwheel repair dist/*.whl -w wheelhouse"
27+ replace-name : " sed -i -e 's/name = \" nonebot-plugin-htmlkit\" /name = \" test-env\" /' pyproject.toml"
28+ - name : manylinux-arm64
29+ os : ubuntu-24.04-arm
30+ container :
31+ image : quay.io/pypa/manylinux_2_34_aarch64
32+ repair : " auditwheel repair dist/*.whl -w wheelhouse"
33+ replace-name : " sed -i -e 's/name = \" nonebot-plugin-htmlkit\" /name = \" test-env\" /' pyproject.toml"
34+ - name : windows-x64
35+ os : windows-2025
36+ activate : " .venv/Scripts/activate"
37+ before-build : " cp .venv/Scripts/python.exe .venv/Scripts/python3.exe" # workaround xmake check for python3 executable
38+ replace-name : (Get-Content pyproject.toml) -replace 'name = "nonebot-plugin-htmlkit"', 'name = "test-env"' | Set-Content pyproject.toml
39+ repair : " delvewheel repair -w wheelhouse dist/*.whl"
40+ pick-wheel : " (Get-ChildItem ..\\ plugin-htmlkit\\ wheelhouse\\ *.whl | Select-Object -First 1).FullName"
41+ - name : macos-arm64
42+ os : macos-latest
43+ repair : " delocate-wheel -w wheelhouse dist/*.whl"
44+ replace-name : " sed -i '' -e 's/name = \" nonebot-plugin-htmlkit\" /name = \" test-env\" /' pyproject.toml"
45+ env :
46+ XMAKE_ROOT : ' y'
47+ MACOSX_DEPLOYMENT_TARGET : ' 11.0'
48+ XMAKE_CONFIG_MODE : release
49+
50+ name : Build on ${{ matrix.name }}
51+ runs-on : ${{ matrix.os }}
52+ container : ${{ matrix.container }}
53+
54+ steps :
55+ - name : Checkout code
56+ uses : actions/checkout@v5
57+ with :
58+ submodules : recursive
59+ - name : Install UV
60+ uses : astral-sh/setup-uv@v6
61+ - name : Install XMake
62+ uses : xmake-io/github-action-setup-xmake@v1
63+ with :
64+ xmake-version : latest
65+ package-cache : true
66+ package-cache-key : packages-${{ matrix.os }}-${{ hashFiles('xmake.lua', 'litehtml/**', '!litehtml/CMakeLists.txt') }}
67+ project-path : .
68+ actions-cache-folder : ' .xmake-cache'
69+ actions-cache-key : xmake-${{ matrix.os }}-${{ hashFiles('xmake.lua') }}
70+ - name : Pin Python Version
71+ run : uv python pin 3.10.11
72+ - name : Build wheels
73+ run : |
74+ git config --global --add safe.directory '*'
75+ uv venv
76+ ${{ matrix.before-build }}
77+ ${{ matrix.activate }}
78+ uv sync --only-group build --no-install-workspace
79+ uv build
80+ ${{ matrix.repair }}
81+ - name : Upload wheels
82+ uses : actions/upload-artifact@v4
83+ with :
84+ name : wheels-${{ matrix.os }}
85+ path : wheelhouse/*.whl
86+ - name : Build Unstripped Binaries
87+ run : |
88+ git config --global --add safe.directory '*'
89+ ${{ matrix.activate }}
90+ xmake config -m releasedbg -y
91+ xmake build -vD core
92+ xmake install -o bindist
93+ - name : Upload Binaries
94+ uses : actions/upload-artifact@v4
95+ with :
96+ name : binaries-${{ matrix.os }}
97+ path : bindist/*
98+ - name : Run Test
99+ run : |
100+ cd ../
101+ mkdir test-env
102+ cd test-env
103+ uv python pin 3.13
104+ uv venv
105+ ${{ matrix.activate }}
106+ cp -r ../plugin-htmlkit/tests/ ./tests
107+ cp ../plugin-htmlkit/pyproject.toml ./pyproject.toml
108+ ${{ matrix.replace-name }}
109+ uv sync --group test --no-install-workspace
110+ uv add ${{ matrix.pick-wheel }} --no-install-workspace
111+ uv run pytest --output-img-dir ../plugin-htmlkit/tests_output
112+ - name : Upload Test Results
113+ if : always()
114+ uses : actions/upload-artifact@v4
115+ with :
116+ name : test-results-${{ matrix.os }}
117+ path : tests_output
118+
119+ sdist :
120+ name : Build Source Distribution
121+ runs-on : ubuntu-latest
122+ steps :
123+ - name : Checkout code
124+ uses : actions/checkout@v5
125+ with :
126+ submodules : recursive
127+ - name : Install UV
128+ uses : astral-sh/setup-uv@v6
129+ - name : Pin Python Version
130+ run : uv python pin 3.10.11
131+ - name : Build sdist
132+ run : |
133+ uv venv
134+ source .venv/bin/activate
135+ uv sync --only-group build --no-install-workspace
136+ uv build --sdist
137+ mkdir sdist-out
138+ cp dist/*.tar.gz sdist-out/
139+ - name : Upload sdist
140+ uses : actions/upload-artifact@v4
141+ with :
142+ name : sdist
143+ path : sdist-out/*
144+
145+ package :
146+ name : Package + Publish to PyPI
147+ runs-on : ubuntu-latest
148+ needs : [build, sdist]
149+ permissions :
150+ id-token : write # required for OIDC trusted publisher
151+ contents : read
152+ steps :
153+ - name : Download all wheels
154+ uses : actions/download-artifact@v4
155+ with :
156+ path : dist
157+ pattern : wheels-*
158+ merge-multiple : true
159+ - name : Download sdist
160+ uses : actions/download-artifact@v4
161+ with :
162+ name : sdist
163+ path : dist
164+ - name : Upload Artifacts
165+ uses : actions/upload-artifact@v4
166+ with :
167+ name : dist
168+ path : dist/*
169+ - name : Install UV
170+ uses : astral-sh/setup-uv@v6
171+ - name : Publish to PyPI
172+ if : startsWith(github.ref, 'refs/tags/')
173+ run : |
174+ uv publish --trusted-publishing always
0 commit comments