| 1 |
release tag: |
| 2 |
#!/usr/bin/env bash |
| 3 |
set -euo pipefail |
| 4 |
|
| 5 |
TAG_COMMIT=$(git rev-parse {{tag}}) |
| 6 |
echo "performing release for {{tag}} @ commit $TAG_COMMIT" |
| 7 |
|
| 8 |
SDIST_ID=$(gh run list \ |
| 9 |
--workflow sdist.yml --json databaseId,headSha --status completed | \ |
| 10 |
jq --raw-output ".[] | select(.headSha==\"$TAG_COMMIT\") | .databaseId" | head -n 1) |
| 11 |
if [ -z "$SDIST_ID" ]; then |
| 12 |
echo "could not find GitHub Actions run for sdist artifact" |
| 13 |
exit 1 |
| 14 |
fi |
| 15 |
|
| 16 |
WHEEL_ID=$(gh run list \ |
| 17 |
--workflow wheel.yml --json databaseId,headSha --status completed | \ |
| 18 |
jq --raw-output ".[] | select(.headSha==\"$TAG_COMMIT\") | .databaseId" | head -n 1) |
| 19 |
if [ -z "$WHEEL_ID" ]; then |
| 20 |
echo "could not find GitHub Actions run for wheels artifacts" |
| 21 |
exit 1 |
| 22 |
fi |
| 23 |
|
| 24 |
rm -rf dist/{{tag}} && mkdir -p dist/{{tag}}/assets dist/{{tag}}/final |
| 25 |
gh run download --dir=dist/{{tag}}/assets $SDIST_ID |
| 26 |
gh run download --dir=dist/{{tag}}/assets $WHEEL_ID |
| 27 |
|
| 28 |
find dist/{{tag}}/assets -name '*.tar.gz' -exec cp {} dist/{{tag}}/final/ ';' |
| 29 |
find dist/{{tag}}/assets -name '*.whl' -exec cp {} dist/{{tag}}/final/ ';' |
| 30 |
|
| 31 |
echo "creating GitHub release {{tag}}" |
| 32 |
gh release create \ |
| 33 |
--prerelease \ |
| 34 |
--target=$TAG_COMMIT \ |
| 35 |
--title={{tag}} \ |
| 36 |
--discussion-category=general \ |
| 37 |
--notes-from-tag \ |
| 38 |
{{tag}} |
| 39 |
gh release upload --clobber {{tag}} dist/{{tag}}/final/* |
| 40 |
|
| 41 |
echo "uploading to PyPI" |
| 42 |
token=$(uv run --no-project -w keyring keyring get pypi token) |
| 43 |
|
| 44 |
# Upload the source distribution first because it can trigger additional |
| 45 |
# validation that can result in an incomplete release being published. |
| 46 |
UV_PUBLISH_TOKEN=$token uv publish dist/{{tag}}/final/*.tar.gz |
| 47 |
UV_PUBLISH_TOKEN=$token uv publish dist/{{tag}}/final/*.whl |