Skip to content

Commit 6895798

Browse files
HHHHexHeZhengQing
andauthored
Dev/4.6.3 (#467)
* Update CI * mock sdk version * modify sdk version * Update podfile * [FIX] windows version --------- Co-authored-by: qinhui <> Co-authored-by: HeZhengQing <hezhengqing@agora.io>
1 parent ff64f28 commit 6895798

File tree

4 files changed

+273
-350
lines changed

4 files changed

+273
-350
lines changed

.github/ci/build/build_ios.sh

Lines changed: 17 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -67,174 +67,26 @@ apiexample_cn_name=Shengwang_Native_SDK_for_iOS
6767
apiexample_global_name=Agora_Native_SDK_for_iOS
6868
global_dir=Global
6969

70-
# ===================================
71-
# Version Validation Functions
72-
# ===================================
70+
# Source common functions
71+
source "$(dirname "$0")/common_functions.sh"
7372

74-
# Function: Get current branch name from various sources
75-
get_branch_name() {
76-
local branch_name=""
77-
78-
# Method 1: Try environment variable (Jenkins/GitLab CI)
79-
if [ ! -z "$GIT_BRANCH" ]; then
80-
branch_name="$GIT_BRANCH"
81-
echo "Branch from GIT_BRANCH: $branch_name" >&2
82-
elif [ ! -z "$BRANCH_NAME" ]; then
83-
branch_name="$BRANCH_NAME"
84-
echo "Branch from BRANCH_NAME: $branch_name" >&2
85-
elif [ ! -z "$CI_COMMIT_REF_NAME" ]; then
86-
branch_name="$CI_COMMIT_REF_NAME"
87-
echo "Branch from CI_COMMIT_REF_NAME: $branch_name" >&2
88-
# Method 2: Try git command
89-
else
90-
branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
91-
if [ "$branch_name" = "HEAD" ]; then
92-
# In detached HEAD state, try to get branch from remote
93-
branch_name=$(git branch -r --contains HEAD | grep -v HEAD | head -1 | sed 's/^[[:space:]]*origin\///')
94-
echo "Branch from git branch -r: $branch_name" >&2
95-
else
96-
echo "Branch from git rev-parse: $branch_name" >&2
97-
fi
98-
fi
99-
100-
# Remove origin/ prefix if present (but keep the rest of the path)
101-
branch_name=$(echo "$branch_name" | sed 's/^origin\///')
102-
103-
echo "$branch_name"
104-
}
105-
106-
# Function: Validate project MARKETING_VERSION against branch version
107-
validate_project_version() {
108-
local project_path="$1"
109-
local project_name="$2"
110-
local branch_version="$3"
111-
112-
echo "-----------------------------------"
113-
echo "Validating project version: $project_path"
114-
115-
local pbxproj_file="${project_path}/${project_name}.xcodeproj/project.pbxproj"
116-
117-
if [ ! -f "$pbxproj_file" ]; then
118-
echo "Error: project.pbxproj file not found: $pbxproj_file"
119-
return 1
120-
fi
121-
122-
# Extract MARKETING_VERSION for main target (skip Extension targets)
123-
local plist_version=$(grep -A 2 "@executable_path/Frameworks" "$pbxproj_file" | grep "MARKETING_VERSION" | head -1 | sed 's/.*MARKETING_VERSION = \([^;]*\);/\1/' | tr -d ' ')
124-
125-
if [ -z "$plist_version" ]; then
126-
echo "Error: Unable to read MARKETING_VERSION from project.pbxproj"
127-
return 1
128-
fi
129-
130-
echo "Project version: $plist_version"
131-
132-
# Compare versions
133-
if [ "$branch_version" != "$plist_version" ]; then
134-
echo ""
135-
echo "=========================================="
136-
echo "Error: Version mismatch!"
137-
echo "=========================================="
138-
echo " Branch version: $branch_version"
139-
echo " Project version: $plist_version"
140-
echo " Project path: $project_path"
141-
echo ""
142-
echo "Please ensure the version in branch name matches MARKETING_VERSION in Info.plist"
143-
echo ""
144-
return 1
145-
fi
146-
147-
echo "✓ Project version matches: $plist_version"
148-
return 0
149-
}
73+
# Run version validation
74+
run_version_validation "iOS/${ios_direction}" "${ios_direction}" "ios" || exit 1
15075

151-
# Function: Validate SDK version in Podfile against branch version
152-
validate_sdk_version() {
153-
local podfile_path="$1"
154-
local branch_version="$2"
155-
156-
echo "-----------------------------------"
157-
echo "Validating SDK version: $podfile_path"
158-
159-
# Extract SDK version from Podfile (support both AgoraRtcEngine_iOS and AgoraAudio_iOS)
160-
# Also support commented lines (lines starting with #)
161-
local sdk_version=$(grep -E "^[[:space:]]*#?[[:space:]]*pod[[:space:]]+'AgoraRtcEngine_iOS'" "$podfile_path" | sed -n "s/.*'\([0-9.]*\)'.*/\1/p" | head -1)
162-
if [ -z "$sdk_version" ]; then
163-
sdk_version=$(grep -E "^[[:space:]]*#?[[:space:]]*pod[[:space:]]+'AgoraAudio_iOS'" "$podfile_path" | sed -n "s/.*'\([0-9.]*\)'.*/\1/p" | head -1)
76+
# Validate SDK version in Podfile (skip only for main branch)
77+
if [ "$BRANCH_NAME" != "main" ]; then
78+
if [ -z "$BRANCH_VERSION" ]; then
79+
echo "Error: BRANCH_VERSION is not set, cannot validate SDK version"
80+
exit 1
16481
fi
16582

166-
if [ -z "$sdk_version" ]; then
167-
echo "Error: Unable to extract SDK version from Podfile"
168-
echo "Podfile path: $podfile_path"
169-
return 1
170-
fi
171-
172-
echo "SDK version: $sdk_version"
173-
174-
# Compare versions
175-
if [ "$branch_version" != "$sdk_version" ]; then
176-
echo ""
177-
echo "=========================================="
178-
echo "Error: SDK version mismatch!"
179-
echo "=========================================="
180-
echo " Branch version: $branch_version"
181-
echo " SDK version: $sdk_version"
182-
echo " Podfile path: $podfile_path"
183-
echo ""
184-
echo "Please ensure the SDK version in Podfile matches the branch version."
185-
echo ""
186-
return 1
187-
fi
188-
189-
echo "✓ SDK version matches: $sdk_version"
190-
return 0
191-
}
192-
193-
# Main version validation logic
194-
echo "=========================================="
195-
echo "Starting branch version validation..."
196-
echo "=========================================="
197-
198-
BRANCH_NAME=$(get_branch_name)
199-
200-
if [ -z "$BRANCH_NAME" ] || [ "$BRANCH_NAME" = "HEAD" ]; then
201-
echo "Warning: Unable to get Git branch name, skipping version validation"
202-
BRANCH_VERSION=""
203-
else
204-
echo "Current branch: $BRANCH_NAME"
205-
206-
# Extract version from branch name (format: dev/x.x.x)
207-
if [[ $BRANCH_NAME =~ ^dev/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
208-
BRANCH_VERSION="${BASH_REMATCH[1]}"
209-
echo "Branch version: $BRANCH_VERSION"
210-
echo "Current building project: $ios_direction"
211-
echo ""
212-
213-
# Validate project version
214-
PROJECT_PATH="iOS/${ios_direction}"
215-
PROJECT_NAME="${ios_direction}"
216-
217-
if ! validate_project_version "$PROJECT_PATH" "$PROJECT_NAME" "$BRANCH_VERSION"; then
218-
exit 1
219-
fi
220-
221-
echo "-----------------------------------"
222-
echo "✓ All version validations passed: $BRANCH_VERSION"
223-
else
224-
echo "Warning: Branch name does not match dev/x.x.x format!"
225-
echo "Current branch: $BRANCH_NAME"
226-
echo "Expected format: dev/x.x.x (e.g., dev/4.6.2)"
227-
echo "Skipping version validation for non-version branches..."
228-
BRANCH_VERSION=""
229-
fi
83+
echo "=========================================="
84+
echo "Validating SDK version in Podfile..."
85+
echo "=========================================="
86+
validate_sdk_version "./iOS/${ios_direction}/Podfile" "$BRANCH_VERSION" "ios" || exit 1
87+
echo ""
23088
fi
23189

232-
echo "Version validation completed"
233-
echo "=========================================="
234-
echo ""
235-
236-
237-
23890
if [ -z "$sdk_url" -o "$sdk_url" = "none" ]; then
23991
sdk_url_flag=false
24092
echo "sdk_url is empty"
@@ -274,22 +126,9 @@ echo $WORKSPACE/with${ios_direction}_${BUILD_NUMBER}_$zip_name
274126
mv result.zip $WORKSPACE/with${ios_direction}_${BUILD_NUMBER}_$zip_name
275127

276128
if [ $compress_apiexample = true ]; then
277-
# Extract SDK version from Podfile (support both AgoraRtcEngine_iOS and AgoraAudio_iOS)
278-
# Also support commented lines
279-
sdk_version=$(grep -E "^[[:space:]]*#?[[:space:]]*pod[[:space:]]+'AgoraRtcEngine_iOS'" ./iOS/${ios_direction}/Podfile | sed -n "s/.*'\([0-9.]*\)'.*/\1/p" | head -1)
280-
if [ -z "$sdk_version" ]; then
281-
sdk_version=$(grep -E "^[[:space:]]*#?[[:space:]]*pod[[:space:]]+'AgoraAudio_iOS'" ./iOS/${ios_direction}/Podfile | sed -n "s/.*'\([0-9.]*\)'.*/\1/p" | head -1)
282-
fi
283-
echo "sdk_version: $sdk_version"
284-
285-
# Validate SDK version matches branch version (if on dev/x.x.x branch)
286-
if [ ! -z "$BRANCH_VERSION" ]; then
287-
if ! validate_sdk_version "./iOS/${ios_direction}/Podfile" "$BRANCH_VERSION"; then
288-
exit 1
289-
fi
290-
else
291-
echo "Skipping SDK version validation (not on dev/x.x.x branch)"
292-
fi
129+
# Use BRANCH_VERSION for the package name (already validated to match SDK version)
130+
sdk_version="${BRANCH_VERSION}"
131+
echo "Using version for package: $sdk_version"
293132

294133
cp -rf ./iOS/${ios_direction} $global_dir/
295134

0 commit comments

Comments
 (0)