Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 95 additions & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,24 @@
name: BinPyRelease

on:
# MAINTAINER INTENT: pushes to the default branch intentionally enter
# this release workflow. With deployment enabled, test_deploy publishes
# those artifacts to TestPyPI so every mainline merge exercises the
# release packaging/signing/trusted-publishing path before promotion.
# Do not make TestPyPI manual-only or remove the default-branch trigger
# unless intentionally changing that release policy.
push:
branches: [ main, release ]
workflow_dispatch:
inputs:
publish_target:
description: Optional non-production publish target
required: true
default: build-only
type: choice
options:
- build-only
- testpypi

jobs:
build_sdist:
Expand All @@ -23,14 +39,14 @@ jobs:
- name: Checkout source
uses: actions/checkout@v6.0.2
- name: Set up Python 3.13
uses: actions/setup-python@v5.6.0
uses: actions/setup-python@v6.2.0
with:
python-version: '3.13'
- name: Build sdist
shell: bash
run: |-
python -m pip install pip uv -U
python -m uv pip install setuptools>=0.8 wheel build twine
python -m uv pip install setuptools>=77 wheel build twine
python -m build --sdist --outdir wheelhouse
python -m twine check ./wheelhouse/line_profiler*.tar.gz
- name: Show built files
Expand All @@ -50,30 +66,45 @@ jobs:
strategy:
fail-fast: false
matrix:
# Release wheel coverage is deliberately broader than the ordinary test-wheel
# matrix. Every configured desktop OS must emit the modern native architectures
# we publish: Linux x86_64 and ARM64, macOS Apple Silicon and Intel, and Windows
# x86_64. Linux cibuildwheel selectors may emit both manylinux and musllinux
# artifacts from each native runner. Keep every entry required: TestPyPI/PyPI
# deploy jobs depend on this entire build job so a missing architecture fails
# closed instead of publishing a partial wheel set.

# Normally, xcookie generates explicit lists of platforms to build / test
# on, but in this case cibuildwheel does that for us, so we need to just
# set the environment variables for cibuildwheel. These are parsed out of
# the standard [tool.cibuildwheel] section in pyproject.toml and set
# explicitly here.
os:
- ubuntu-latest
- macOS-latest
- windows-latest
- ubuntu-24.04-arm
cibw_skip:
- '*-win32 cp310-win_arm64 cp313-musllinux_i686'
arch:
- auto
include:
- os: ubuntu-latest
arch: auto
cibw_skip: pp* *-musllinux_* cp310-win_arm64
- os: ubuntu-24.04-arm
arch: auto
cibw_skip: pp* *-musllinux_* cp310-win_arm64
- os: macos-15
arch: auto
cibw_skip: pp* *-musllinux_* cp310-win_arm64
- os: macos-15-intel
arch: auto
cibw_skip: pp* *-musllinux_* cp310-win_arm64
- os: windows-latest
arch: auto
cibw_skip: pp* *-musllinux_* cp310-win_arm64
steps:
- name: Checkout source
uses: actions/checkout@v6.0.2
- name: Enable MSVC 64bit
uses: ilammy/msvc-dev-cmd@v1
uses: ilammy/msvc-dev-cmd@v1.13.0
if: ${{ startsWith(matrix.os, 'windows-') }}
with:
arch: ${{ contains(matrix.os, 'arm') && 'arm64' || 'x64' }}
- name: Build binary wheels
uses: pypa/cibuildwheel@v3.3.1
uses: pypa/cibuildwheel@v4.3.1
with:
output-dir: wheelhouse
config-file: pyproject.toml
Expand All @@ -83,6 +114,8 @@ jobs:
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
PYTHONUTF8: '1'
VSCMD_ARG_TGT_ARCH: ''
CIBW_ARCHS_WINDOWS: auto64
CIBW_ARCHS_MACOS: auto64
- name: Show built files
shell: bash
run: ls -la wheelhouse
Expand All @@ -94,20 +127,20 @@ jobs:
test_deploy:
name: Deploy Test
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_target == 'testpypi')
needs:
- build_binpy_wheels
- build_sdist
steps:
- name: Checkout source
uses: actions/checkout@v6.0.2
- uses: actions/download-artifact@v4.1.8
- uses: actions/download-artifact@v7.0.0
name: Download wheels
with:
pattern: wheels-*
merge-multiple: true
path: wheelhouse
- uses: actions/download-artifact@v4.1.8
- uses: actions/download-artifact@v7.0.0
name: Download sdist
with:
name: sdist_wheels
Expand Down Expand Up @@ -137,7 +170,7 @@ jobs:
IMPORTED_FPR=$($GPG_EXECUTABLE --list-keys --with-colons "$GPG_KEYID" | awk -F: '/^fpr/ { print $10; exit }')
if [[ "$IMPORTED_FPR" != "$GPG_KEYID" ]]; then echo "ERROR: imported GPG fingerprint $IMPORTED_FPR does not match pinned $GPG_KEYID"; exit 1; fi
echo "GPG fingerprint verified: $IMPORTED_FPR"
VERSION=$(python -c "import setup; print(setup.VERSION)")
VERSION=$(python -c 'import ast, pathlib; tree = ast.parse(pathlib.Path('"'"'line_profiler/__init__.py'"'"').read_text()); print(next(ast.literal_eval(n.value) for n in tree.body if isinstance(n, ast.Assign) and any(getattr(t, "id", None) == "__version__" for t in n.targets)))')
python -m pip install pip uv -U
python -m pip install packaging twine -U
python -m pip install urllib3 requests[security]
Expand Down Expand Up @@ -190,20 +223,20 @@ jobs:
live_deploy:
name: Deploy Live
runs-on: ubuntu-latest
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags') || startsWith(github.event.ref, 'refs/heads/release'))
if: github.event_name == 'push' && github.ref == 'refs/heads/release'
needs:
- build_binpy_wheels
- build_sdist
steps:
- name: Checkout source
uses: actions/checkout@v6.0.2
- uses: actions/download-artifact@v4.1.8
- uses: actions/download-artifact@v7.0.0
name: Download wheels
with:
pattern: wheels-*
merge-multiple: true
path: wheelhouse
- uses: actions/download-artifact@v4.1.8
- uses: actions/download-artifact@v7.0.0
name: Download sdist
with:
name: sdist_wheels
Expand Down Expand Up @@ -233,7 +266,7 @@ jobs:
IMPORTED_FPR=$($GPG_EXECUTABLE --list-keys --with-colons "$GPG_KEYID" | awk -F: '/^fpr/ { print $10; exit }')
if [[ "$IMPORTED_FPR" != "$GPG_KEYID" ]]; then echo "ERROR: imported GPG fingerprint $IMPORTED_FPR does not match pinned $GPG_KEYID"; exit 1; fi
echo "GPG fingerprint verified: $IMPORTED_FPR"
VERSION=$(python -c "import setup; print(setup.VERSION)")
VERSION=$(python -c 'import ast, pathlib; tree = ast.parse(pathlib.Path('"'"'line_profiler/__init__.py'"'"').read_text()); print(next(ast.literal_eval(n.value) for n in tree.body if isinstance(n, ast.Assign) and any(getattr(t, "id", None) == "__version__" for t in n.targets)))')
python -m pip install pip uv -U
python -m pip install packaging twine -U
python -m pip install urllib3 requests[security]
Expand Down Expand Up @@ -284,7 +317,7 @@ jobs:
environment: pypi
release:
name: Create Github Release
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags') || startsWith(github.event.ref, 'refs/heads/release'))
if: github.event_name == 'push' && github.ref == 'refs/heads/release'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -293,7 +326,7 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v6.0.2
- uses: actions/download-artifact@v4.1.8
- uses: actions/download-artifact@v7.0.0
name: Download artifacts
with:
name: deploy_artifacts
Expand All @@ -302,24 +335,43 @@ jobs:
shell: bash
run: ls -la wheelhouse
- run: 'echo "Automatic Release Notes. TODO: improve" > ${{ github.workspace }}-CHANGELOG.txt'
- name: Resolve Release Tag
id: release_meta
shell: bash
run: |-
export VERSION=$(python -c 'import ast, pathlib; tree = ast.parse(pathlib.Path('"'"'line_profiler/__init__.py'"'"').read_text()); print(next(ast.literal_eval(n.value) for n in tree.body if isinstance(n, ast.Assign) and any(getattr(t, "id", None) == "__version__" for t in n.targets)))')
echo "VERSION=$VERSION"
test -n "$VERSION" || { echo "failed to parse version" ; exit 1; }
TAG="v$VERSION"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Tag Release Commit
if: (startsWith(github.event.ref, 'refs/heads/release'))
shell: bash
run: |-
export VERSION=$(python -c "import setup; print(setup.VERSION)")
git tag "v$VERSION"
git push origin "v$VERSION"
TAG="${{ steps.release_meta.outputs.tag }}"
REMOTE_SHA=$(git ls-remote --refs origin "refs/tags/$TAG" | awk '{print $1}')
if [[ -n "$REMOTE_SHA" ]]; then
test "$REMOTE_SHA" = "$GITHUB_SHA" || {
echo "$TAG already points to $REMOTE_SHA, not $GITHUB_SHA"
exit 1
}
echo "$TAG already points to this release commit"
else
git tag "$TAG" "$GITHUB_SHA"
git push origin "refs/tags/$TAG"
fi
- uses: softprops/action-gh-release@v1
name: Create Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: ${{ github.workspace }}-CHANGELOG.txt
tag_name: ${{ github.ref }}
name: Release ${{ github.ref }}
tag_name: ${{ steps.release_meta.outputs.tag }}
name: Release ${{ steps.release_meta.outputs.tag }}
target_commitish: ${{ github.sha }}
body: Automatic Release
generate_release_notes: true
draft: true
draft: false
prerelease: false
files: |-
wheelhouse/*.whl
Expand All @@ -335,11 +387,11 @@ jobs:
# This release workflow file:
# .github/workflows/release.yml
# Workflow page:
# github.com/pyutils/line_profiler/actions/workflows/release.yml
# https://github.com/pyutils/line_profiler/actions/workflows/release.yml
# Workflow source:
# github.com/pyutils/line_profiler/blob/main/.github/workflows/release.yml
# https://github.com/pyutils/line_profiler/blob/main/.github/workflows/release.yml
# GitHub environments:
# github.com/pyutils/line_profiler/settings/environments
# https://github.com/pyutils/line_profiler/settings/environments
#
# Official references:
# https://docs.pypi.org/trusted-publishers/
Expand All @@ -354,23 +406,23 @@ jobs:
# - testpypi
# - pypi
# URL:
# github.com/pyutils/line_profiler/settings/environments
# https://github.com/pyutils/line_profiler/settings/environments
#
# Some xcookie setups will expect a setup like:
#
# - testpypi:
# * environment name: testpypi
# * use for non-release pushes that publish to TestPyPI
# * used automatically for default-branch packaging smoke tests
# and optionally for explicit workflow_dispatch probes
# * usually no manual approval is needed
# * optionally restrict deployment branches if you only want
# TestPyPI publishes from selected branches
# * this environment is never part of a live release push
#
# - pypi:
# * environment name: pypi
# * use for real releases only
# * require manual approval / required reviewers
# * prevent self-review if your org supports it
# * restrict deployments to release branches / version tags
# * restrict deployments to the exact release branch
#
# - do not put TWINE_* secrets in these environments when using
# trusted publishing
Expand All @@ -391,6 +443,10 @@ jobs:
# Account publishing page:
# https://pypi.org/manage/account/publishing/
#
# If workspace_members publishes additional distributions,
# register this same repository/workflow/environment tuple as a
# trusted publisher for each workspace PyPI project as well.
#
# 3. In TestPyPI, add a trusted publisher for this project:
# owner: pyutils
# repository: line_profiler
Expand All @@ -410,4 +466,4 @@ jobs:
# CI_SECRET is still required (environment-scoped to pypi/testpypi).
# - When enable_gpg=true and ci_gpg_secret_transport="direct_ci":
# GPG_SECRET_SIGNING_SUBKEY_B64, GPG_PUBLIC_KEY_B64, and GPG_OWNER_TRUST_B64
# are required (environment-scoped to pypi/testpypi). No CI_SECRET.
# are required (environment-scoped to pypi/testpypi). No CI_SECRET.
Loading
Loading