-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (89 loc) · 3.18 KB
/
Copy pathpublish-PyPI.yml
File metadata and controls
104 lines (89 loc) · 3.18 KB
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
98
99
100
101
102
103
104
name: Publish to PyPI
run-name: Publish Python Package to PyPI for release ${{ github.event.release.tag_name || inputs.tag_name || github.ref_name }}
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_name:
description: 'Git tag to checkout and publish'
required: false
type: string
jobs:
build:
name: Build distribution 📦
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4.1.0
with:
ref: ${{ inputs.tag_name || github.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install Rust targets for macOS
if: matrix.os == 'macos-latest'
run: |
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- name: Build wheels
uses: pypa/cibuildwheel@v4.1.0
env:
CIBW_SKIP: "pp* *-musllinux_*" # Skip PyPy and musl builds
CIBW_ARCHS_MACOS: "x86_64 arm64" # Build for Intel and Apple Silicon
CIBW_ARCHS_WINDOWS: "AMD64"
CIBW_ARCHS_LINUX: "x86_64"
# This is needed as for linux the wheel build process happens inside a container instead of the Github runner
# See https://cibuildwheel.pypa.io/en/stable/platforms/#linux-containers
CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && source $HOME/.cargo/env"
CIBW_ENVIRONMENT_LINUX: 'PATH="$HOME/.cargo/bin:$PATH"'
# Required to build wheels with Rust extensions on macOS
# See https://cibuildwheel.pypa.io/en/stable/platforms/#macos-version-compatibility
MACOSX_DEPLOYMENT_TARGET: "11.0"
- name: Build source distribution (Linux only)
if: matrix.os == 'ubuntu-latest'
run: |
python3 -m pip install build
python3 -m build --sdist
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.os }}
path: |
wheelhouse/*.whl
dist/*.tar.gz
if-no-files-found: error
publish-to-pypi:
name: Publish to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/source-modelling
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: python-package-distributions-*
merge-multiple: true
path: artifacts/
- name: Collect all distributions into dist/
run: |
mkdir -p dist/
find artifacts/ -name '*.whl' -exec cp {} dist/ \;
find artifacts/ -name '*.tar.gz' -exec cp {} dist/ \;
ls -la dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist