Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,78 @@ jobs:
path: dist
pattern: dist-*
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
- name: Authenticate to Google Cloud (OSS Exit Gate)
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
workload_identity_provider: 'projects/305452601764/locations/global/workloadIdentityPools/builders/providers/github'

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3.0.1

- name: Clean up failed staging attempt for this exact version (if any)
id: exit_gate_cleanup
run: |
set -euo pipefail
PKG_VER=$(python3 - <<'PY'
import email, glob, tarfile, zipfile
files = sorted(glob.glob("dist/**/*.whl", recursive=True) + glob.glob("dist/**/*.tar.gz", recursive=True))
assert files, "No distributions found in dist/"
f = files[0]
if f.endswith(".whl"):
with zipfile.ZipFile(f) as zf:
meta = [n for n in zf.namelist() if n.endswith(".dist-info/METADATA")][0]
raw = zf.read(meta).decode()
else:
with tarfile.open(f) as tf:
info = [m for m in tf.getmembers() if m.name.endswith("/PKG-INFO") or m.name == "PKG-INFO"][0]
raw = tf.extractfile(info).read().decode()
print(email.message_from_string(raw)["Version"].strip())
PY
)
echo "pkg_ver=${PKG_VER}" >> "$GITHUB_OUTPUT"
if gcloud artifacts versions describe "${PKG_VER}" \
--package="google-benchmark" \
--project="oss-exit-gate-prod" \
--location="us" \
--repository="benchmark--pypi" >/dev/null 2>&1; then
gcloud artifacts versions delete "${PKG_VER}" \
--package="google-benchmark" \
--project="oss-exit-gate-prod" \
--location="us" \
--repository="benchmark--pypi" \
--quiet
fi
- name: Stage distributions to OSS Exit Gate and upload manifest
env:
PKG_VER: ${{ steps.exit_gate_cleanup.outputs.pkg_ver }}
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
set -euo pipefail
shopt -s globstar nullglob
DIST_FILES=(dist/**/*.whl dist/**/*.tar.gz)
python3 -m pip install --upgrade twine
TWINE_PASSWORD="$(gcloud auth print-access-token)"
python3 -m twine upload \
--repository-url "https://us-python.pkg.dev/oss-exit-gate-prod/benchmark--pypi/" \
-u oauth2accesstoken \
-p "${TWINE_PASSWORD}" \
"${DIST_FILES[@]}"
cat <<EOF > manifest.json
{
"publish_all": false,
"publishing_groups": [
{
"packages": [
{
"name": "google-benchmark",
"version": "${PKG_VER}"
}
]
}
]
}
EOF
gcloud storage cp manifest.json \
"gs://oss-exit-gate-prod-projects-bucket/benchmark/pypi/manifests/manifest-${PKG_VER}-${RUN_ID}-${RUN_ATTEMPT}.json"
Loading