2021-11-28 22:18:08 +01:00
|
|
|
---
|
2020-03-01 22:32:01 +01:00
|
|
|
name: Deploy
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-09-05 19:45:29 +02:00
|
|
|
- main
|
2021-11-28 22:18:08 +01:00
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- ".github/workflows/deploy.yml"
|
2020-03-01 22:32:01 +01:00
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
2021-11-22 12:51:22 +01:00
|
|
|
workflow_dispatch:
|
2020-03-01 22:32:01 +01:00
|
|
|
|
2022-06-18 10:49:05 +02:00
|
|
|
env:
|
|
|
|
FORCE_COLOR: 1
|
|
|
|
|
2020-03-01 22:32:01 +01:00
|
|
|
jobs:
|
2021-11-28 22:18:08 +01:00
|
|
|
build-native-wheels:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
os: [windows-latest, macOS-latest, ubuntu-latest]
|
|
|
|
|
|
|
|
steps:
|
2023-10-01 02:18:46 +02:00
|
|
|
- uses: actions/checkout@v4
|
2021-11-28 22:18:08 +01:00
|
|
|
- run: git fetch --prune --unshallow
|
|
|
|
|
2021-12-14 15:39:42 +01:00
|
|
|
- name: Set up Python
|
2024-01-01 01:47:15 +01:00
|
|
|
uses: actions/setup-python@v5
|
2021-12-14 15:39:42 +01:00
|
|
|
with:
|
2022-08-07 10:54:21 +02:00
|
|
|
python-version: "3.x"
|
2021-12-14 15:39:42 +01:00
|
|
|
cache: pip
|
|
|
|
cache-dependency-path: ".github/workflows/deploy.yml"
|
|
|
|
|
2023-01-27 15:32:06 +01:00
|
|
|
# https://github.com/pypa/cibuildwheel
|
2021-11-28 22:18:08 +01:00
|
|
|
- name: Build wheels
|
2023-11-01 01:09:49 +01:00
|
|
|
uses: pypa/cibuildwheel@v2.16.2
|
2023-01-27 15:32:06 +01:00
|
|
|
with:
|
|
|
|
output-dir: dist
|
2021-11-28 22:18:08 +01:00
|
|
|
# Options are supplied via environment variables:
|
|
|
|
env:
|
|
|
|
# Build separate wheels for macOS's different architectures.
|
|
|
|
CIBW_ARCHS_MACOS: "x86_64 arm64"
|
|
|
|
# Build only on Linux architectures that don't need qemu emulation.
|
|
|
|
CIBW_ARCHS_LINUX: "x86_64 i686"
|
2023-05-28 20:30:35 +02:00
|
|
|
# Include latest Python beta.
|
|
|
|
CIBW_PRERELEASE_PYTHONS: True
|
2021-11-28 22:18:08 +01:00
|
|
|
# Run the test suite after each build.
|
|
|
|
CIBW_TEST_REQUIRES: "pytest"
|
|
|
|
CIBW_TEST_COMMAND: pytest {package}/tests
|
|
|
|
|
|
|
|
- name: Upload as build artifacts
|
2024-01-01 01:47:15 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2021-11-28 22:18:08 +01:00
|
|
|
with:
|
2024-01-01 01:47:15 +01:00
|
|
|
name: wheels-${{ matrix.os }}
|
2021-11-28 22:18:08 +01:00
|
|
|
path: dist/*.whl
|
|
|
|
|
|
|
|
build-QEMU-emulated-wheels:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
python-version:
|
2022-09-14 07:43:33 +02:00
|
|
|
- pp39
|
2023-08-01 18:51:30 +02:00
|
|
|
- pp310
|
2021-11-28 22:18:08 +01:00
|
|
|
- cp38
|
|
|
|
- cp39
|
|
|
|
- cp310
|
2022-08-07 11:07:53 +02:00
|
|
|
- cp311
|
2023-05-28 20:30:35 +02:00
|
|
|
- cp312
|
2021-11-28 22:18:08 +01:00
|
|
|
|
|
|
|
steps:
|
2023-10-01 02:18:46 +02:00
|
|
|
- uses: actions/checkout@v4
|
2021-11-28 22:18:08 +01:00
|
|
|
- run: git fetch --prune --unshallow
|
|
|
|
|
2021-12-14 15:39:42 +01:00
|
|
|
- name: Set up Python
|
2024-01-01 01:47:15 +01:00
|
|
|
uses: actions/setup-python@v5
|
2021-12-14 15:39:42 +01:00
|
|
|
with:
|
2022-08-07 11:07:53 +02:00
|
|
|
python-version: "3.x"
|
2021-12-14 15:39:42 +01:00
|
|
|
cache: pip
|
|
|
|
cache-dependency-path: ".github/workflows/deploy.yml"
|
|
|
|
|
2021-11-28 22:18:08 +01:00
|
|
|
# https://github.com/docker/setup-qemu-action
|
|
|
|
- name: Set up QEMU
|
2023-10-01 02:18:46 +02:00
|
|
|
uses: docker/setup-qemu-action@v3
|
2021-11-28 22:18:08 +01:00
|
|
|
|
2023-01-27 15:32:06 +01:00
|
|
|
# https://github.com/pypa/cibuildwheel
|
2021-11-28 22:18:08 +01:00
|
|
|
- name: Build wheels
|
2023-11-01 01:09:49 +01:00
|
|
|
uses: pypa/cibuildwheel@v2.16.2
|
2023-01-27 15:32:06 +01:00
|
|
|
with:
|
|
|
|
output-dir: dist
|
2021-11-28 22:18:08 +01:00
|
|
|
# Options are supplied via environment variables:
|
|
|
|
env:
|
|
|
|
# Build only the currently selected Linux architecture (so we can
|
|
|
|
# parallelise for speed).
|
2022-09-13 22:20:55 +02:00
|
|
|
CIBW_ARCHS_LINUX: "aarch64"
|
2021-11-28 22:18:08 +01:00
|
|
|
# Likewise, select only one Python version per job to speed this up.
|
|
|
|
CIBW_BUILD: "${{ matrix.python-version }}-*"
|
2023-05-28 20:30:35 +02:00
|
|
|
# Include latest Python beta.
|
|
|
|
CIBW_PRERELEASE_PYTHONS: True
|
2021-11-28 22:18:08 +01:00
|
|
|
# Run the test suite after each build.
|
|
|
|
CIBW_TEST_REQUIRES: "pytest"
|
|
|
|
CIBW_TEST_COMMAND: pytest {package}/tests
|
|
|
|
|
|
|
|
- name: Upload as build artifacts
|
2024-01-01 01:47:15 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2021-11-28 22:18:08 +01:00
|
|
|
with:
|
2024-01-01 01:47:15 +01:00
|
|
|
name: wheels-qemu-${{ matrix.python-version }}
|
2021-11-28 22:18:08 +01:00
|
|
|
path: dist/*.whl
|
|
|
|
|
2023-06-06 22:01:03 +02:00
|
|
|
build-sdist-and-upload:
|
2022-08-07 11:00:46 +02:00
|
|
|
runs-on: ubuntu-latest
|
2021-11-28 22:18:08 +01:00
|
|
|
needs: ['build-native-wheels', 'build-QEMU-emulated-wheels']
|
2023-08-02 09:24:15 +02:00
|
|
|
permissions:
|
|
|
|
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
|
|
id-token: write
|
2020-03-01 22:32:01 +01:00
|
|
|
|
|
|
|
steps:
|
2023-10-01 02:18:46 +02:00
|
|
|
- uses: actions/checkout@v4
|
2020-03-23 20:55:39 +01:00
|
|
|
- run: |
|
|
|
|
git fetch --prune --unshallow
|
2020-03-01 22:32:01 +01:00
|
|
|
|
2021-03-05 14:05:11 +01:00
|
|
|
- name: Set up Python
|
2024-01-01 01:47:15 +01:00
|
|
|
uses: actions/setup-python@v5
|
2020-03-01 22:32:01 +01:00
|
|
|
with:
|
2022-08-07 10:54:21 +02:00
|
|
|
python-version: "3.x"
|
2021-11-22 12:51:22 +01:00
|
|
|
cache: pip
|
|
|
|
cache-dependency-path: "setup.py"
|
2020-03-01 22:32:01 +01:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install -U pip
|
2023-06-02 18:41:19 +02:00
|
|
|
python -m pip install -U build twine
|
2020-03-01 22:32:01 +01:00
|
|
|
|
2023-06-06 22:01:03 +02:00
|
|
|
- name: Download wheels from build artifacts
|
2024-01-01 01:47:15 +01:00
|
|
|
uses: actions/download-artifact@v4
|
2023-06-06 22:01:03 +02:00
|
|
|
with:
|
2024-01-01 01:47:15 +01:00
|
|
|
pattern: wheels-*
|
|
|
|
merge-multiple: true
|
2023-06-07 18:58:06 +02:00
|
|
|
path: dist-wheels/
|
2023-06-06 22:01:03 +02:00
|
|
|
|
2020-03-01 22:32:01 +01:00
|
|
|
- name: Build package
|
|
|
|
run: |
|
2020-03-23 20:55:39 +01:00
|
|
|
git tag
|
2021-11-22 12:51:22 +01:00
|
|
|
python -m build --sdist
|
|
|
|
twine check --strict dist/*
|
2023-06-07 18:58:06 +02:00
|
|
|
twine check --strict dist-wheels/*
|
2020-03-01 22:32:01 +01:00
|
|
|
|
2023-06-07 18:58:06 +02:00
|
|
|
- name: Publish wheels to PyPI
|
2020-03-01 22:32:01 +01:00
|
|
|
if: github.event.action == 'published'
|
2022-07-25 20:21:11 +02:00
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
2020-03-01 22:32:01 +01:00
|
|
|
with:
|
2023-06-07 18:58:06 +02:00
|
|
|
packages-dir: dist-wheels/
|
2020-03-01 22:32:01 +01:00
|
|
|
|
2023-06-07 18:58:06 +02:00
|
|
|
- name: Publish sdist to PyPI
|
|
|
|
if: github.event.action == 'published'
|
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
|
|
|
|
|
|
- name: Publish wheels to TestPyPI
|
|
|
|
if: |
|
|
|
|
github.repository == 'ultrajson/ultrajson' &&
|
|
|
|
github.ref == 'refs/heads/main'
|
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
|
|
with:
|
|
|
|
repository-url: https://test.pypi.org/legacy/
|
|
|
|
packages-dir: dist-wheels/
|
|
|
|
|
|
|
|
- name: Publish sdist to TestPyPI
|
2021-11-28 22:18:08 +01:00
|
|
|
if: |
|
|
|
|
github.repository == 'ultrajson/ultrajson' &&
|
|
|
|
github.ref == 'refs/heads/main'
|
2022-07-25 20:21:11 +02:00
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
2020-03-01 22:32:01 +01:00
|
|
|
with:
|
2023-03-19 14:53:20 +01:00
|
|
|
repository-url: https://test.pypi.org/legacy/
|