Fix PyPI upload and reorder release process

- Fix PyPI upload to only include valid distribution files (.whl and .tar.gz)
- Reorder release process to publish to PyPI before creating git tags/GitHub releases
- Prevents .gitignore upload errors and ensures cleaner rollback on PyPI failures
This commit is contained in:
filipstrand 2025-07-17 11:36:41 +02:00
parent fd15a72cda
commit 7ab1e4b276
2 changed files with 16 additions and 11 deletions

View File

@ -126,7 +126,12 @@ class PyPIPublisher:
comment="Automated release via mflux-release-script",
)
dist_files = list(Path("dist").glob("*"))
# Only select valid distribution files (.whl and .tar.gz)
dist_files = []
dist_dir = Path("dist")
dist_files.extend(dist_dir.glob("*.whl"))
dist_files.extend(dist_dir.glob("*.tar.gz"))
if not dist_files:
raise ValueError("No distribution files found in dist/")

View File

@ -37,21 +37,21 @@ class ReleaseManager:
if ReleaseManager._is_release_complete(git_tag_exists, github_release_exists):
return
# 4. Create git tag if needed
if not git_tag_exists:
GitOperations.create_and_push_tag(tag_name, version)
# 5. Create GitHub release if needed
if not github_release_exists:
release_notes = ChangelogParser.extract_release_notes_from_changelog(version)
GitHubAPI.create_github_release(github_token, github_repo, tag_name, version, release_notes)
# 6. Handle PyPI publishing
# 4. Handle PyPI publishing FIRST (before creating git artifacts)
if ReleaseManager._should_publish_to_pypi(git_tag_exists, github_release_exists, package_name, version):
PyPIPublisher.build_and_verify_package()
PyPIPublisher.publish_to_test_pypi(test_pypi_token, package_name, version)
PyPIPublisher.publish_to_pypi(pypi_token, package_name, version)
# 5. Create git tag if needed
if not git_tag_exists:
GitOperations.create_and_push_tag(tag_name, version)
# 6. Create GitHub release if needed
if not github_release_exists:
release_notes = ChangelogParser.extract_release_notes_from_changelog(version)
GitHubAPI.create_github_release(github_token, github_repo, tag_name, version, release_notes)
print(f"🎉 Release process completed successfully for version {version}!")
@staticmethod