[Package] Setup Python packaging #1
Workflow file for this run
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: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: '0 4 * * *' # 4 AM UTC | ||
jobs: | ||
Build: | ||
strategy: | ||
matrix: | ||
pkg_kind: ['nightly'] | ||
# pkg_kind: ['nightly', 'stable'] | ||
config: | ||
- image: 'mlcaidev/package-cpu:254d630' | ||
exclude: | ||
- pkg_kind: ${{ github.event_name == 'schedule' && 'stable' || '' }} | ||
runs-on: ubuntu-latest | ||
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/xgrammar xgrammar --recursive | ||
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 MLC LLM Package | ||
run: | | ||
python scripts/sync_package.py --gpu none --package xgrammar --package-name ${{ matrix.pkg_kind == 'nightly' && 'xgrammar-nightly' || 'xgrammar' }} --revision origin/main ${{ matrix.pkg_kind == 'nightly' && '--skip-checkout' || '' }} --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: Upload release to PyPI | ||
if: github.ref == 'refs/heads/main' | ||
environment: | ||
name: pypi | ||
url: https://test.pypi.org/p/xgrammar-nightly | ||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
steps: | | ||
xgrammar/python/repaired_wheels/*.whl | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |