jsonobject tests #96
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
name: Build wheels and publish to PyPI | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "v*" | |
workflow_dispatch: | |
jobs: | |
configure: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Read Python versions from pyproject.toml | |
id: read-versions | |
# produces output like: python_versions=39,310,311,312,313 | |
run: >- | |
echo "python_versions=$( | |
grep -oP '(?<=Language :: Python :: )\d.\d+' pyproject.toml | |
| sed 's/\.//' | |
| tr '\n' ',' | |
| sed 's/,$//' | |
)" >> $GITHUB_OUTPUT | |
outputs: | |
python_versions: ${{ steps.read-versions.outputs.python_versions }} | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check version | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
run: python version.py check "${{ github.ref }}" | |
- name: Add untagged version suffix | |
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }} | |
run: python version.py update ${{ github.sha }} | |
- name: Build sdist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: dist | |
choose_linux_wheel_types: | |
name: Decide which wheel types to build | |
runs-on: ubuntu-latest | |
steps: | |
- id: manylinux_x86_64 | |
run: echo "wheel_types=manylinux_x86_64" >> $GITHUB_OUTPUT | |
- id: musllinux_x86_64 | |
run: echo "wheel_types=musllinux_x86_64" >> $GITHUB_OUTPUT | |
outputs: | |
wheel_types: ${{ toJSON(steps.*.outputs.wheel_types) }} | |
build_linux_wheels: | |
needs: [configure, choose_linux_wheel_types] | |
name: ${{ matrix.wheel_type }} wheels | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
wheel_type: ${{ fromJSON(needs.choose_linux_wheel_types.outputs.wheel_types) }} | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
path: dist | |
- name: Extract sdist | |
run: | | |
tar zxvf dist/*.tar.gz --strip-components=1 | |
- uses: docker/setup-qemu-action@v3 | |
if: runner.os == 'Linux' | |
name: Set up QEMU | |
- name: Disable ptrace security restrictions | |
run: | | |
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: cp{${{ needs.configure.outputs.python_versions }}}-${{ matrix.wheel_type }} | |
CIBW_ARCHS_LINUX: auto | |
CIBW_TEST_COMMAND: ls -l | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.wheel_type }}-wheels | |
path: ./wheelhouse/*.whl | |
pypi-publish: | |
name: Upload release to PyPI | |
needs: [build_sdist, build_linux_wheels] | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
environment: | |
name: pypi | |
url: https://pypi.org/p/pytest-unmagic | |
permissions: | |
id-token: write | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- run: | | |
mv dist/sdist/*.tar.gz dist/ | |
mv dist/*-wheels/*.whl dist/ | |
rmdir dist/{sdist,*-wheels} | |
ls -R dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
pypi-test-publish: | |
name: Upload release to test PyPI | |
needs: [build_sdist, build_linux_wheels] | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/pytest-unmagic | |
permissions: | |
id-token: write | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- run: | | |
mv dist/sdist/*.tar.gz dist/ | |
mv dist/*-wheels/*.whl dist/ | |
rmdir dist/{sdist,*-wheels} | |
ls -R dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ |