Skip to content

Commit 027b414

Browse files
committed
feat: add update dep support
1 parent bd5129e commit 027b414

File tree

3 files changed

+167
-3
lines changed

3 files changed

+167
-3
lines changed

.github/ci/build/dep.sh

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#!/bin/bash
2+
set -e
3+
set +x
4+
MY_PATH=$(realpath $(dirname "$0"))
5+
PROJECT_ROOT=$(realpath ${MY_PATH}/../../..)
6+
URL_JSON_PATH="${PROJECT_ROOT}/Agora-Unreal-SDK-CPP/AgoraPlugin/Resources/url.json"
7+
8+
if [ "$#" -lt 1 ]; then
9+
echo "Usage: $0 <json_input>"
10+
exit 1
11+
fi
12+
INPUT=$1
13+
14+
IOS_DEPENDENCIES=$(echo "$INPUT" | jq -r '.[] | select(.platform == "iOS") | .cdn[]')
15+
MAC_DEPENDENCIES=$(echo "$INPUT" | jq -r '.[] | select(.platform == "macOS") | .cdn[]')
16+
ANDROID_DEPENDENCIES=$(echo "$INPUT" | jq -r '.[] | select(.platform == "Android") | .cdn[]')
17+
WINDOWS_DEPENDENCIES=$(echo "$INPUT" | jq -r '.[] | select(.platform == "Windows") | .cdn[]')
18+
19+
# Extract version from first platform that has a non-empty version
20+
DEP_VERSION=$(echo "$INPUT" | jq -r '.[] | select(.version != "" and .version != null) | .version' | head -n 1)
21+
echo "Detected version: $DEP_VERSION"
22+
23+
# Helper: choose first native link from cdn list
24+
choose_native_dep() {
25+
local list="$1"
26+
for DEP in $list; do
27+
echo "$DEP"; return
28+
done
29+
echo ""
30+
}
31+
32+
# Helper: update url.json using jq
33+
update_url_json() {
34+
local release_type="$1" # video | audio
35+
local platform="$2" # native_win | native_mac | native_android | native_ios
36+
local value="$3" # url value
37+
38+
[ -z "$value" ] && return 0
39+
40+
if [ ! -f "$URL_JSON_PATH" ]; then
41+
echo "url.json not found at $URL_JSON_PATH"
42+
return 1
43+
fi
44+
45+
echo "Updating .$release_type.$platform with value: $value"
46+
47+
# Update the JSON file
48+
jq --arg val "$value" ".$release_type.$platform = \$val" "$URL_JSON_PATH" > "$URL_JSON_PATH.tmp"
49+
50+
if [ $? -eq 0 ]; then
51+
mv "$URL_JSON_PATH.tmp" "$URL_JSON_PATH"
52+
echo "Successfully updated .$release_type.$platform to: $value"
53+
else
54+
echo "Failed to update .$release_type.$platform"
55+
rm -f "$URL_JSON_PATH.tmp"
56+
return 1
57+
fi
58+
}
59+
60+
# Process Windows dependencies
61+
if [ -z "$WINDOWS_DEPENDENCIES" ]; then
62+
echo "No windows native dependencies need to change."
63+
else
64+
NATIVE_WIN=$(choose_native_dep "$WINDOWS_DEPENDENCIES")
65+
if [ -n "$NATIVE_WIN" ]; then
66+
echo "Windows native dependency: $NATIVE_WIN"
67+
update_url_json video native_win "$NATIVE_WIN"
68+
update_url_json audio native_win "$NATIVE_WIN"
69+
fi
70+
fi
71+
72+
# Process macOS dependencies
73+
if [ -z "$MAC_DEPENDENCIES" ]; then
74+
echo "No mac native dependencies need to change."
75+
else
76+
NATIVE_MAC=$(choose_native_dep "$MAC_DEPENDENCIES")
77+
if [ -n "$NATIVE_MAC" ]; then
78+
echo "Mac native dependency: $NATIVE_MAC"
79+
update_url_json video native_mac "$NATIVE_MAC"
80+
update_url_json audio native_mac "$NATIVE_MAC"
81+
fi
82+
fi
83+
84+
# Process iOS dependencies
85+
if [ -z "$IOS_DEPENDENCIES" ]; then
86+
echo "No iOS native dependencies need to change."
87+
else
88+
NATIVE_IOS=$(choose_native_dep "$IOS_DEPENDENCIES")
89+
if [ -n "$NATIVE_IOS" ]; then
90+
echo "iOS native dependency: $NATIVE_IOS"
91+
update_url_json video native_ios "$NATIVE_IOS"
92+
update_url_json audio native_ios "$NATIVE_IOS"
93+
fi
94+
fi
95+
96+
# Process Android dependencies
97+
if [ -z "$ANDROID_DEPENDENCIES" ]; then
98+
echo "No Android native dependencies need to change."
99+
else
100+
NATIVE_ANDROID=$(choose_native_dep "$ANDROID_DEPENDENCIES")
101+
if [ -n "$NATIVE_ANDROID" ]; then
102+
echo "Android native dependency: $NATIVE_ANDROID"
103+
update_url_json video native_android "$NATIVE_ANDROID"
104+
update_url_json audio native_android "$NATIVE_ANDROID"
105+
fi
106+
fi
107+
108+
# Increment Build number in url.json
109+
if [ -f "$URL_JSON_PATH" ]; then
110+
echo "Incrementing Build number in url.json..."
111+
112+
# Read current build number
113+
BUILD_NUM=$(jq -r '.version.build' "$URL_JSON_PATH")
114+
115+
if [ "$BUILD_NUM" = "null" ] || [ -z "$BUILD_NUM" ]; then
116+
BUILD_NUM=0
117+
fi
118+
119+
# Increment and update
120+
NEW_BUILD_NUM=$((BUILD_NUM + 1))
121+
jq --arg build "$NEW_BUILD_NUM" '.version.build = ($build | tonumber)' "$URL_JSON_PATH" > "$URL_JSON_PATH.tmp"
122+
123+
if [ $? -eq 0 ]; then
124+
mv "$URL_JSON_PATH.tmp" "$URL_JSON_PATH"
125+
echo "Build number updated: $BUILD_NUM -> $NEW_BUILD_NUM"
126+
else
127+
echo "Failed to update build number"
128+
rm -f "$URL_JSON_PATH.tmp"
129+
fi
130+
fi
131+
132+
echo "Dependencies update completed successfully!"
133+
echo "Updated url.json at: $URL_JSON_PATH"

.github/workflows/terra.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Generate codes and create pull request
33
on:
44
workflow_dispatch:
55
inputs:
6-
rtc_version:
7-
description: 'verison (4.5.2)'
6+
dependencies-content:
7+
description: The content of dependencies
88
required: true
99
type: string
1010

@@ -21,11 +21,24 @@ jobs:
2121
- name: Setup
2222
uses: ./.github/setup
2323

24+
- name: Get dependencies
25+
id: dep
26+
uses: AgoraIO-Extensions/actions/.github/actions/dep@main
27+
with:
28+
dependencies-content: ${{ inputs.dependencies-content }}
29+
30+
- name: Update dependencies
31+
run: |
32+
sh ci/build/dep.sh ${{ steps.dep.outputs.matches }}
33+
2434
- name: Replace rtc version
2535
run: |
2636
cd Terra
2737
pip install -r requirements.txt
28-
python ASDK.py -agorasdk=${{ inputs.rtc_version }}
38+
JSON_RAW='${{ steps.dep.outputs.matches }}'
39+
JSON_OUTPUT=$(printf '%s' "$JSON_RAW" | sed 's/^"//;s/"$//' | sed 's/\\"/"/g')
40+
VERSION=$(echo "$JSON_OUTPUT" | jq -r '.[] | select(.version != "" and .version != null) | .version' | head -n 1)
41+
python ASDK.py -agorasdk="${VERSION}"
2942
3043
- name: Generate code and comment by terra
3144
uses: AgoraIO-Extensions/actions/.github/actions/generate@main
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version":{
3+
"build": 0
4+
},
5+
"video":{
6+
"native_win": "https://download.agora.io/sdk/release/Agora_SDK_Windows_v4.5.2.zip",
7+
"native_mac": "",
8+
"native_android": "",
9+
"native_ios": ""
10+
},
11+
"audio":{
12+
"native_win": "",
13+
"native_mac": "",
14+
"native_android": "",
15+
"native_ios": ""
16+
}
17+
18+
}

0 commit comments

Comments
 (0)