Skip to content

Change PyPI publishing to trigger on releases and tags#187

Merged
bortok merged 1 commit intodevfrom
pypi-on-release
Jan 4, 2026
Merged

Change PyPI publishing to trigger on releases and tags#187
bortok merged 1 commit intodevfrom
pypi-on-release

Conversation

@bortok
Copy link
Copy Markdown
Contributor

@bortok bortok commented Jan 4, 2026

Summary

This PR updates the PyPI and TestPyPI publishing workflows to use a more controlled release process based on GitHub releases and tags, instead of automatic publishing on every push to main.

Changes

PyPI Workflow (Production)

Before: Published to PyPI on every push to main branch
After: Publishes to PyPI only when a GitHub release is published

  • Trigger: on.release.types = [published]
  • More controlled production releases
  • Aligns package versions with Git tags and release notes

TestPyPI Workflow (Testing)

Before: Published to TestPyPI on every PR to main
After: Publishes to TestPyPI when:

  1. A draft release is created (on.release.types = [created])
  2. A release is marked as prerelease (on.release.types = [prereleased])
  3. Pre-release version tags are pushed (v*rc*, v*-dev*, v*-alpha*, v*-beta*)

Removed: PR to main trigger (replaced with more intentional release triggers)

Benefits

  1. Controlled releases - No accidental publishes from commits to main
  2. Test before production - Validate on TestPyPI before publishing to PyPI
  3. Version alignment - GitHub releases, Git tags, and PyPI versions stay in sync
  4. Release documentation - Requires release notes before publishing
  5. Standard versioning - Supports rc, dev, alpha, beta pre-releases

Release Workflow

Testing a Pre-release

# Option 1: Push a pre-release tag
git tag v0.8.2rc1
git push --tags
# → Automatically publishes to TestPyPI

# Option 2: Create a draft release on GitHub
# → Automatically publishes to TestPyPI

Publishing to Production

# 1. Create and publish a GitHub release (e.g., v0.8.2)
# 2. Workflow automatically builds and publishes to PyPI

Manual Trigger (if needed)

Both workflows still support manual triggering via workflow_dispatch.

Breaking Changes

None - this only changes the automation triggers. Manual publishing via make publish is unchanged.

Testing

  • Workflow syntax validated
  • Will be tested by creating a test release after merge

Updated both PyPI and TestPyPI workflows for controlled releases:

PyPI (production):
- Trigger: When a GitHub release is published
- Use case: Official releases to PyPI
- Process: Create release → Publish → Auto-deploy to PyPI

TestPyPI (testing):
- Trigger 1: When a release is created (draft) or marked as prerelease
- Trigger 2: When pre-release tags are pushed (v*rc*, v*-dev*, v*-alpha*, v*-beta*)
- Removed: PR to main trigger (no longer needed with new release process)

Benefits:
- Controlled release process tied to GitHub releases
- Test pre-releases on TestPyPI before production
- Prevents accidental publishes from direct commits
- Supports standard pre-release versioning

Workflow:
1. Test: git tag v0.8.1rc1 && git push --tags → TestPyPI
2. Draft: Create draft release → TestPyPI
3. Pre-release: Mark as prerelease → TestPyPI
4. Production: Publish release → PyPI

Manual triggers via workflow_dispatch available for both.
@bortok bortok merged commit e3feee0 into dev Jan 4, 2026
1 check passed
@bortok bortok deleted the pypi-on-release branch January 4, 2026 18:28
bortok added a commit that referenced this pull request Jan 4, 2026
Makefile changes:
- 'make test-publish' now creates and pushes pre-release tags
- Automatically triggers GitHub Actions for TestPyPI publish
- Validates version contains rc/dev/alpha/beta
- No local build/upload needed
- 'make pubdev' remains as legacy alias

BUILD.md updates:
- Document new automated 'make test-publish' workflow
- Clarify manual vs automated publishing
- Add Make commands reference section
- Update workflow summary with new process
- Remove confusion about manual upload

New workflow:
1. hatch version rc → v0.8.1rc0
2. make test-publish → Creates tag, pushes, triggers GitHub Actions
3. GitHub Actions builds and publishes to TestPyPI

This aligns with the tag-based publishing from PR #187.
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.

1 participant