-
Notifications
You must be signed in to change notification settings - Fork 147
212 lines (178 loc) · 5.65 KB
/
build-cli.yml
File metadata and controls
212 lines (178 loc) · 5.65 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
---
name: build cli
on:
push:
tags:
- pact-python-cli/*
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
STABLE_PYTHON_VERSION: '310'
HATCH_VERBOSE: '1'
FORCE_COLOR: '1'
CIBW_BUILD_FRONTEND: build
jobs:
complete:
name: Build CLI completion check
if: always()
permissions:
contents: none
runs-on: ubuntu-latest
needs:
- build-sdist
- build-wheels
- publish
steps:
- name: Failed
run: exit 1
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
build-sdist:
name: Build CLI source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
enable-cache: true
- name: Install Python
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
- name: Install hatch
run: uv tool install hatch
- name: Create source distribution
working-directory: pact-python-cli
run: hatch build --target sdist
- name: Upload sdist
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-sdist
path: pact-python-cli/dist/*.tar*
if-no-files-found: error
compression-level: 0
build-wheels:
name: Build CLI wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
- os: macos-latest
- os: ubuntu-24.04-arm
- os: ubuntu-latest
# - os: windows-11-arm # Not supported upstream
- os: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Create wheels
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
with:
package-dir: pact-python-cli
env:
CIBW_BUILD: cp${{ env.STABLE_PYTHON_VERSION }}-*
- name: Upload wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
if-no-files-found: error
compression-level: 0
publish:
name: Publish CLI wheels and sdist
if: >-
github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/pact-python-cli/')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pact-python-cli
needs:
- build-sdist
- build-wheels
permissions:
# Required for creating the release
contents: write
# Required for trusted publishing
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Install git cliff and typos
uses: taiki-e/install-action@0abfcd587b70a713fdaa7fb502c885e2112acb15 # v2.75.7
with:
tool: git-cliff,typos
- name: Update changelog
run: git cliff --verbose
working-directory: pact-python-cli
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Generate release changelog
id: release-changelog
working-directory: pact-python-cli
run: |
if ! git cliff \
--current \
--strip header \
--output ${{ runner.temp }}/release-changelog.md; then
{
echo "> [!WARNING]"
echo ">"
echo "> No changelog generated. To be filled in."
} > ${{ runner.temp }}/release-changelog.md
fi
{
echo ""
echo "<details>"
echo "<summary>"
echo ""
echo "## Pull Requests"
echo ""
echo "</summary>"
echo ""
} >> ${{ runner.temp }}/release-changelog.md
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Download wheels and sdist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: wheelhouse
merge-multiple: true
- name: Generate release
id: release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
files: wheelhouse/*
body_path: ${{ runner.temp }}/release-changelog.md
draft: false
prerelease: false
generate_release_notes: true
- name: Push build artifacts to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
with:
skip-existing: true
packages-dir: wheelhouse
- name: Create PR for changelog update
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ secrets.GH_TOKEN }}
commit-message: 'docs: update changelog for ${{ github.ref_name }}'
title: 'docs: update cli changelog'
body: |
This PR updates the changelog for ${{ github.ref_name }}.
branch: docs/update-changelog
base: main