Skip to content

Commit

Permalink
build(ci): cross-build wheels by setting env variables in github wo…
Browse files Browse the repository at this point in the history
…rkflows
  • Loading branch information
WSH032 committed Dec 17, 2023
1 parent db2c8ff commit 179562a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
47 changes: 42 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,46 @@ jobs:
uses: ./.github/workflows/lint-test.yml
secrets: inherit # IMPORTANT: sub-workflow needs secrets for uploading codecov

build-dist:
build-wheel:
needs:
- lint-test
name: Build distribution 📦
name: Build wheel distribution 📦
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# keep `cross_host` consistent with `tag_4_build_enum` in `hatch_build.py`
cross_host:
- x86_64-linux-musl
- aarch64-linux-musl
- x86_64-w64-mingw32
- i686-w64-mingw32
env:
CROSS_HOST: ${{ matrix.cross_host }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Build a binary wheel
run: |
hatch build --target wheel -c
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
if-no-files-found: error

build-sdist:
needs:
- lint-test
name: Build sdist distribution 📦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -31,9 +67,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Build a binary wheel and a source tarball
- name: Build a sdist
run: |
hatch build
hatch build --target sdist
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
Expand All @@ -43,7 +79,8 @@ jobs:

publish-to-pypi:
needs:
- build-dist
- build-wheel
- build-sdist
name: Publish Python 🐍 distribution 📦 to PyPI
runs-on: ubuntu-latest
environment:
Expand Down
1 change: 1 addition & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Tag4Build(NamedTuple):
whl_platform: str


# keep all of `Tag4Build().aria2_build` consistent with `matrix.cross_host` in `.github\workflows\publish.yml`
tag_4_build_enum = (
Tag4Build("x86_64-linux-musl", "linux_x86_64"),
Tag4Build("aarch64-linux-musl", "linux_aarch64"),
Expand Down

0 comments on commit 179562a

Please sign in to comment.