-
-
Notifications
You must be signed in to change notification settings - Fork 433
196 lines (185 loc) · 7.1 KB
/
Copy pathpython-distributions.yml
File metadata and controls
196 lines (185 loc) · 7.1 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
---
name: Build Python distributions
"on":
push:
branches: [main, master]
tags:
- 'dulwich-*'
pull_request:
schedule:
- cron: "0 6 * * *" # Daily 6AM UTC build
permissions:
contents: read
jobs:
define-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.merged-identifiers.outputs.merged-identifiers }}
steps:
- uses: actions/checkout@v6.0.3
- uses: actions/setup-python@v6
with:
python-version: 3.x
cache: pip
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Install cibuildwheel
run: pip install cibuildwheel
- name: Find build identifiers using cibuildwheel --print-build-identifiers
id: all-build-identifiers
run: |
echo "linux=$(cibuildwheel --platform linux --print-build-identifiers | tr '\n' ' ')" >> $GITHUB_OUTPUT
echo "macos=$(cibuildwheel --platform macos --print-build-identifiers | tr '\n' ' ')" >> $GITHUB_OUTPUT
echo "windows=$(cibuildwheel --platform windows --print-build-identifiers | tr '\n' ' ')" >> $GITHUB_OUTPUT
- name: Select build identifiers
id: select-build-identifiers
run: |
if [[ "$GITHUB_REF" = "refs/heads/main" ]] || [[ "$GITHUB_REF" = "refs/heads/master" ]] || [[ "$GITHUB_REF" = "refs/tags/"* ]]; then
echo 'linux=${{ steps.all-build-identifiers.outputs.linux }}' >> $GITHUB_OUTPUT
echo 'windows=${{ steps.all-build-identifiers.outputs.windows }}' >> $GITHUB_OUTPUT
echo 'macos=${{ steps.all-build-identifiers.outputs.macos }}' >> $GITHUB_OUTPUT
else
echo "linux=$(echo -n '${{ steps.all-build-identifiers.outputs.linux }}' | awk '{print $NF}')" >> $GITHUB_OUTPUT
# Select the last identifier overall plus the last x86_64 one, to ensure we test both architectures
macos_all='${{ steps.all-build-identifiers.outputs.macos }}'
macos_last=$(echo -n "$macos_all" | awk '{print $NF}')
macos_x86=$(echo -n "$macos_all" | tr ' ' '\n' | grep x86_64 | tail -1)
echo "macos=$(echo $macos_last $macos_x86 | tr ' ' '\n' | sort -u | tr '\n' ' ')" >> $GITHUB_OUTPUT
echo "windows=$(echo -n '${{ steps.all-build-identifiers.outputs.windows }}' | awk '{print $NF}')" >> $GITHUB_OUTPUT
fi
- name: Output build identifiers
id: json-identifiers
run: |
echo "linux=$(echo -n '${{ steps.select-build-identifiers.outputs.linux }}' | jq -R -s -c 'split(" ") | map(select(length > 0)) | [.[] | {os: "ubuntu-latest", "build-identifier": .}]')" >> $GITHUB_OUTPUT
echo "macos=$(echo -n '${{ steps.select-build-identifiers.outputs.macos }}' | jq -R -s -c 'split(" ") | map(select(length > 0)) | [.[] | {os: "macos-latest", "build-identifier": .}]')" >> $GITHUB_OUTPUT
echo "windows=$(echo -n '${{ steps.select-build-identifiers.outputs.windows }}' | jq -R -s -c 'split(" ") | map(select(length > 0)) | [.[] | {os: "windows-latest", "build-identifier": .}]')" >> $GITHUB_OUTPUT
- name: Merge build identifiers
id: merged-identifiers
run: |
echo merged-identifiers=$(echo -n '${{ steps.json-identifiers.outputs.linux }} ${{ steps.json-identifiers.outputs.macos }} ${{ steps.json-identifiers.outputs.windows }}' | jq -c -s 'add') >> $GITHUB_OUTPUT
build-wheels:
runs-on: ${{ matrix.os }}
needs: define-matrix
strategy:
matrix:
include: ${{ fromJSON(needs.define-matrix.outputs.matrix ) }}
fail-fast: true
steps:
- uses: actions/checkout@v6.0.3
- uses: actions/setup-python@v6
with:
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel cibuildwheel setuptools-rust
- name: Set up QEMU
uses: docker/setup-qemu-action@v4.1.0
if: "matrix.os == 'ubuntu-latest'"
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "${{ matrix.build-identifier }}*"
- name: Upload wheels
uses: actions/upload-artifact@v7.0.1
with:
name: artifact-${{ matrix.build-identifier }}
path: ./wheelhouse/*.whl
build-android-wheels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.3
- uses: actions/setup-python@v6
with:
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel cibuildwheel setuptools-rust
- name: Build Android wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_PLATFORM: android
CIBW_ARCHS_ANDROID: arm64_v8a x86_64
- name: Upload Android wheels
uses: actions/upload-artifact@v7.0.1
with:
name: artifact-android
path: ./wheelhouse/*.whl
build-pure-wheels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.3
- uses: actions/setup-python@v6
with:
cache: pip
- run: pip install build
- run: PURE=true python -m build --wheel
- name: Upload pure wheels
uses: actions/upload-artifact@v7.0.1
with:
name: artifact-pure
path: ./dist/*.whl
build-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.3
- uses: actions/setup-python@v6
with:
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build sdist
run: python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v7.0.1
with:
name: artifact-source
path: ./dist/*.tar.gz
test-sdist:
needs:
- build-sdist
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v6
with:
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Upgrade packaging to avoid a bug in twine.
# See https://github.com/pypa/twine/issues/1216
pip install "twine>=6.1.0" "packaging>=24.2"
- name: Download sdist
uses: actions/download-artifact@v8.0.1
with:
name: artifact-source
path: dist
- name: Test sdist
run: twine check dist/*
- name: Test installation from sdist
run: pip install dist/*.tar.gz
publish:
runs-on: ubuntu-latest
needs:
- build-wheels
- build-android-wheels
- build-sdist
- build-pure-wheels
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/dulwich-')
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/p/dulwich
steps:
- name: Download distributions
uses: actions/download-artifact@v8.0.1
with:
merge-multiple: true
pattern: artifact-*
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@v1.14.0