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
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ jobs:
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --all-targets -- -D warnings
run: cargo clippy --all-targets --locked -- -D warnings

- name: Run the tests
run: cargo test --all-targets
run: cargo test --all-targets --locked

- name: Package eggpass-auth
run: cargo package --locked --allow-dirty -p eggpass-auth

- name: Package eggpass
run: >-
cargo package --locked --allow-dirty -p eggpass
--config 'patch.crates-io.eggpass-auth.path="crates/eggpass-auth"'

- name: Build the release binary
run: cargo build --release
run: cargo build --release --locked

windows-msvc:
name: Windows MSVC tests and release build
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/publish-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ permissions:

jobs:
publish:
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'release' &&
startsWith(github.event.release.tag_name, 'v'))
name: publish
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -52,10 +56,10 @@ jobs:
fi

- name: Verify the package
run: cargo package --locked --allow-dirty
run: cargo package --locked --allow-dirty -p eggpass

- name: Publish the crate
if: ${{ github.event_name == 'release' && !(inputs.dry_run == true) }}
run: cargo publish --locked
if: ${{ github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v') && !(inputs.dry_run == true) }}
run: cargo publish --locked -p eggpass
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
326 changes: 326 additions & 0 deletions .github/workflows/publish-eggpass-auth-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
name: Publish eggpass-auth to PyPI

# Python releases use eggpass-auth-python-vX.Y.Z and are independent of the
# Rust auth crate (eggpass-auth-vX.Y.Z) and the Eggpass CLI (vX.Y.Z).
on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: pypi-${{ github.event.release.tag_name || github.ref }}
cancel-in-progress: false

jobs:
verify-source:
name: Verify Python release tag and version
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.event.release.tag_name, 'eggpass-auth-python-v'))
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.version.outputs.value }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || github.ref }}

- uses: actions/setup-python@v6
with:
python-version: "3.11"

- name: Verify package versions and release tag
id: version
env:
EVENT_NAME: ${{ github.event_name }}
RELEASE_TAG: ${{ github.event.release.tag_name || '' }}
working-directory: python/eggpass-auth
run: |
python - <<'PY'
import os
import re
import tomllib
from pathlib import Path

with Path("pyproject.toml").open("rb") as manifest:
python_version = tomllib.load(manifest)["project"]["version"]
with Path("Cargo.toml").open("rb") as manifest:
rust_version = tomllib.load(manifest)["package"]["version"]

if python_version != rust_version:
raise SystemExit(
f"pyproject.toml version {python_version} does not match "
f"Cargo.toml {rust_version}"
)

if os.environ["EVENT_NAME"] == "release":
tag = os.environ["RELEASE_TAG"]
tag_pattern = r"eggpass-auth-python-v\d+\.\d+\.\d+"
if not re.fullmatch(tag_pattern, tag):
raise SystemExit(f"invalid Python release tag: {tag}")
if tag != f"eggpass-auth-python-v{python_version}":
raise SystemExit(
f"tag {tag} does not match package version "
f"{python_version}"
)

output_path = Path(os.environ["GITHUB_OUTPUT"])
with output_path.open("a", encoding="utf-8") as output:
output.write(f"value={python_version}\n")
print(f"Verified eggpass-auth Python version {python_version}")
PY

build-wheels:
name: Build ${{ matrix.platform.name }} wheel
needs: verify-source
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
platform:
- name: linux-x86_64
runner: ubuntu-24.04
manylinux: "2014"
interpreter: python3.11
- name: linux-aarch64
runner: ubuntu-24.04-arm
manylinux: "2014"
interpreter: python3.11
- name: macos-x86_64
runner: macos-15-intel
manylinux: "off"
interpreter: python
- name: macos-arm64
runner: macos-15
manylinux: "off"
interpreter: python
- name: windows-x86_64
runner: windows-2025
manylinux: "off"
interpreter: python
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || github.ref }}

- uses: actions/setup-python@v6
with:
python-version: "3.11"

- name: Check the vendored Rust source snapshot
run: python tools/sync_core.py --check
working-directory: python/eggpass-auth

- name: Build stable-ABI wheel
uses: PyO3/maturin-action@v1
with:
maturin-version: v1.16.0
manylinux: ${{ matrix.platform.manylinux }}
args: >-
--release --locked --interpreter ${{ matrix.platform.interpreter }}
--out dist
working-directory: python/eggpass-auth

- uses: actions/upload-artifact@v4
with:
name: python-dist-${{ matrix.platform.name }}
path: python/eggpass-auth/dist/*.whl
if-no-files-found: error
retention-days: 14

build-sdist:
name: Build source distribution
needs: verify-source
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || github.ref }}

- uses: actions/setup-python@v6
with:
python-version: "3.11"

- name: Install Rust
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable

- name: Install Maturin
run: python -m pip install "maturin==1.16.0"

- name: Check the vendored Rust source snapshot
run: python tools/sync_core.py --check
working-directory: python/eggpass-auth

- name: Build source distribution
run: maturin sdist --out dist
working-directory: python/eggpass-auth

- uses: actions/upload-artifact@v4
with:
name: python-dist-sdist
path: python/eggpass-auth/dist/*.tar.gz
if-no-files-found: error
retention-days: 14

validate-artifacts:
name: Validate release distributions
needs: [verify-source, build-wheels, build-sdist]
runs-on: ubuntu-24.04
steps:
- uses: actions/setup-python@v6
with:
python-version: "3.11"

- uses: actions/download-artifact@v4
with:
pattern: python-dist-*
path: dist
merge-multiple: true

- name: Install distribution checker
run: python -m pip install twine packaging

- name: Validate metadata and target coverage
env:
PACKAGE_VERSION: ${{ needs.verify-source.outputs.version }}
run: |
python -m twine check dist/*
python - <<'PY'
import os
import tarfile
from pathlib import Path
from packaging.utils import (
canonicalize_name,
parse_sdist_filename,
parse_wheel_filename,
)

version = os.environ["PACKAGE_VERSION"]
files = sorted(Path("dist").iterdir())
wheels = [path for path in files if path.suffix == ".whl"]
sdists = [path for path in files if path.name.endswith(".tar.gz")]
if len(wheels) != 5 or len(sdists) != 1 or len(files) != 6:
names = [path.name for path in files]
raise SystemExit(
f"expected five wheels and one sdist; found {names}"
)

wheel_platforms = []
for wheel in wheels:
_name, wheel_version, _build, tags = parse_wheel_filename(
wheel.name
)
if canonicalize_name(_name) != canonicalize_name("eggpass-auth"):
raise SystemExit(f"unexpected distribution in {wheel.name}")
if str(wheel_version) != version:
raise SystemExit(f"unexpected wheel version in {wheel.name}")
abi3 = any(
tag.interpreter == "cp311" and tag.abi == "abi3"
for tag in tags
)
if not abi3:
raise SystemExit(
f"wheel is not tagged cp311-abi3: {wheel.name}"
)
wheel_platforms.append({tag.platform for tag in tags})

def has_platform(platforms, prefix, suffix):
return any(
platform.startswith(prefix) and platform.endswith(suffix)
for platform in platforms
)

expected = {
"Linux x86_64": ("manylinux", "_x86_64"),
"Linux aarch64": ("manylinux", "_aarch64"),
"macOS x86_64": ("macosx_", "_x86_64"),
"macOS arm64": ("macosx_", "_arm64"),
"Windows x86_64": ("win_amd64", ""),
}
unmatched = list(wheel_platforms)
for label, (prefix, suffix) in expected.items():
if label == "Windows x86_64":
matches = lambda platforms: prefix in platforms
else:
matches = lambda platforms: has_platform(
platforms, prefix, suffix
)
index = next(
(
i
for i, platforms in enumerate(unmatched)
if matches(platforms)
),
None,
)
if index is None:
raise SystemExit(
f"missing {label} wheel; wheel tags were "
f"{wheel_platforms}"
)
unmatched.pop(index)

sdist = sdists[0]
distribution, sdist_version = parse_sdist_filename(sdist.name)
expected_name = canonicalize_name("eggpass-auth")
if canonicalize_name(distribution) != expected_name:
raise SystemExit(f"unexpected distribution in {sdist.name}")
if str(sdist_version) != version:
raise SystemExit(f"unexpected sdist version in {sdist.name}")
with tarfile.open(sdist) as archive:
members = archive.getnames()
required = (
"/README.md",
"/LICENSE",
"/Cargo.toml",
"/Cargo.lock",
"/src/lib.rs",
"/vendor/eggpass-auth/Cargo.toml",
"/vendor/eggpass-auth/src/lib.rs",
)
missing = [
suffix
for suffix in required
if not any(name.endswith(suffix) for name in members)
]
if missing:
raise SystemExit(f"sdist is missing required files: {missing}")
print(f"Validated {len(wheels)} wheels and {sdist.name}")
PY

- uses: actions/upload-artifact@v4
with:
name: verified-distributions
path: dist/*
if-no-files-found: error
retention-days: 14

publish:
name: Publish verified files to PyPI
needs: validate-artifacts
if: >-
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.event.release.tag_name, 'eggpass-auth-python-v')
runs-on: ubuntu-24.04
environment:
name: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: verified-distributions
path: dist

- name: Publish with PyPI Trusted Publishing
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
Loading
Loading