Skip to content

Publish palace-util and palace-opds to PyPI on release (PP-4076)#3238

Open
jonathangreen wants to merge 2 commits intomainfrom
chore/publish-workspace-packages
Open

Publish palace-util and palace-opds to PyPI on release (PP-4076)#3238
jonathangreen wants to merge 2 commits intomainfrom
chore/publish-workspace-packages

Conversation

@jonathangreen
Copy link
Copy Markdown
Member

@jonathangreen jonathangreen commented Apr 14, 2026

Description

Two things:

  1. Dynamic versioning for both workspace packages. Each package's pyproject.toml now declares dynamic = ["version"] and sources the version from a committed _version.py stub via hatchling's built-in regex version source. The stub carries a dev placeholder (0.0.0.dev0, __commit__ = None) so uv build --package … works out-of-box for local and CI builds without an explicit version override. The release workflow overwrites _version.py with real dunamai-computed values right before uv build, so the wheel metadata picks up the real version.

  2. publish-pypi.yml workflow triggered by published GitHub Releases. Matrix-builds both packages in parallel, uses PyPI's Trusted Publishing (OIDC) flow. The workflow also pins the intra-workspace dep, so palace-opds always depends on the most recent palace-util.

Motivation and Context

With palace-util and palace-opds extracted as standalone packages, they should be installable from PyPI so downstream Palace services (and the wider OPDS-consuming community for palace-opds) can depend on them without pulling in the palace-manager monorepo. palace-manager itself is intentionally NOT published here — it needs additional work first (alembic and friends prevent a clean wheel build).

One-time PyPI setup

I need to setup trusted publishing in pypi before we cut a release with this. This is a work in progress. 🚧
This setup is complete now.

How Has This Been Tested?

I set this up in my own fork, and published test packages to test.pypi.org. Using the same workflow they published correctly for me:

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.30%. Comparing base (11171c1) to head (06c835b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3238      +/-   ##
==========================================
- Coverage   93.30%   93.30%   -0.01%     
==========================================
  Files         498      502       +4     
  Lines       46147    46155       +8     
  Branches     6318     6318              
==========================================
+ Hits        43059    43066       +7     
- Misses       2003     2004       +1     
  Partials     1085     1085              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonathangreen jonathangreen force-pushed the chore/extract-palace-opds branch 2 times, most recently from f42c076 to 568b49d Compare April 14, 2026 19:30
Base automatically changed from chore/extract-palace-opds to main April 14, 2026 19:40
@jonathangreen jonathangreen changed the title Publish palace-util and palace-opds to PyPI on release Publish palace-util and palace-opds to PyPI on release (PP-4076) Apr 14, 2026
@jonathangreen jonathangreen force-pushed the chore/publish-workspace-packages branch from f1f8058 to 8d9177c Compare April 14, 2026 19:43
Both packages now declare `dynamic = ["version"]` and source the
version from a committed `_version.py` stub via hatchling's regex
version source. The stub carries a dev placeholder (0.0.0.dev0) so
local / developer builds succeed out-of-box; the PyPI publish workflow
overwrites `_version.py` with the dunamai-computed release version
right before `uv build` to get the real version into the wheel
metadata.

The workflow:

- Runs a matrix job per package on parallel runners.
- Computes version / commit / branch from the release tag via dunamai.
- Overwrites the package's _version.py with the computed values so the
  wheel metadata picks up the release version (see the previous
  commit for why _version.py is the source of truth).
- Pins the intra-workspace dependency before building palace-opds:
  uv build leaves workspace deps as bare `palace-util` in the wheel's
  Requires-Dist, which would fail to resolve on PyPI; we sed in
  `palace-util==<version>` so consumers installing palace-opds get the
  matching palace-util.
- Uploads via pypa/gh-action-pypi-publish@release/v1 with OIDC.
@jonathangreen jonathangreen force-pushed the chore/publish-workspace-packages branch from 8d9177c to 89c505b Compare April 15, 2026 14:38
@jonathangreen jonathangreen requested a review from a team April 15, 2026 14:43
@jonathangreen jonathangreen marked this pull request as ready for review April 15, 2026 15:00
Copy link
Copy Markdown
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants