-
Notifications
You must be signed in to change notification settings - Fork 92
97 lines (90 loc) · 2.62 KB
/
build-and-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Build & Publish
on:
pull_request:
paths:
- ".github/workflows/build-and-publish.yml"
- "setup.*"
workflow_dispatch:
inputs:
branch:
description: "The branch, tag or SHA to release from"
required: true
default: "master"
jobs:
os-built-distributions:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
submodules: true
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build dependencies
run: python -m pip install --upgrade cibuildwheel
- name: Build wheels
run: python -m cibuildwheel
env:
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_ARCHS_LINUX: "auto aarch64"
- uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.os }}
path: ./wheelhouse/*.whl
source-distribution:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
submodules: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build source distribution
run: |
# FIXME: setuptools was removed starting with Python 3.12
pip install --upgrade --force setuptools
python setup.py sdist
- name: Store the source distribution
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-source
path: dist
retention-days: 4
publish:
needs:
- os-built-distributions
- source-distribution
runs-on: ubuntu-latest
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: python-package-distributions-*
merge-multiple: true
path: dist/
- name: What will we publish?
run: ls -l dist
- name: Publish
if: github.event.inputs.branch != ''
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true