1
0
Fork 0
mirror of https://github.com/ultrajson/ultrajson.git synced 2024-06-10 18:26:04 +02:00
ultrajson/.github/workflows/deploy.yml

182 lines
5.0 KiB
YAML
Raw Normal View History

---
name: Deploy
on:
push:
branches:
2021-09-05 19:45:29 +02:00
- main
pull_request:
paths:
- ".github/workflows/deploy.yml"
release:
types:
- published
2021-11-22 12:51:22 +01:00
workflow_dispatch:
2022-06-18 10:49:05 +02:00
env:
FORCE_COLOR: 1
jobs:
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
- run: git fetch --prune --unshallow
2021-12-14 15:39:42 +01:00
- name: Set up Python
2022-08-07 10:54:21 +02:00
uses: actions/setup-python@v4
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
- name: Build wheels
2023-10-01 02:18:46 +02:00
uses: pypa/cibuildwheel@v2.16.1
2023-01-27 15:32:06 +01:00
with:
output-dir: dist
# 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
# Run the test suite after each build.
CIBW_TEST_REQUIRES: "pytest"
CIBW_TEST_COMMAND: pytest {package}/tests
- name: Upload as build artifacts
2022-08-07 10:54:21 +02:00
uses: actions/upload-artifact@v3
with:
name: wheels
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
- cp38
- cp39
- cp310
2022-08-07 11:07:53 +02:00
- cp311
2023-05-28 20:30:35 +02:00
- cp312
steps:
2023-10-01 02:18:46 +02:00
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
2021-12-14 15:39:42 +01:00
- name: Set up Python
2022-08-07 10:54:21 +02:00
uses: actions/setup-python@v4
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"
# 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
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
2023-10-01 02:18:46 +02:00
uses: docker/setup-buildx-action@v3
2023-01-27 15:32:06 +01:00
# https://github.com/pypa/cibuildwheel
- name: Build wheels
2023-10-01 02:18:46 +02:00
uses: pypa/cibuildwheel@v2.16.1
2023-01-27 15:32:06 +01:00
with:
output-dir: dist
# 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"
# 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
# Run the test suite after each build.
CIBW_TEST_REQUIRES: "pytest"
CIBW_TEST_COMMAND: pytest {package}/tests
- name: Upload as build artifacts
2022-08-07 10:54:21 +02:00
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl
build-sdist-and-upload:
runs-on: ubuntu-latest
needs: ['build-native-wheels', 'build-QEMU-emulated-wheels']
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
2023-10-01 02:18:46 +02:00
- uses: actions/checkout@v4
- run: |
git fetch --prune --unshallow
2021-03-05 14:05:11 +01:00
- name: Set up Python
2022-08-07 10:54:21 +02:00
uses: actions/setup-python@v4
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"
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U build twine
- name: Download wheels from build artifacts
uses: actions/download-artifact@v3
with:
name: wheels
2023-06-07 18:58:06 +02:00
path: dist-wheels/
- name: Build package
run: |
git tag
python setup.py --version
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/*
2023-06-07 18:58:06 +02:00
- name: Publish wheels to PyPI
if: github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@release/v1
with:
2023-06-07 18:58:06 +02:00
packages-dir: dist-wheels/
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
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/