Skip to content

feat(cli): build abi-agnostic wheels #46

feat(cli): build abi-agnostic wheels

feat(cli): build abi-agnostic wheels #46

Workflow file for this run

---
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: '313'
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
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6.4.1
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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
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-13
- 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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Create wheels
uses: pypa/cibuildwheel@95d2f3a92fbf80abe066b09418bbf128a8923df2 # v3.0.1
with:
package-dir: pact-python-cli
env:
CIBW_BUILD: cp${{ env.STABLE_PYTHON_VERSION }}-*
- name: Upload wheels
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Install git cliff and typos
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
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: |
git cliff \
--current \
--strip header \
--output ${{ runner.temp }}/release-changelog.md
echo -e "\n\n## Pull Requests\n\n" >> ${{ runner.temp }}/release-changelog.md
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Download wheels and sdist
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: wheelhouse
merge-multiple: true
- name: Generate release
id: release
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
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@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
skip-existing: true
packages-dir: wheelhouse
- name: Create PR for changelog update
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
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