Skip to content

test(compat-suite): add v4 plugin scenarios #4

test(compat-suite): add v4 plugin scenarios

test(compat-suite): add v4 plugin scenarios #4

Workflow file for this run

---
# Release workflow for pact-python-ffi (FFI wrapper package).
#
# This package tracks the upstream pact-foundation/pact-reference project and
# versions itself as `{upstream_version}.{N}` (e.g. `0.4.28.0`). The release
# lifecycle runs in three stages:
#
# Stage 1: Prepare (trigger: push to main)
# The `prepare` job runs `scripts/release.py prepare ffi`, which fetches the
# latest `pact_ffi-v*` release from pact-foundation/pact-reference,
# computes the next wrapper version, updates pyproject.toml and CHANGELOG.md,
# and force-pushes those changes to the fixed branch `release/pact-python-ffi`.
# It then creates (or updates the title and body of) the release PR targeting
# main.
#
# Stage 2: Tag (trigger: release PR merged → `closed` event, merged == true)
# When the release PR on `release/pact-python-ffi` is merged, the `tag` job
# runs `scripts/release.py tag ffi`, which reads the version from
# pyproject.toml and pushes a git tag of the form `pact-python-ffi/X.Y.Z.N`.
#
# Stage 3: Publish (trigger: tag push matching `pact-python-ffi/*`)
# The `build-sdist`, `build-wheels`, and `publish` jobs build the full wheel
# matrix (macOS/Linux/Windows, multiple architectures), create a GitHub
# release with the changelog, and publish all artifacts to PyPI.
#
# Additional: `build-sdist` and `build-wheels` also run on open/updated release
# PRs (not closed) to verify builds before merging.
#
# The `closed` PR type is listed in the trigger so that Stage 2 fires on merge.
# All jobs except `tag` guard against closed-but-not-merged events with
# explicit `if` conditions.
name: release ffi
on:
push:
branches:
- main
tags:
- pact-python-ffi/*
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- closed
permissions:
contents: read
# Only runs that a newer run fully supersedes share a group, and the newer run
# cancels the older one:
#
# - Push to main: only `prepare` runs, and it rebuilds the release branch from
# scratch.
# - Open or updated PR: only the verification build runs.
#
# Tag pushes and PR merges get a group of their own (the run ID), so nothing can
# cancel them or hold them in the pending queue. The `push` check matters: a
# `closed` PR event sets `github.ref` to the base branch, `refs/heads/main`.
concurrency:
group: >-
${{ github.workflow }}-${{
(
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'pull_request' && github.event.action != 'closed')
) && github.ref || github.run_id
}}
cancel-in-progress: true
env:
STABLE_PYTHON_VERSION: '311'
HATCH_VERBOSE: '1'
FORCE_COLOR: '1'
CIBW_BUILD_FRONTEND: build
jobs:
complete:
name: Release FFI completion check
if: always()
runs-on: ubuntu-latest
needs:
- prepare
- tag
- build-sdist
- build-wheels
- publish
steps:
- name: Failed
run: exit 1
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
prepare:
name: Update FFI release PR
if: >-
github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment:
name: release-pr
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
app-id: ${{ vars.PACT_FOUNDATION_BOT_APP_ID }}
private-key: ${{ secrets.PACT_FOUNDATION_BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Need full history for git-cliff to determine the next version and
# generate the changelog
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Configure git identity
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git config user.name "${{ steps.app-token.outputs.app-slug }}[bot]"
git config user.email "$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq '.id')+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com"
- name: Install git-cliff and typos
uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29
with:
tool: git-cliff,typos
- name: Set up uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
- name: Install Python
# Bump to 3.11 to access tomllib
run: uv python install 311
- name: Update release PR
run: uv run python scripts/release.py prepare ffi
env:
# Use the GitHub App token instead of GITHUB_TOKEN so that the PR can
# itself trigger workflows
GH_TOKEN: ${{ steps.app-token.outputs.token }}
tag:
name: Create FFI release tag
if: >-
github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.event.pull_request.head.ref
== 'release/pact-python-ffi'
runs-on: ubuntu-latest
environment:
name: release-pr
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
app-id: ${{ vars.PACT_FOUNDATION_BOT_APP_ID }}
private-key: ${{ secrets.PACT_FOUNDATION_BOT_PRIVATE_KEY }}
- name: Checkout merged release commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Tag the release PR's own commit. The tip of main may already hold
# later, unreleased changes.
ref: ${{ github.event.pull_request.merge_commit_sha }}
token: ${{ steps.app-token.outputs.token }}
- name: Configure git identity
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git config user.name "${{ steps.app-token.outputs.app-slug }}[bot]"
git config user.email "$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq '.id')+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com"
- name: Set up uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
- name: Install Python
# Bump to 3.11 to access tomllib
run: uv python install 311
- name: Create and push release tag
run: uv run python scripts/release.py tag ffi
env:
# Use the GitHub App token instead of GITHUB_TOKEN so that the tag can
# itself trigger workflows
GH_TOKEN: ${{ steps.app-token.outputs.token }}
build-sdist:
name: Build FFI source distribution
# Prepare the wheels for upload, and also verify that the build works on
# release PRs before merging.
if: >-
(
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/pact-python-ffi/')
) || (
github.event_name == 'pull_request' &&
github.event.action != 'closed' &&
github.event.pull_request.head.ref == 'release/pact-python-ffi'
)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
- name: Install Python
run: uv python install ${{ env.STABLE_PYTHON_VERSION }}
- name: Install hatch
run: uv tool install hatch
- name: Build source distribution
working-directory: pact-python-ffi
run: hatch build --target sdist
- name: Upload sdist
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: wheels-sdist
path: pact-python-ffi/dist/*.tar*
if-no-files-found: error
compression-level: 0
build-wheels:
name: Build FFI wheel on ${{ matrix.os }}
# Prepare the wheels for upload, and also verify that the build works on
# release PRs before merging.
if: >-
(
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/pact-python-ffi/')
) || (
github.event_name == 'pull_request' &&
github.event.action != 'closed' &&
github.event.pull_request.head.ref == 'release/pact-python-ffi'
)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-15-intel
- macos-latest
- ubuntu-24.04-arm
- ubuntu-latest
- windows-11-arm
- windows-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Build wheels
uses: pypa/cibuildwheel@b9e566a2b284570af229f6c2a33673410d0389a3 # v4.3.4
with:
package-dir: pact-python-ffi
env:
# The stable ABI wheel targets the oldest supported Python version.
# Free-threaded interpreters need the `abi3t` wheel, which requires
# Python 3.15 and also loads on GIL-enabled builds.
CIBW_BUILD: cp${{ env.STABLE_PYTHON_VERSION }}-* cp315t-*
- name: Set up uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
- name: Check wheel tags
shell: bash
run: uv run --no-project python scripts/check_ffi_wheels.py wheelhouse/*.whl
- name: Upload wheels
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
if-no-files-found: error
compression-level: 0
publish:
name: Publish FFI wheels and sdist
if: >-
github.event_name == 'push' && startsWith(github.ref, 'refs/tags/pact-python-ffi/')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pact-python-ffi
needs:
- build-sdist
- build-wheels
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Extract release changelog
run: |
version="${{ github.ref_name }}"
version="${version#*/}"
out="${{ runner.temp }}/release-changelog.md"
awk -v ver="$version" '
/^## / { if (found) exit; if (index($0, ver)) found=1; next }
found { print }
' pact-python-ffi/CHANGELOG.md > "$out"
if [ ! -s "$out" ]; then
printf '> [!WARNING]\n>\n> No changelog entry found for %s.\n' "$version" > "$out"
fi
- name: Find previous release tag
id: previous-tag
run: |
git fetch --tags --quiet
previous=$(git tag --list 'pact-python-ffi/*' --sort=-version:refname \
| grep -v "^${{ github.ref_name }}$" | head -1)
echo "tag=${previous}" >> "$GITHUB_OUTPUT"
- name: Download wheels and sdist
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: wheelhouse
merge-multiple: true
- name: Create GitHub release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
files: wheelhouse/*
body_path: ${{ runner.temp }}/release-changelog.md
previous_tag: ${{ steps.previous-tag.outputs.tag }}
draft: false
prerelease: false
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
skip-existing: true
packages-dir: wheelhouse