Skip to content

Commit 5fe4cac

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 5fe4cac

2 files changed

Lines changed: 83 additions & 3 deletions

File tree

release/kokoro/release_macos.sh

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,84 @@
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+
echo "Installing CPython Mac Frameworks..."
14+
for pyver in "3.11.9" "3.12.4" "3.13.0"; do
15+
echo "Downloading and installing Python ${pyver}..."
16+
curl -LO "https://www.python.org/ftp/python/${pyver}/python-${pyver}-macos11.pkg"
17+
sudo installer -pkg "python-${pyver}-macos11.pkg" -target /
18+
rm "python-${pyver}-macos11.pkg"
19+
done
20+
21+
REPO_DIR=$(mktemp -d)
22+
echo "Created temporary directory: ${REPO_DIR}"
23+
24+
# Ensure the temporary directory is removed on script exit
25+
trap 'echo "Cleaning up temporary directory: ${REPO_DIR}"; rm -rf "${REPO_DIR}"' EXIT
26+
27+
if [ "${DRY_RUN}" = "true" ]; then
28+
echo "[DRY RUN] Using local Kokoro clone instead of cloning main."
29+
SRC_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
30+
pushd "${SRC_DIR}"
31+
# Get the latest tag or fallback
32+
VERSION=$(git tag --sort=-v:refname 2>/dev/null | head -n 1 || true)
33+
if [ -z "${VERSION}" ]; then
34+
VERSION="0.1.2"
35+
fi
36+
popd
37+
else
38+
pushd "${REPO_DIR}"
39+
git clone https://github.com/cel-expr/cel-python.git
40+
cd cel-python
41+
# Get the latest version tag
42+
VERSION=$(git tag --sort=-v:refname | head -n 1)
43+
SRC_DIR="${REPO_DIR}/cel-python"
44+
popd
45+
fi
46+
47+
# Strip initial "v" if present
48+
VERSION=${VERSION#v}
49+
echo "Building release for version: ${VERSION}"
50+
51+
TMP_DIR=$(mktemp -d)
52+
echo "Build directory: ${TMP_DIR}"
53+
54+
# Add trap cleanup for TMP_DIR as well
55+
trap 'echo "Cleaning up temporary directories: ${REPO_DIR} ${TMP_DIR}"; rm -rf "${REPO_DIR}" "${TMP_DIR}"' EXIT
56+
57+
pushd "${TMP_DIR}"
58+
59+
cp -r "${SRC_DIR}"/{*,.*} . 2>/dev/null || true
60+
cp "${SRC_DIR}"/release/* . 2>/dev/null || true
61+
rm -rf cel_expr_python/*_test.py
62+
63+
# Check if pyproject.toml exists before running sed
64+
if [ -f pyproject.toml ]; then
65+
sed -i "" "s/\$VERSION/${VERSION}/g" pyproject.toml || sed -i "s/\$VERSION/${VERSION}/g" pyproject.toml
66+
fi
67+
68+
echo "Running cibuildwheel: ${CIBWHEEL_BIN}"
69+
# Default CIBWHEEL_BIN if not set
70+
if [ -z "${CIBWHEEL_BIN}" ]; then
71+
CIBWHEEL_BIN="python3 -m cibuildwheel"
72+
fi
73+
${CIBWHEEL_BIN} --platform macos --output-dir dist
74+
75+
if [ "${DRY_RUN}" = "true" ]; then
76+
echo "[DRY RUN] Skipping upload to PyPI exit gate."
77+
else
78+
echo "Uploading to OSS Exit Gate for autopush to PyPI..."
79+
python3 -m twine upload --repository-url https://us-python.pkg.dev/oss-exit-gate-prod/cel-expr-python--pypi dist/*
80+
fi
81+
82+
popd
83+
84+
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)