Skip to content

Commit b8dcb7c

Browse files
Support macOS release builds for CEL Python
- Implement release pipeline in release_macos.sh based on build_release_linux.sh - Add DRY_RUN support to release_macos.sh - Add Operating System :: MacOS to pyproject.toml classifiers PiperOrigin-RevId: 921767276
1 parent 13ff88d commit b8dcb7c

2 files changed

Lines changed: 75 additions & 3 deletions

File tree

release/kokoro/release_macos.sh

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,76 @@
11
#!/bin/bash
2-
echo "Cel-expr-python release build on MacOS"
3-
echo "TODO(b/507567432): implement release build for MacOS."
2+
set -e
43

5-
exit 0
4+
# If running locally (not on Kokoro), authenticate with gcloud.
5+
if [ -z "${KOKORO_BUILD_ID}" ]; then
6+
if ! gcloud auth application-default print-access-token --quiet > /dev/null; then
7+
gcloud auth application-default login
8+
fi
9+
fi
10+
11+
pip install -U keyring keyrings.google-artifactregistry-auth twine cibuildwheel
12+
13+
REPO_DIR=$(mktemp -d)
14+
echo "Created temporary directory: ${REPO_DIR}"
15+
16+
# Ensure the temporary directory is removed on script exit
17+
trap 'echo "Cleaning up temporary directory: ${REPO_DIR}"; rm -rf "${REPO_DIR}"' EXIT
18+
19+
if [ "${DRY_RUN}" = "true" ]; then
20+
echo "[DRY RUN] Using local Kokoro clone instead of cloning main."
21+
SRC_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
22+
pushd "${SRC_DIR}"
23+
# Get the latest tag or fallback
24+
VERSION=$(git tag --sort=-v:refname 2>/dev/null | head -n 1 || true)
25+
if [ -z "${VERSION}" ]; then
26+
VERSION="0.1.2"
27+
fi
28+
popd
29+
else
30+
pushd "${REPO_DIR}"
31+
git clone https://github.com/cel-expr/cel-python.git
32+
cd cel-python
33+
# Get the latest version tag
34+
VERSION=$(git tag --sort=-v:refname | head -n 1)
35+
SRC_DIR="${REPO_DIR}/cel-python"
36+
popd
37+
fi
38+
39+
# Strip initial "v" if present
40+
VERSION=${VERSION#v}
41+
echo "Building release for version: ${VERSION}"
42+
43+
TMP_DIR=$(mktemp -d)
44+
echo "Build directory: ${TMP_DIR}"
45+
46+
# Add trap cleanup for TMP_DIR as well
47+
trap 'echo "Cleaning up temporary directories: ${REPO_DIR} ${TMP_DIR}"; rm -rf "${REPO_DIR}" "${TMP_DIR}"' EXIT
48+
49+
pushd "${TMP_DIR}"
50+
51+
cp -r "${SRC_DIR}"/{*,.*} . 2>/dev/null || true
52+
cp "${SRC_DIR}"/release/* . 2>/dev/null || true
53+
rm -rf cel_expr_python/*_test.py
54+
55+
# Check if pyproject.toml exists before running sed
56+
if [ -f pyproject.toml ]; then
57+
sed -i "" "s/\$VERSION/${VERSION}/g" pyproject.toml || sed -i "s/\$VERSION/${VERSION}/g" pyproject.toml
58+
fi
59+
60+
echo "Running cibuildwheel: ${CIBWHEEL_BIN}"
61+
# Default CIBWHEEL_BIN if not set
62+
if [ -z "${CIBWHEEL_BIN}" ]; then
63+
CIBWHEEL_BIN="python3 -m cibuildwheel"
64+
fi
65+
${CIBWHEEL_BIN} --platform macos --output-dir dist
66+
67+
if [ "${DRY_RUN}" = "true" ]; then
68+
echo "[DRY RUN] Skipping upload to PyPI exit gate."
69+
else
70+
echo "Uploading to OSS Exit Gate for autopush to PyPI..."
71+
python3 -m twine upload --repository-url https://us-python.pkg.dev/oss-exit-gate-prod/cel-expr-python--pypi dist/*
72+
fi
73+
74+
popd
75+
76+
echo "cel-expr-python ${VERSION} built and uploaded for release by OSS Exit Gate."

release/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ classifiers = [
2323
"Topic :: Software Development :: Libraries :: Python Modules",
2424
"Operating System :: POSIX :: Linux",
2525
"Operating System :: Microsoft :: Windows",
26+
"Operating System :: MacOS",
2627
]
2728
license = "Apache-2.0"
2829
readme = "README.md"

0 commit comments

Comments
 (0)