[Package] Build and upload to PyPI (#56) #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GH actions. | |
name: Wheel-Manylinux | |
on: push | |
jobs: | |
Build: | |
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
strategy: | |
matrix: | |
config: | |
- image: 'mlcaidev/package-cpu:254d630' | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/xgrammar | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Reclaim disk space | |
run: | | |
df -h | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /opt/hostedtoolcache/CodeQL | |
sudo rm -rf /usr/local/.ghcup | |
df -h | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Checkout source | |
run: | | |
git clone https://github.com/mlc-ai/package package --recursive | |
- name: Setup script env | |
run: | | |
rm -rf conda | |
ln -s package/3rdparty/tlcpack/conda conda | |
- name: Sync XGrammar Package | |
run: | | |
python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} --skip-conda | |
- name: Build XGrammar | |
env: | |
IMAGE: ${{ matrix.config.image }} | |
run: | | |
scripts/docker/bash.sh --no-gpu $IMAGE ./scripts/build_xgrammar_wheel_manylinux.sh | |
- name: Retrieve all wheels | |
run: | | |
mkdir -p dist | |
cp python/repaired_wheels/* dist/ | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages_dir: python/repaired_wheels | |
skip_existing: true | |
verbose: true |