77 description : ' Target platforms, e.g. android, ios, macos, windows, web, etc; separated by comma, default is all platforms'
88 type : string
99 required : true
10- default : ' android, ios, macos, windows, web'
10+ default : ' android, ios, macos, windows, web, ohos '
1111 target_branch :
1212 description : ' Target branch, leave empty will use the same as the workflow trigger branch'
1313 type : string
9393 required : true
9494 KEYCHAIN_PASSWORD :
9595 required : true
96+ FLUTTER_3_22_OHOS_1_0_1 :
97+ required : true
98+ FLUTTER_3_7_12_OHOS_1_1_1 :
99+ required : true
100+
96101
97102
98103jobs :
@@ -121,7 +126,7 @@ jobs:
121126 platforms=$(echo "$target_platforms" | sed 's/ //g' | tr ',' '\n' | sort -u | sed '/^$/d' | jq -R -s -c 'split("\n")[:-1]')
122127 echo "splited platforms: $platforms"
123128 # remove not supported platforms, only keep supported platforms: android, ios, macos, windows, web
124- platforms=$(echo "$platforms" | jq -e 'map(select(. == "android" or . == "ios" or . == "macos" or . == "windows" or . == "web"))')
129+ platforms=$(echo "$platforms" | jq -e 'map(select(. == "android" or . == "ios" or . == "macos" or . == "windows" or . == "web" or . == "ohos" ))')
125130 # make platforms in oneline, and keep json format
126131 platforms=$(echo "$platforms" | jq -c .)
127132 echo "final jsonlized platforms: $platforms"
@@ -144,6 +149,8 @@ jobs:
144149 platform : macos
145150 - os : ubuntu-latest
146151 platform : windows
152+ - os : ubuntu-latest
153+ platform : ohos
147154 - os : macos-latest
148155 platform : windows
149156 - os : macos-latest
@@ -156,6 +163,8 @@ jobs:
156163 platform : macos
157164 - os : windows-latest
158165 platform : web
166+ - os : windows-latest
167+ platform : ohos
159168 env :
160169 platform : ${{ matrix.platform }}
161170 extra_build_options : ${{ inputs.extra_build_options }}
@@ -166,6 +175,7 @@ jobs:
166175 artifact_nightly_link_macos : ${{ steps.setup_output.outputs.artifact_nightly_link_macos }}
167176 artifact_nightly_link_windows : ${{ steps.setup_output.outputs.artifact_nightly_link_windows }}
168177 artifact_nightly_link_web : ${{ steps.setup_output.outputs.artifact_nightly_link_web }}
178+ artifact_nightly_link_ohos : ${{ steps.setup_output.outputs.artifact_nightly_link_ohos }}
169179 steps :
170180 - name : Checkout
171181 uses : actions/checkout@v4
@@ -176,7 +186,7 @@ jobs:
176186 submodules : ' true'
177187
178188 - name : Setup JDK for Android
179- if : ${{ matrix.platform == 'android' }}
189+ if : ${{ matrix.platform == 'android' || matrix.platform == 'ohos' }}
180190 uses : actions/setup-java@v4
181191 with :
182192 distribution : ' zulu'
@@ -230,12 +240,56 @@ jobs:
230240 run : pod repo update
231241
232242 - name : Setup Flutter
243+ if : ${{ matrix.platform != 'ohos' }}
233244 uses : subosito/flutter-action@v2
234245 with :
235246 channel : ${{ inputs.flutter_channel }}
236247 flutter-version : ${{ inputs.flutter_version }}
237248 cache : true
238249
250+ - name : Setup Flutter for OHOS
251+ if : ${{ matrix.platform == 'ohos' }}
252+ run : |
253+ # download flutter
254+ curl -o flutter.zip ${{ secrets.FLUTTER_3_7_12_OHOS_1_1_1 }}
255+ unzip flutter.zip -d $RUNNER_TEMP/flutter
256+ FLUTTER_HOME=$(find $RUNNER_TEMP/flutter -name "flutter.bat" | sed 's/\/bin\/flutter.bat//')
257+ export PUB_CACHE=$RUNNER_TEMP/pub-cache
258+ export PUB_HOSTED_URL=https://pub.flutter-io.cn
259+ export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
260+ export FLUTTER_GIT_URL=https://gitcode.com/openharmony-sig/flutter_flutter.git
261+ CURRENT_DIR=$(pwd)
262+ cd $FLUTTER_HOME/
263+ echo "3.7.12-ohos-1.1.1" > version
264+ git config --global --add safe.directory $FLUTTER_HOME
265+ git init
266+ git add README.md
267+ git commit -m "init"
268+ git tag 3.7.12-ohos-1.1.1
269+ git log
270+ git tag -l
271+ git status
272+ cd $CURRENT_DIR
273+ echo "FLUTTER_HOME=$FLUTTER_HOME" >> $GITHUB_ENV
274+ echo "PUB_CACHE=$PUB_CACHE" >> $GITHUB_ENV
275+ echo "PUB_HOSTED_URL=$PUB_HOSTED_URL" >> $GITHUB_ENV
276+ echo "FLUTTER_STORAGE_BASE_URL=$FLUTTER_STORAGE_BASE_URL" >> $GITHUB_ENV
277+ echo "FLUTTER_GIT_URL=$FLUTTER_GIT_URL" >> $GITHUB_ENV
278+ echo "$FLUTTER_HOME/bin" >> $GITHUB_PATH
279+
280+
281+ - name : Setup OHOS SDK
282+ if : ${{ matrix.platform == 'ohos' }}
283+ uses :
openharmony-rs/[email protected] 284+ with :
285+ version : ' 5.1.0'
286+ cache : true
287+ # run: |
288+ # # download ohos sdk
289+ # curl -O https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-sdk-download-0000001056040578
290+ # unzip ohos-sdk-linux-x64.zip
291+ # export OHOS_SDK_PATH=$RUNNER_TEMP/ohos-sdk
292+
239293 - name : Build
240294 env :
241295 DEFAULT_BUILD_APP_ID : ${{ secrets.APP_ID }}
@@ -260,6 +314,8 @@ jobs:
260314 build_command="flutter build windows"
261315 elif [ "$platform" == "web" ]; then
262316 build_command="flutter build web"
317+ elif [ "$platform" == "ohos" ]; then
318+ build_command="flutter build hap"
263319 fi
264320
265321 # prepare build options
@@ -340,6 +396,9 @@ jobs:
340396 elif [ "$platform" == "web" ]; then
341397 # copy all files and files in subdirectories to ../output directory
342398 cp -r build/web/* ../output
399+ elif [ "$platform" == "ohos" ]; then
400+ # copy all files and files in subdirectories to ../output directory
401+ cp -r ohos/entry/build/default/outputs/default/*.hap ../output
343402 fi
344403
345404 - name : Generate artifact name
@@ -390,5 +449,6 @@ jobs:
390449 - ${{ needs.build.outputs.artifact_nightly_link_macos }}
391450 - ${{ needs.build.outputs.artifact_nightly_link_windows }}
392451 - ${{ needs.build.outputs.artifact_nightly_link_web }}
452+ - ${{ needs.build.outputs.artifact_nightly_link_ohos }}
393453
394454 > This comment is commented by bot, do not edit it directly
0 commit comments