Skip to content

Commit 189da6d

Browse files
Merge branch 'main' into main
2 parents acce802 + 49da5ba commit 189da6d

6 files changed

Lines changed: 96 additions & 20 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ bazel_dep(name = "rules_python", version = "1.9.0")
5151
single_version_override(
5252
module_name = "antlr4-cpp-runtime",
5353
patch_cmds = [
54-
"mv VERSION VERSION.txt || true",
55-
"mv version version.txt || true",
54+
"python3 -c \"import os; [os.rename(f, f + '.txt') for f in ['VERSION', 'version'] if os.path.exists(f)]\" || python -c \"import os; [os.rename(f, f + '.txt') for f in ['VERSION', 'version'] if os.path.exists(f)]\"",
5655
],
5756
)
5857

release/kokoro/presubmit_windows.bat

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ setlocal enabledelayedexpansion
1919

2020
set "IN_PRESUBMIT=1"
2121
set "PRESUBMIT_STATUS=0"
22+
set "FETCH_RETRIES=10"
23+
set "FETCH_RETRY_DELAY_S=10"
2224
if "%PYTHON_VERSIONS%" == "" (
2325
set "PYTHON_VERSIONS=3.11"
2426
)
@@ -53,18 +55,18 @@ for %%V in (%PYTHON_VERSIONS%) do (
5355
set ATTEMPTS=0
5456
:fetch_loop
5557
set /a ATTEMPTS+=1
56-
echo Fetch attempt !ATTEMPTS! of %FETCH_RETRIES%...
58+
echo Fetch attempt !ATTEMPTS! of !FETCH_RETRIES!...
5759
bazel %STARTUP_FLAGS% fetch //... > fetch.log 2>&1
5860
set FETCH_STATUS=!ERRORLEVEL!
5961
type fetch.log
6062
if !FETCH_STATUS! NEQ 0 (
6163
findstr /i "timeout timed" fetch.log >nul
6264
if !ERRORLEVEL! EQU 0 (
63-
if !ATTEMPTS! LSS %FETCH_RETRIES% (
64-
echo Fetch failed with timeout. Retrying in %FETCH_RETRY_DELAY_S% seconds...
65+
if !ATTEMPTS! LSS !FETCH_RETRIES! (
66+
echo Fetch failed with timeout. Retrying in !FETCH_RETRY_DELAY_S! seconds...
6567
:: Use ping instead of timeout because timeout command fails in non-interactive Kokoro environments
6668
:: with "ERROR: Input redirection is not supported, exiting the process immediately."
67-
set /a PINGS=%FETCH_RETRY_DELAY_S%+1
69+
set /a PINGS=!FETCH_RETRY_DELAY_S!+1
6870
ping -n !PINGS! 127.0.0.1 >nul
6971
goto fetch_loop
7072
)

release/kokoro/release_linux.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# proto-file: //devtools/kokoro/config/proto/build.proto
2+
# proto-message: BuildConfig
3+
4+
build_file: "cel-python/release/kokoro/release_linux.sh"
5+
timeout_mins: 120

release/kokoro/release_linux.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
set -e
3+
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 -r "${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 linux --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/kokoro/release_windows.bat

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@
1313
:: limitations under the License.
1414
::
1515
setlocal enabledelayedexpansion
16-
:: release_windows.bat
17-
:: Kokoro entrypoint for Windows Release builds.
16+
set "RELEASE_STATUS=0"
17+
set "FETCH_RETRIES=10"
18+
set "FETCH_RETRY_DELAY_S=10"
1819

1920
echo === Loading Environment Configuration ===
2021
call "%~dp0set_env_windows.bat"
2122
if !ERRORLEVEL! NEQ 0 (
2223
echo Failed to configure build environment!
2324
exit /b 1
2425
)
25-
26-
set "RELEASE_STATUS=0"
27-
2826
:: If running locally (not on Kokoro), authenticate with gcloud.
2927
if "%KOKORO_BUILD_ID%" == "" (
3028
gcloud auth application-default print-access-token --quiet >nul 2>&1
@@ -126,18 +124,18 @@ echo --- Pre-fetching Dependencies ---
126124
set ATTEMPTS=0
127125
:fetch_loop
128126
set /a ATTEMPTS+=1
129-
echo Fetch attempt !ATTEMPTS! of %FETCH_RETRIES%...
127+
echo Fetch attempt !ATTEMPTS! of !FETCH_RETRIES!...
130128
bazel %STARTUP_FLAGS% fetch //... > fetch.log 2>&1
131129
set FETCH_STATUS=!ERRORLEVEL!
132130
type fetch.log
133131
if !FETCH_STATUS! NEQ 0 (
134132
findstr /i "timeout timed" fetch.log >nul
135133
if !ERRORLEVEL! EQU 0 (
136-
if !ATTEMPTS! LSS %FETCH_RETRIES% (
137-
echo Fetch failed with timeout. Retrying in %FETCH_RETRY_DELAY_S% seconds...
134+
if !ATTEMPTS! LSS !FETCH_RETRIES! (
135+
echo Fetch failed with timeout. Retrying in !FETCH_RETRY_DELAY_S! seconds...
138136
:: Use ping instead of timeout because timeout command fails in non-interactive Kokoro environments
139137
:: with "ERROR: Input redirection is not supported, exiting the process immediately."
140-
set /a PINGS=%FETCH_RETRY_DELAY_S%+1
138+
set /a PINGS=!FETCH_RETRY_DELAY_S!+1
141139
ping -n !PINGS! 127.0.0.1 >nul
142140
goto fetch_loop
143141
)

release/kokoro/set_env_windows.bat

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ echo BAZEL_SH set to %BAZEL_SH%
3434
:: Configure a very short Bazel output user root to completely bypass the Windows 260-character path length limit (MAX_PATH)
3535
set "STARTUP_FLAGS=--output_user_root=C:/tmp"
3636

37-
:: Configure retry parameters for Bazel fetch to absorb transient download timeouts
38-
set "FETCH_RETRIES=10"
39-
set "FETCH_RETRY_DELAY_S=10"
40-
4137
echo --- Bazel Version ---
4238
bazel %STARTUP_FLAGS% version
4339

@@ -53,7 +49,7 @@ echo Python Version Selected: %PYTHON_VERSION%
5349
:: Detect Python executable first (needed for downloading BCR assets dynamically)
5450
set PYTHON_EXE=python
5551
where python%PYTHON_VERSION% >nul 2>&1
56-
if !ERRORLEVEL! EQU 0 (
52+
if %ERRORLEVEL% EQU 0 (
5753
set PYTHON_EXE=python%PYTHON_VERSION%
5854
) else if exist C:\Python%PY_VER_NO_DOT%\python.exe (
5955
set PYTHON_EXE=C:\Python%PY_VER_NO_DOT%\python.exe

0 commit comments

Comments
 (0)