forked from gluesql/gluesql
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (129 loc) · 3.98 KB
/
Copy pathpublish-python.yml
File metadata and controls
150 lines (129 loc) · 3.98 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Publish Python
on:
workflow_dispatch:
inputs:
# Latest commit to include with the release. If omitted, use the latest commit on the main branch.
sha:
description: Commit SHA
type: string
dry-run:
description: Dry run
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.11"
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUSTUP_MAX_RETRIES: 10
jobs:
create-sdist:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: [gluesql]
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.sha }}
# Avoid potential out-of-memory errors
- name: Set swap space for Linux
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Create source distribution
uses: PyO3/maturin-action@v1
with:
command: sdist
args: >
--manifest-path pkg/python/Cargo.toml
--out dist
- name: Test sdist
run: |
pip install --force-reinstall --verbose dist/*.tar.gz
python -c 'import gluesql'
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist-${{ matrix.package }}
path: dist/*.tar.gz
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
package: [gluesql]
os: [ubuntu-latest, macos-13]
architecture: [x86-64, aarch64]
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.sha }}
# Avoid potential out-of-memory errors
- name: Set swap space for Linux
if: matrix.os == 'ubuntu-latest'
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Configure PyO3 cross
if: matrix.architecture == 'aarch64'
run: echo "PYO3_CROSS_PYTHON_VERSION=${{ env.PYTHON_VERSION }}" >> $GITHUB_ENV
- name: Set Rust target for aarch64
if: matrix.architecture == 'aarch64'
id: target
run: |
TARGET=${{ matrix.os == 'macos-13' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu'}}
echo "target=$TARGET" >> $GITHUB_OUTPUT
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
target: ${{ steps.target.outputs.target }}
args: >
--release
--manifest-path pkg/python/Cargo.toml
--out dist
--interpreter ${{ env.PYTHON_VERSION }}
manylinux: ${{ matrix.architecture == 'aarch64' && '2_24' || 'auto' }}
- name: Test wheel
# Only test on x86-64 for now as this matches the runner architecture
if: matrix.architecture == 'x86-64'
run: |
pip install --force-reinstall --verbose dist/*.whl
python -c 'import gluesql'
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.package }}-${{ matrix.os }}-${{ matrix.architecture }}
path: dist/*.whl
publish-to-pypi:
needs: [create-sdist, build-wheels]
environment:
name: release-python
url: https://pypi.org/project/gluesql
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download sdists and wheels
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish to PyPI
if: github.event_name != 'push' && inputs.dry-run == false
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true