-
-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: flesh out cibuildwheel workflow
- Loading branch information
Showing
3 changed files
with
156 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,11 @@ on: | |
# NOTE(vytas): Also allow to release to Test PyPi manually. | ||
workflow_dispatch: | ||
|
||
# TODO(vytas): Remove later (temporary testing). | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-sdist: | ||
name: sdist | ||
|
@@ -27,7 +32,8 @@ jobs: | |
|
||
- name: Build sdist | ||
run: | | ||
pip install build | ||
pip install --upgrade pip | ||
pip install --upgrade build | ||
python -m build --sdist | ||
- name: Upload artifacts | ||
|
@@ -36,6 +42,13 @@ jobs: | |
name: cibw-sdist | ||
path: dist/*.tar.gz | ||
|
||
- name: Nuclear testing | ||
run: | | ||
echo ${{ github.event_name }} | ||
echo ${{ github.event_name == 'release' }} | ||
echo ${{ github.ref }} | ||
python -c '0/0' | ||
build-wheels: | ||
name: ${{ matrix.python }}-${{ matrix.platform.name }} | ||
needs: build-sdist | ||
|
@@ -107,35 +120,93 @@ jobs: | |
name: cibw-wheel-${{ matrix.python }}-${{ matrix.platform.name }} | ||
path: wheelhouse/*.whl | ||
|
||
publish-sdist: | ||
name: publish-sdist | ||
needs: | ||
- build-sdist | ||
- build-wheels | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: cibw-sdist | ||
path: dist | ||
|
||
- name: Check collected artifacts | ||
run: | | ||
python tools/check_dist.py --dist-dir dist/ | ||
- name: Upload sdist to release | ||
uses: AButler/[email protected] | ||
if: github.event_name == 'release' | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
files: 'dist/*.tar.gz' | ||
|
||
- name: Publish sdist to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
if: github.event_name == 'workflow_dispatch' | ||
with: | ||
password: ${{ secrets.TEST_PYPI_TOKEN }} | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
- name: Publish sdist to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
if: github.event_name == 'release' | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
|
||
publish-wheels: | ||
name: publish | ||
name: publish-wheels | ||
needs: | ||
- build-sdist | ||
- build-wheels | ||
- publish-sdist | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Download packages | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: cibw-* | ||
pattern: cibw-wheel-* | ||
path: dist | ||
merge-multiple: true | ||
|
||
- name: Check collected artifacts | ||
# TODO(vytas): Run a script to perform version sanity checks instead. | ||
run: ls -l dist/ | ||
run: | | ||
python tools/check_dist.py --dist-dir dist/ | ||
- name: Publish artifacts to TestPyPI | ||
- name: Publish wheels to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
if: github.event_name == 'workflow_dispatch' | ||
with: | ||
password: ${{ secrets.TEST_PYPI_TOKEN }} | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
# TODO(vytas): Enable this nuclear option once happy with other tests. | ||
# - name: Publish artifacts to PyPI | ||
# uses: pypa/gh-action-pypi-publish@release/v1 | ||
# if: github.event_name == 'release' | ||
# with: | ||
# password: ${{ secrets.PYPI_TOKEN }} | ||
- name: Publish wheels to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
if: github.event_name == 'release' | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
import pathlib | ||
import sys | ||
|
||
HERE = pathlib.Path(__file__).resolve().parent | ||
DIST = HERE.parent / 'dist' | ||
|
||
|
||
def check_dist(dist): | ||
sdist = None | ||
versions = set() | ||
wheels = [] | ||
|
||
for path in dist.iterdir(): | ||
if not path.is_file(): | ||
continue | ||
|
||
if path.name.endswith('.tar.gz'): | ||
assert sdist is None, f'sdist already exists: {sdist}' | ||
sdist = path.name | ||
|
||
elif path.name.endswith('.whl'): | ||
wheels.append(path.name) | ||
|
||
else: | ||
sys.stderr.write(f'Unexpected file found in dist: {path.name}\n') | ||
sys.exit(1) | ||
|
||
package, _, _ = path.stem.partition('.tar') | ||
falcon, version, *_ = package.split('-') | ||
assert falcon == 'falcon', 'Unexpected package name: {path.name}' | ||
versions.add(version) | ||
|
||
if not versions: | ||
sys.stderr.write('No artifacts collected!\n') | ||
sys.exit(1) | ||
if len(versions) > 1: | ||
sys.stderr.write(f'Multiple versions found: {tuple(versions)}!\n') | ||
sys.exit(1) | ||
version = versions.pop() | ||
|
||
wheel_list = ' None\n' | ||
if wheels: | ||
wheel_list = ''.join(f' {wheel}\n' for wheel in sorted(wheels)) | ||
|
||
print(f'[{dist}]\n') | ||
print(f'sdist found:\n {sdist}\n') | ||
print(f'wheels found:\n{wheel_list}') | ||
print(f'version identified:\n {version}\n') | ||
|
||
|
||
def main(): | ||
description = 'Check artifacts (sdist, wheels) inside dist dir.' | ||
|
||
parser = argparse.ArgumentParser(description=description) | ||
parser.add_argument( | ||
'-d', | ||
'--dist-dir', | ||
default=str(DIST), | ||
help='dist directory to check (default: %(default)s)', | ||
) | ||
|
||
args = parser.parse_args() | ||
check_dist(pathlib.Path(args.dist_dir)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |