-
Notifications
You must be signed in to change notification settings - Fork 137
296 lines (251 loc) · 8.35 KB
/
build.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
---
name: build
on:
push:
tags:
- v*
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
env:
STABLE_PYTHON_VERSION: '3.13'
HATCH_VERBOSE: '1'
FORCE_COLOR: '1'
CIBW_BUILD_FRONTEND: build
jobs:
complete:
name: Build completion check
if: always()
permissions:
contents: none
runs-on: ubuntu-latest
needs:
- build-sdist
- build-x86_64
- build-arm64
steps:
- name: Failed
run: exit 1
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
build-sdist:
name: Build source distribution
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Fetch all tags
fetch-depth: 0
- name: Set up Python
uses: astral-sh/setup-uv@d8db0a86d3d88f3017a4e6b8a1e2b234e7a0a1b5 # v4.0.0
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install Python
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
- name: Install hatch
run: uv tool install hatch
- name: Create source distribution
run: |
hatch build --target sdist
- name: Upload sdist
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: wheels-sdist
path: ./dist/*.tar.*
if-no-files-found: error
compression-level: 0
build-x86_64:
name: Build wheels on ${{ matrix.os }} (x86, 64-bit)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
archs: x86_64
- os: macos-12
archs: x86_64
- os: windows-2019
archs: AMD64
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Fetch all tags
fetch-depth: 0
- name: Cache pip packages
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: ~/.cache/pip
key: ${{ github.workflow }}-pip-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ github.workflow }}-pip-${{ runner.os }}
${{ github.workflow }}-pip
${{ github.workflow }}
- name: Filter targets
id: cibw-filter
shell: bash
# Building all wheels on PRs is too slow, so we filter them to target
# the latest stable version of Python.
run: |
if [[ "${{ github.event_name}}" == "pull_request" ]] ; then
echo "build=cp${STABLE_PYTHON_VERSION/./}-*" >> "$GITHUB_OUTPUT"
else
echo "build=*" >> "$GITHUB_OUTPUT"
fi
- name: Set macOS deployment target
if: startsWith(matrix.os, 'macos-')
run: |
echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> "$GITHUB_ENV"
- name: Create wheels
uses: pypa/cibuildwheel@ee63bf16da6cddfb925f542f2c7b59ad50e93969 # v2.22.0
env:
CIBW_ARCHS: ${{ matrix.archs }}
CIBW_BUILD: ${{ steps.cibw-filter.outputs.build }}
- name: Upload wheels
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.archs }}
path: ./wheelhouse/*.whl
if-no-files-found: error
compression-level: 0
build-arm64:
name: Build wheels on ${{ matrix.os }} (arm64)
# As this requires emulation, it's not worth running on PRs or main
if: >-
github.event_name == 'push' &&
startsWith(github.event.ref, 'refs/tags/v')
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
archs: aarch64
build: manylinux
- os: ubuntu-20.04
archs: aarch64
build: musllinux
- os: macos-14
archs: arm64
build: ''
# TODO: Re-enable once the issues with Windows ARM64 are resolved.exclude:
# See: pypa/cibuildwheel#1942
# - os: windows-2019
# archs: ARM64
# build: ""
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Fetch all tags
fetch-depth: 0
- name: Cache pip packages
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: ~/.cache/pip
key: ${{ github.workflow }}-pip-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ github.workflow }}-pip-${{ runner.os }}
${{ github.workflow }}-pip
${{ github.workflow }}
- name: Set up QEMU
if: startsWith(matrix.os, 'ubuntu-')
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
with:
platforms: arm64
- name: Create wheels
uses: pypa/cibuildwheel@ee63bf16da6cddfb925f542f2c7b59ad50e93969 # v2.22.0
env:
CIBW_ARCHS: ${{ matrix.archs }}
CIBW_BUILD: ${{ matrix.build == '' && '*' || format('*{0}*', matrix.build) }}
- name: Upload wheels
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.archs }}-${{ matrix.build }}
path: ./wheelhouse/*.whl
if-no-files-found: error
compression-level: 0
publish:
name: Publish wheels and sdist
if: >-
github.event_name == 'push' &&
startsWith(github.event.ref, 'refs/tags/v')
runs-on: ubuntu-20.04
environment:
name: pypi
url: https://pypi.org/p/pact-python
needs:
- build-sdist
- build-x86_64
- build-arm64
permissions:
# Required for trusted publishing
id-token: write
# Required for release creation
contents: write
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Fetch all tags
fetch-depth: 0
- name: Download wheels and sdist
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
path: wheels
merge-multiple: true
- name: Set up uv
uses: astral-sh/setup-uv@d8db0a86d3d88f3017a4e6b8a1e2b234e7a0a1b5 # v4.0.0
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Install Python
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
- name: Install commitizen
run: uv tool install commitizen
- name: Update changelog
id: changelog
run: |
pip install --upgrade commitizen
cz changelog \
--incremental \
--template .github/CHANGELOG.md.j2 \
--dry-run \
| tail -n+2 \
> ${{ runner.temp }}/changelog
echo -e "\n\n## Pull Requests\n\n" >> ${{ runner.temp }}/changelog
cz changelog \
--incremental \
--template .github/CHANGELOG.md.j2
- name: Generate release
id: release
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
with:
files: wheels/*
body_path: ${{ runner.temp }}/changelog
draft: false
prerelease: false
generate_release_notes: true
- name: Push build artifacts to PyPI
uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2
with:
skip-existing: true
packages-dir: wheels
- name: Create PR for changelog update
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7
with:
token: ${{ secrets.GH_TOKEN }}
commit-message: 'chore: update changelog ${{ github.ref_name }}'
title: 'chore: update changelog'
body: |
This PR updates the changelog for ${{ github.ref_name }}.
branch: chore/update-changelog
base: main