-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (131 loc) · 3.98 KB
/
Copy pathpython-package.yml
File metadata and controls
151 lines (131 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
151
name: Python Package
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:
permissions:
contents: read
id-token: write # For PyPI trusted publishing
jobs:
check:
runs-on: ubuntu-latest
if: |
contains(github.event.head_commit.message, '[ci skip]') == false &&
contains(github.event.head_commit.message, '[skip ci]') == false
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
- name: Run lint check
uses: astral-sh/ruff-action@v3
- name: Install development dependencies
run: uv sync
- name: Run type check
run: uv run mypy
validate-tag:
name: Validate Tag
runs-on: ubuntu-latest
needs: check
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
outputs:
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Validate version
id: check
run: |
python3 -m pip install --disable-pip-version-check packaging
python3 .github/scripts/validate_version.py
build-sdist:
name: Build sdist
runs-on: ubuntu-latest
needs: [validate-tag, check]
if: |
always() && needs.check.result == 'success' &&
(needs.validate-tag.outputs.version != '' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request')
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
- name: Build sdist
run: |
uv build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
if-no-files-found: error
build-wheels:
name: Build wheel
runs-on: ubuntu-latest
needs: [validate-tag, check]
if: |
always() && needs.check.result == 'success' &&
(needs.validate-tag.outputs.version != '' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request')
strategy:
fail-fast: true
matrix:
image:
- manylinux_2_34_x86_64
- manylinux_2_34_aarch64
- musllinux_1_2_x86_64
- musllinux_1_2_aarch64
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Build wheels
run: |
# Select the appropriate build script based on image type
if [[ "${{ matrix.image }}" == musllinux_* ]]; then
BUILD_SCRIPT=build-wheels-musllinux.sh
else
BUILD_SCRIPT=build-wheels-manylinux.sh
fi
# Detect platform
if [[ "${{ matrix.image }}" == *_aarch64 ]]; then
PLATFORM=linux/arm64
else
PLATFORM=linux/amd64
fi
docker run --rm \
-v $(pwd):/ws \
-w /ws \
--platform $PLATFORM \
quay.io/pypa/${{ matrix.image }} \
sh .github/scripts/$BUILD_SCRIPT
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.image }}
path: wheelhouse/*.whl
if-no-files-found: error
publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [validate-tag, build-sdist, build-wheels]
if: |
always() && needs.validate-tag.outputs.version != '' &&
needs.build-sdist.result == 'success' && needs.build-wheels.result == 'success'
environment:
name: pypi
url: https://pypi.org/project/python-nsjail/
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: wheelhouse/
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: wheelhouse/
skip-existing: true
verbose: true