Skip to content

Commit 35e44bf

Browse files
committed
chore(ci): add build cli pipeline
Signed-off-by: JP-Ellis <[email protected]>
1 parent dcc286b commit 35e44bf

File tree

2 files changed

+215
-6
lines changed

2 files changed

+215
-6
lines changed

.github/workflows/build-cli.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
---
2+
name: build cli
3+
4+
on:
5+
push:
6+
tags:
7+
- pact-python-cli/*
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
16+
cancel-in-progress: true
17+
18+
env:
19+
STABLE_PYTHON_VERSION: '3.13'
20+
HATCH_VERBOSE: '1'
21+
FORCE_COLOR: '1'
22+
CIBW_BUILD_FRONTEND: build
23+
24+
jobs:
25+
complete:
26+
name: Build CLI completion check
27+
if: always()
28+
29+
permissions:
30+
contents: none
31+
32+
runs-on: ubuntu-latest
33+
needs:
34+
- build-sdist
35+
- build-wheels
36+
37+
steps:
38+
- name: Failed
39+
run: exit 1
40+
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
41+
42+
build-sdist:
43+
name: Build CLI source distribution
44+
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
49+
with:
50+
# Fetch all tags
51+
fetch-depth: 0
52+
53+
- name: Set up uv
54+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
55+
with:
56+
enable-cache: true
57+
58+
- name: Install Python
59+
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
60+
61+
- name: Install hatch
62+
run: uv tool install hatch
63+
64+
- name: Create source distribution
65+
working-directory: pact-python-cli
66+
run: hatch build --target sdist
67+
68+
- name: Upload sdist
69+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
70+
with:
71+
name: wheels-sdist
72+
path: pact-python-cli/dist/*.tar*
73+
if-no-files-found: error
74+
compression-level: 0
75+
76+
build-wheels:
77+
name: Build CLI wheels on ${{ matrix.os }}
78+
79+
runs-on: ${{ matrix.os }}
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
include:
84+
- os: macos-13
85+
- os: macos-latest
86+
- os: ubuntu-24.04-arm
87+
- os: ubuntu-latest
88+
# - os: windows-11-arm # Not supported upstream
89+
- os: windows-latest
90+
91+
steps:
92+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
93+
with:
94+
# Fetch all tags
95+
fetch-depth: 0
96+
97+
- name: Filter targets
98+
id: cibw-filter
99+
shell: bash
100+
# On PRs, only build the latest stable version of Python to speed up the
101+
# workflow.
102+
run: |
103+
if [[ "${{ github.event_name}}" == "pull_request" ]] ; then
104+
echo "build=cp${STABLE_PYTHON_VERSION/./}-*" >> "$GITHUB_OUTPUT"
105+
else
106+
echo "build=*" >> "$GITHUB_OUTPUT"
107+
fi
108+
109+
- name: Set macOS deployment target
110+
if: startsWith(matrix.os, 'macos-')
111+
run: |
112+
echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> "$GITHUB_ENV"
113+
114+
- name: Create wheels
115+
uses: pypa/cibuildwheel@95d2f3a92fbf80abe066b09418bbf128a8923df2 # v3.0.1
116+
with:
117+
package-dir: pact-python-cli
118+
env:
119+
CIBW_BUILD: ${{ steps.cibw-filter.outputs.build }}
120+
121+
- name: Upload wheels
122+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
123+
with:
124+
name: wheels-${{ matrix.os }}
125+
path: wheelhouse/*.whl
126+
if-no-files-found: error
127+
compression-level: 0
128+
129+
publish:
130+
name: Publish CLI wheels and sdist
131+
132+
if: >-
133+
github.event_name == 'push' &&
134+
startsWith(github.event.ref, 'refs/tags/pact-python-cli/')
135+
runs-on: ubuntu-latest
136+
environment:
137+
name: pypi
138+
url: https://pypi.org/p/pact-python-cli
139+
140+
needs:
141+
- build-sdist
142+
- build-wheels
143+
144+
permissions:
145+
# Required for trusted publishing
146+
id-token: write
147+
# Required for release creation
148+
contents: write
149+
150+
steps:
151+
- name: Checkout code
152+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
153+
with:
154+
# Fetch all tags
155+
fetch-depth: 0
156+
157+
- name: Install git cliff and typos
158+
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
159+
with:
160+
tool: git-cliff,typos
161+
162+
- name: Update changelog
163+
run: git cliff --verbose
164+
working-directory: pact-python-cli
165+
env:
166+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
167+
168+
- name: Generate release changelog
169+
id: release-changelog
170+
working-directory: pact-python-cli
171+
run: |
172+
git cliff \
173+
--current \
174+
--strip header \
175+
--output ${{ runner.temp }}/release-changelog.md
176+
177+
echo -e "\n\n## Pull Requests\n\n" >> ${{ runner.temp }}/release-changelog.md
178+
env:
179+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
180+
181+
- name: Download wheels and sdist
182+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
183+
with:
184+
path: wheelhouse
185+
merge-multiple: true
186+
187+
- name: Generate release
188+
id: release
189+
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
190+
with:
191+
files: wheelhouse/*
192+
body_path: ${{ runner.temp }}/release-changelog.md
193+
draft: false
194+
prerelease: false
195+
generate_release_notes: true
196+
197+
- name: Push build artifacts to PyPI
198+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
199+
with:
200+
skip-existing: true
201+
packages-dir: wheelhouse
202+
203+
- name: Create PR for changelog update
204+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
205+
with:
206+
token: ${{ secrets.GH_TOKEN }}
207+
commit-message: 'docs: update changelog for ${{ github.ref_name }}'
208+
title: 'docs: update cli changelog'
209+
body: |
210+
This PR updates the changelog for ${{ github.ref_name }}.
211+
branch: docs/update-changelog
212+
base: main

pact-python-cli/pyproject.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,10 @@ exclude = ''
194194
################################################################################
195195
[tool.cibuildwheel]
196196
before-build = "rm -rvf src/pact_cli/{bin,data,lib}"
197-
skip = "pp*"
198-
test-command = "pytest"
199197

200-
[tool.cibuildwheel.macos]
201-
# The repair tool unfortunately did not like the bundled Ruby distributable.
202-
# TODO: Check whether delocate-wheel can be configured.
203-
repair-wheel-command = ""
198+
# The repair tool unfortunately did not like the bundled Ruby distributable,
199+
# with false-positives missing libraries despite being bundled.
200+
repair-wheel-command = ""
204201

205202
[tool.cibuildwheel.windows]
206203
before-build = [

0 commit comments

Comments
 (0)