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
83 changes: 83 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Publish to PyPI

# Publishes `palace-util` and `palace-opds` when a GitHub Release is
# published. Each package is built and uploaded independently via PyPI's
# Trusted Publishing (OIDC) flow. https://docs.pypi.org/trusted-publishers/
#
# No action is needed on new releases beyond publishing a GitHub Release with
# a tag that dunamai can parse as semver (e.g. `v1.0.0` or `1.0.0`).

on:
release:
types: [published]

env:
PYTHON_VERSION: "3.12"

jobs:
publish:
name: Publish ${{ matrix.package }} to PyPI
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- package: palace-util
source_dir: packages/palace-util/src/palace/util
- package: palace-opds
source_dir: packages/palace-opds/src/palace/opds
permissions:
# Required for PyPI Trusted Publishing (OIDC).
id-token: write
contents: read

steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
# dunamai needs the full tag history.
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
cache-dependency-glob: uv.lock
python-version: ${{ env.PYTHON_VERSION }}
activate-environment: true

- name: Install Dunamai
run: uv sync --frozen --only-group ci

- name: Compute version metadata
id: version
run: |
echo "version=$(dunamai from git --style semver)" >> "$GITHUB_OUTPUT"
echo "commit=$(dunamai from git --format '{commit}' --full-commit)" >> "$GITHUB_OUTPUT"

- name: Write _version.py
# hatch reads __version__ from this file via [tool.hatch.version]
# regex source; overwriting it here is how the release version lands
# in the wheel metadata.
run: |
cat > ${{ matrix.source_dir }}/_version.py <<EOF
__version__ = "${{ steps.version.outputs.version }}"
__commit__: str | None = "${{ steps.version.outputs.commit }}"
EOF

- name: Pin intra-workspace dependency
# uv build preserves workspace deps as bare names in Requires-Dist
# (e.g. `palace-util` with no version). For PyPI we need an exact pin
# so a consumer installing palace-opds resolves the matching
# palace-util version.
if: matrix.package == 'palace-opds'
run: uv add --package palace-opds "palace-util==${{ steps.version.outputs.version }}"

- name: Build ${{ matrix.package }}
run: uv build --package ${{ matrix.package }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
print-hash: true
5 changes: 4 additions & 1 deletion packages/palace-opds/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ dependencies = [
"uritemplate==4.2.0",
]
description = "Pydantic models for OPDS 2.0, RWPM, ODL, LCP, and Palace Project extensions."
dynamic = ["version"]
license = "Apache-2.0"
name = "palace-opds"
readme = "README.md"
requires-python = ">=3.12,<4"
version = "0"

[project.urls]
Homepage = "https://thepalaceproject.org"
Expand All @@ -24,6 +24,9 @@ Repository = "https://github.com/ThePalaceProject/circulation"
[tool.hatch.build.targets.wheel]
packages = ["src/palace"]

[tool.hatch.version]
path = "src/palace/opds/_version.py"

[tool.isort]
combine_as_imports = true
known_first_party = ["palace.opds"]
Expand Down
3 changes: 3 additions & 0 deletions packages/palace-opds/src/palace/opds/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from palace.opds._version import __commit__, __version__

__all__ = ["__commit__", "__version__"]
6 changes: 6 additions & 0 deletions packages/palace-opds/src/palace/opds/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# WARNING!
# This file is dynamically generated during the CI build process.
# Any changes made here will be overwritten. Do not edit this file manually.

__version__ = "0.0.0.dev0"
__commit__: str | None = None
5 changes: 4 additions & 1 deletion packages/palace-util/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ dependencies = [
"python-dateutil>=2.8,<3",
]
description = "Shared utilities for Palace Project packages."
dynamic = ["version"]
license = "Apache-2.0"
name = "palace-util"
readme = "README.md"
requires-python = ">=3.12,<4"
version = "0"

[project.urls]
Homepage = "https://thepalaceproject.org"
Expand All @@ -21,6 +21,9 @@ Repository = "https://github.com/ThePalaceProject/circulation"
[tool.hatch.build.targets.wheel]
packages = ["src/palace"]

[tool.hatch.version]
path = "src/palace/util/_version.py"

[tool.isort]
combine_as_imports = true
known_first_party = ["palace.util"]
Expand Down
3 changes: 3 additions & 0 deletions packages/palace-util/src/palace/util/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from palace.util._version import __commit__, __version__

__all__ = ["__commit__", "__version__"]
6 changes: 6 additions & 0 deletions packages/palace-util/src/palace/util/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# WARNING!
# This file is dynamically generated during the CI build process.
# Any changes made here will be overwritten. Do not edit this file manually.

__version__ = "0.0.0.dev0"
__commit__: str | None = None
2 changes: 0 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading