Skip to content

Commit acd178e

Browse files
ci(release): upload to PyPI without the docker rebuild
The Publish step ran twine via `docker compose run --build`, which reinstalled the package inside a container with no .git/tag, so hatch-vcs (added in #1503, first exercised for a release in v2.3.2) could not derive the version and the build failed with metadata-generation-failed before twine ran. Upload the dist/* artifacts already built on the runner directly, with `twine upload --skip-existing` for idempotent re-runs (dropping the brittle resolved_version guard, which was empty).
1 parent d9ce6b7 commit acd178e

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

.github/workflows/post_draft_release_published.yaml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,27 @@ jobs:
5050
python -m build .
5151
echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
5252
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
53-
echo "NEW_VERSION=${{github.event.release.resolved_version}}" >> $GITHUB_ENV
5453
- name: Publish package
5554
id: publish
5655
env:
5756
RELEASE_NAME: ${{ github.event.release.name }}
5857
run: |
59-
export HOST_UID=$(id -u)
58+
python -m pip install --upgrade twine
6059
if [[ "$RELEASE_NAME" =~ ^Test ]]; then
61-
LATEST_PYPI=$(curl -s https://test.pypi.org/pypi/datajoint/json | jq -r '.info.version')
6260
echo "TEST_PYPI=true" >> $GITHUB_ENV
6361
export TWINE_REPOSITORY="testpypi"
6462
export TWINE_USERNAME=${TWINE_TEST_USERNAME}
6563
export TWINE_PASSWORD=${TWINE_TEST_PASSWORD}
6664
else
67-
LATEST_PYPI=$(curl -s https://pypi.org/pypi/datajoint/json | jq -r '.info.version')
6865
echo "TEST_PYPI=false" >> $GITHUB_ENV
6966
export TWINE_REPOSITORY="pypi"
7067
fi
71-
# Check if the new version is different from the latest on PyPI, avoid re-uploading error
72-
if [ "$NEW_VERSION" != "$LATEST_PYPI" ]; then
73-
docker compose run --build --quiet-pull \
74-
-e TWINE_USERNAME=${TWINE_USERNAME} \
75-
-e TWINE_PASSWORD=${TWINE_PASSWORD} \
76-
-e TWINE_REPOSITORY=${TWINE_REPOSITORY} \
77-
app sh -c "pip install twine && python -m twine upload dist/*"
78-
else
79-
echo "::warning::Latest version $LATEST_PYPI on $TWINE_REPOSITORY is the new version $NEW_VERSION"
80-
fi
68+
# Upload the artifacts built in the previous step directly. The old
69+
# `docker compose run --build` path reinstalled the package inside a
70+
# container without the git tag, which broke hatch-vcs version
71+
# derivation. `--skip-existing` keeps re-runs idempotent instead of
72+
# erroring on an already-published version.
73+
python -m twine upload --skip-existing dist/*
8174
# Upload package as release assets
8275
- name: Upload pip wheel asset to release
8376
uses: actions/upload-release-asset@v1

0 commit comments

Comments
 (0)