Skip to content

Commit ff64f28

Browse files
authored
Merge pull request #466 from AgoraIO/dev/4.6.3
Dev/4.6.3
2 parents 39fff8b + d9c4530 commit ff64f28

File tree

46 files changed

+1078
-407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1078
-407
lines changed

.git-hooks/install-hooks.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ else
5353
print_green "pre-commit is already installed!"
5454
fi
5555

56-
# Check if gitleaks is installed
56+
# Check if gitleaks is installed (required)
5757
if ! command -v gitleaks &> /dev/null; then
58-
print_yellow "gitleaks not found, please install it..."
58+
print_red "gitleaks not found - this is a required security tool!"
5959
print_yellow "Installation guide: https://github.com/gitleaks/gitleaks#installing"
6060

6161
# Attempt automatic installation (based on OS)
@@ -77,6 +77,8 @@ if ! command -v gitleaks &> /dev/null; then
7777
print_red "Please install gitleaks manually and try again"
7878
exit 1
7979
fi
80+
else
81+
print_green "gitleaks is installed!"
8082
fi
8183

8284
# Check required files and directories

.git-hooks/post-commit

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
# Check if required hooks are installed
44
if [ ! -f ".git/hooks/commit-msg" ] || [ ! -x ".git/hooks/commit-msg" ]; then
55
echo "============================================================"
6-
echo "Note: Git hooks for checking Chinese characters in commit messages are not installed."
6+
echo "⚠️ Note: Git hooks for checking commit messages are not installed."
77
echo "Please run the following commands to install:"
88
echo ""
99
echo " 1. Install pre-commit:"
1010
echo " pip install pre-commit"
1111
echo ""
12-
echo " 2. Install pre-commit hook:"
13-
echo " pre-commit install"
12+
echo " 2. Install hooks:"
13+
echo " .git-hooks/install-hooks.sh"
1414
echo ""
15-
echo " 3. Install commit-msg hook:"
16-
echo " pre-commit install --hook-type commit-msg"
17-
echo " cp .git-hooks/check-commit-message.sh .git/hooks/commit-msg"
18-
echo " chmod +x .git/hooks/commit-msg"
19-
echo ""
20-
echo "These hooks will help detect sensitive information leaks and Chinese characters in commit messages."
15+
echo "These hooks will help detect sensitive information leaks and"
16+
echo "Chinese characters in commit messages."
2117
echo "============================================================"
2218
fi
2319

.git-hooks/pre-commit

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
# Check if gitleaks is configured
44
if ! command -v gitleaks &> /dev/null; then
55
echo "============================================================"
6-
echo "Gitleaks not detected. This is a required tool to prevent sensitive information leaks."
7-
echo "Please install gitleaks first: https://github.com/gitleaks/gitleaks#installing"
6+
echo "❌ ERROR: Gitleaks not detected."
7+
echo "This is a required tool to prevent sensitive information leaks."
8+
echo ""
9+
echo "Please install gitleaks first:"
10+
echo " macOS: brew install gitleaks"
11+
echo " Other: https://github.com/gitleaks/gitleaks#installing"
12+
echo ""
813
echo "After installation, run: ./.git-hooks/install-hooks.sh"
914
echo "============================================================"
1015
exit 1
@@ -14,12 +19,12 @@ fi
1419
if [ -f ".gitleaks.toml" ]; then
1520
gitleaks detect --source . --config .gitleaks.toml
1621
if [ $? -ne 0 ]; then
17-
echo "Gitleaks detected sensitive information. Commit rejected."
22+
echo "Gitleaks detected sensitive information. Commit rejected."
1823
echo "Please review the output above and remove sensitive information."
1924
exit 1
2025
fi
2126
else
22-
echo "No .gitleaks.toml configuration file found, skipping sensitive information check."
27+
echo "⚠️ No .gitleaks.toml configuration file found, skipping sensitive information check."
2328
fi
2429

2530
exit 0

.git-hooks/run-gitleaks.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Try to find gitleaks in common locations
4+
GITLEAKS_CMD=""
5+
6+
# Check if gitleaks is in PATH
7+
if command -v gitleaks &> /dev/null; then
8+
GITLEAKS_CMD="gitleaks"
9+
# Check Homebrew locations (Intel Mac)
10+
elif [ -f "/usr/local/bin/gitleaks" ]; then
11+
GITLEAKS_CMD="/usr/local/bin/gitleaks"
12+
# Check Homebrew locations (Apple Silicon Mac)
13+
elif [ -f "/opt/homebrew/bin/gitleaks" ]; then
14+
GITLEAKS_CMD="/opt/homebrew/bin/gitleaks"
15+
# Check if installed via other package managers
16+
elif [ -f "$HOME/.local/bin/gitleaks" ]; then
17+
GITLEAKS_CMD="$HOME/.local/bin/gitleaks"
18+
fi
19+
20+
# If gitleaks not found, exit with error
21+
if [ -z "$GITLEAKS_CMD" ]; then
22+
echo "============================================================"
23+
echo "❌ ERROR: gitleaks not found!"
24+
echo ""
25+
echo "Please install gitleaks:"
26+
echo " macOS: brew install gitleaks"
27+
echo " Linux: https://github.com/gitleaks/gitleaks#installing"
28+
echo ""
29+
echo "After installation, run: ./.git-hooks/install-hooks.sh"
30+
echo "============================================================"
31+
exit 1
32+
fi
33+
34+
# Run gitleaks with provided arguments
35+
exec "$GITLEAKS_CMD" "$@"

.github/ci/build/build_android.sh

Lines changed: 157 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
##################################
4040
export PATH=$PATH:/opt/homebrew/bin
4141

42+
# Record build start time
43+
START_TIME=$(date +%s)
44+
echo "=========================================="
45+
echo "Build started at: $(date '+%Y-%m-%d %H:%M:%S')"
46+
echo "=========================================="
47+
echo ""
48+
4249
echo Package_Publish: $Package_Publish
4350
echo is_tag_fetch: $is_tag_fetch
4451
echo arch: $arch
@@ -48,23 +55,114 @@ echo build_date: $build_date
4855
echo build_time: $build_time
4956
echo release_version: $release_version
5057
echo short_version: $short_version
58+
echo BUILD_NUMBER: $BUILD_NUMBER
5159
echo pwd: `pwd`
5260
echo sdk_url: $sdk_url
5361
echo android_direction: $android_direction
62+
echo compile_project: $compile_project
63+
echo compress_apiexample: $compress_apiexample
64+
echo api_examples_branch: $api_examples_branch
65+
66+
# ===== Version Consistency Check =====
67+
echo ""
68+
echo "=========================================="
69+
echo "Checking version consistency..."
70+
echo "=========================================="
71+
72+
# Read version from gradle.properties based on android_direction
73+
GRADLE_FILE="Android/${android_direction}/gradle.properties"
74+
75+
if [ ! -f "$GRADLE_FILE" ]; then
76+
echo ""
77+
echo "=========================================="
78+
echo "❌ CI BUILD FAILED: GRADLE FILE NOT FOUND"
79+
echo "=========================================="
80+
echo "Cannot find: $GRADLE_FILE"
81+
echo "=========================================="
82+
exit 1
83+
fi
84+
85+
SDK_VERSION=$(grep "rtc_sdk_version" "$GRADLE_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
86+
echo "Using version from $GRADLE_FILE: $SDK_VERSION"
87+
88+
if [ -z "$SDK_VERSION" ]; then
89+
echo ""
90+
echo "=========================================="
91+
echo "❌ CI BUILD FAILED: CANNOT EXTRACT VERSION"
92+
echo "=========================================="
93+
echo "Cannot extract rtc_sdk_version from $GRADLE_FILE"
94+
echo "Please ensure rtc_sdk_version is set in gradle.properties"
95+
echo "=========================================="
96+
exit 1
97+
fi
98+
99+
echo ""
100+
101+
# Skip version check for main branch (we trust main when building from it)
102+
api_examples_branch_stripped=$(echo "$api_examples_branch" | sed 's|^origin/||')
103+
if [ "$api_examples_branch_stripped" = "main" ]; then
104+
echo "Branch is main, skipping version consistency check (main branch is trusted)"
105+
echo "Using version: $SDK_VERSION"
106+
else
107+
# Extract version number from branch name (supports formats like dev/4.6.2, release/4.6.2, etc.)
108+
BRANCH_NAME_VERSION=$(echo $api_examples_branch | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)
109+
110+
if [ -z "$BRANCH_NAME_VERSION" ]; then
111+
echo ""
112+
echo "=========================================="
113+
echo "❌ CI BUILD FAILED: CANNOT EXTRACT VERSION FROM BRANCH"
114+
echo "=========================================="
115+
echo "Cannot extract version from branch name: $api_examples_branch"
116+
echo "Branch name must contain version number (e.g., dev/4.6.2, release/4.6.2)"
117+
echo "=========================================="
118+
exit 1
119+
fi
120+
121+
echo "Branch name version: $BRANCH_NAME_VERSION"
122+
echo ""
123+
124+
# Check gradle.properties for consistency with branch name
125+
GRADLE_VERSION=$(grep "rtc_sdk_version" "$GRADLE_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
126+
echo "Checking $GRADLE_FILE: $GRADLE_VERSION"
127+
128+
if [ "$GRADLE_VERSION" != "$BRANCH_NAME_VERSION" ]; then
129+
echo ""
130+
echo "=========================================="
131+
echo "❌ CI BUILD FAILED: VERSION MISMATCH"
132+
echo "=========================================="
133+
echo "Branch name contains version: $BRANCH_NAME_VERSION"
134+
echo "But $GRADLE_FILE has version: $GRADLE_VERSION"
135+
echo ""
136+
echo "Please update rtc_sdk_version in $GRADLE_FILE to: $BRANCH_NAME_VERSION"
137+
echo "=========================================="
138+
exit 1
139+
fi
140+
141+
echo "✅ Version check passed: $GRADLE_VERSION"
142+
fi
143+
echo "=========================================="
144+
echo ""
54145

55146
unzip_name=Agora_Native_SDK_for_Android_FULL_DEFAULT
56147
zip_name=Agora_Native_SDK_for_Android_FULL_DEFAULT.zip
57148
if [ -z "$sdk_url" ] || [ "$sdk_url" = "none" ]; then
58-
echo "sdk_url is empty"
149+
echo "sdk_url is empty, using default SDK structure"
59150
echo unzip_name: $unzip_name
60151
echo zip_name: $zip_name
61152
else
62153
zip_name=${sdk_url##*/}
63154
echo zip_name: $zip_name
64155

156+
# Download SDK
157+
echo "Downloading SDK from: $sdk_url"
65158
# env LC_ALL=en_US.UTF-8 python3 $WORKSPACE/artifactory_utils.py --action=download_file --file=$sdk_url || exit 1
66159
curl -o $zip_name $sdk_url || exit 1
160+
echo "✅ SDK downloaded successfully"
161+
162+
# Extract SDK
163+
echo "Extracting SDK package..."
67164
7za x ./$zip_name -y > log.txt
165+
echo "✅ SDK extracted successfully"
68166

69167
# Support top-level directory name containing 'Agora' or 'Shengwang'
70168
unzip_name=`ls -S -d */ | grep -E 'Agora|Shengwang' | head -n 1 | sed 's/\///g'`
@@ -74,38 +172,89 @@ else
74172
fi
75173
echo unzip_name: $unzip_name
76174

175+
# Clean up unnecessary files
176+
echo "Cleaning up unnecessary files..."
77177
rm -rf ./$unzip_name/rtc/bin
78178
rm -rf ./$unzip_name/rtc/demo
79179
rm -f ./$unzip_name/.commits
80180
rm -f ./$unzip_name/spec
81181
rm -rf ./$unzip_name/pom
182+
echo "✅ Cleanup completed"
82183
fi
83184

84185
mkdir -p ./$unzip_name/rtc/samples/${android_direction} || exit 1
85186
rm -rf ./$unzip_name/rtc/samples/${android_direction}/*
86187

188+
echo ""
189+
echo "Copying API Example code from ./Android/${android_direction}..."
87190
if [ -d "./Android/${android_direction}" ]; then
88191
cp -rf ./Android/${android_direction}/* ./$unzip_name/rtc/samples/${android_direction}/ || exit 1
192+
echo "✅ API Example code copied successfully"
89193
else
90194
echo "Error: Source directory ./Android/${android_direction} does not exist"
91195
exit 1
92196
fi
197+
echo ""
93198

94-
7za a -tzip result.zip -r $unzip_name > log.txt
95-
mv result.zip $WORKSPACE/withAPIExample_${BUILD_NUMBER}_$zip_name
96-
97-
if [ $compress_apiexample = true ]; then
98-
onlyCodeZipName=${android_direction}_onlyCode.zip
99-
7za a -tzip $onlyCodeZipName -r ./$unzip_name/rtc/samples/${android_direction} >> log.txt
100-
mv $onlyCodeZipName $WORKSPACE/APIExample_onlyCode_${BUILD_NUMBER}_$zip_name
199+
if [ "$compress_apiexample" = true ]; then
200+
# Compress only API Example code (without SDK)
201+
echo "Creating code-only package..."
202+
TEMP_ZIP_NAME="temp_code_only.zip"
203+
7za a -tzip $TEMP_ZIP_NAME -r ./$unzip_name/rtc/samples/${android_direction} > log.txt
204+
echo "✅ Code-only package created"
205+
206+
# Generate final output zip name with version
207+
OUTPUT_ZIP_NAME="Agora_Native_SDK_for_Android_v${SDK_VERSION}_${android_direction}_${BUILD_NUMBER}.zip"
208+
echo "Output zip name: $OUTPUT_ZIP_NAME"
209+
mv $TEMP_ZIP_NAME $WORKSPACE/$OUTPUT_ZIP_NAME
210+
211+
# Display package size
212+
echo "Package size: $(du -h $WORKSPACE/$OUTPUT_ZIP_NAME | cut -f1)"
213+
else
214+
# Compress full SDK with API Example
215+
echo "Creating full package with SDK..."
216+
TEMP_ZIP_NAME="temp_with_sdk.zip"
217+
7za a -tzip $TEMP_ZIP_NAME -r $unzip_name > log.txt
218+
echo "✅ Full package created"
219+
220+
# Generate final output zip name with version (with SDK)
221+
OUTPUT_ZIP_NAME="withSDK_Agora_Native_SDK_for_Android_v${SDK_VERSION}_${android_direction}_${BUILD_NUMBER}.zip"
222+
echo "Output zip name: $OUTPUT_ZIP_NAME"
223+
mv $TEMP_ZIP_NAME $WORKSPACE/$OUTPUT_ZIP_NAME
224+
225+
# Display package size
226+
echo "Package size: $(du -h $WORKSPACE/$OUTPUT_ZIP_NAME | cut -f1)"
101227
fi
228+
echo ""
102229

103230
if [ $compile_project = true ]; then
231+
echo "Starting project compilation..."
104232
cd ./$unzip_name/rtc/samples/${android_direction} || exit 1
105233
if [ -z "$sdk_url" ] || [ "$sdk_url" = "none" ]; then
106234
./cloud_build.sh false || exit 1
107235
else
108236
./cloud_build.sh true || exit 1
109237
fi
238+
echo "✅ Project compiled successfully"
239+
echo ""
240+
fi
241+
242+
# Calculate and display build duration
243+
END_TIME=$(date +%s)
244+
DURATION=$((END_TIME - START_TIME))
245+
MINUTES=$((DURATION / 60))
246+
SECONDS=$((DURATION % 60))
247+
248+
echo ""
249+
echo "=========================================="
250+
echo "✅ BUILD COMPLETED SUCCESSFULLY"
251+
echo "=========================================="
252+
echo "Completed at: $(date '+%Y-%m-%d %H:%M:%S')"
253+
if [ $MINUTES -gt 0 ]; then
254+
echo "Total duration: ${MINUTES}m ${SECONDS}s"
255+
else
256+
echo "Total duration: ${SECONDS}s"
110257
fi
258+
echo "Output package: $OUTPUT_ZIP_NAME"
259+
echo "=========================================="
111260

0 commit comments

Comments
 (0)