From 5d0bb98b41324fdcf80d5b9cd91eba20e968287d Mon Sep 17 00:00:00 2001 From: jimmy8854 Date: Thu, 18 Dec 2025 09:00:41 +0800 Subject: [PATCH 1/5] build for static --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index d80e7db..7dcc00a 100755 --- a/build.sh +++ b/build.sh @@ -59,7 +59,7 @@ if echo " $need_no_error_versions " | grep -q " $version "; then fi export CC_host="gcc" export CXX_host="g++" -./configure --dest-cpu=arm64 --dest-os=openharmony --cross-compiling --prefix=node-${version}-openharmony-arm64 +./configure --dest-cpu=arm64 --dest-os=openharmony --cross-compiling --prefix=node-${version}-openharmony-arm64 --fully-static --enable-static make -j$(nproc) make install From 1a17ea71e0b9155d51ad0f02b63a2b2e99121a77 Mon Sep 17 00:00:00 2001 From: jimmy8854 Date: Thu, 18 Dec 2025 09:09:13 +0800 Subject: [PATCH 2/5] Add static build workflow --- .github/workflows/build-static.yml | 155 +++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 .github/workflows/build-static.yml diff --git a/.github/workflows/build-static.yml b/.github/workflows/build-static.yml new file mode 100644 index 0000000..2726ac6 --- /dev/null +++ b/.github/workflows/build-static.yml @@ -0,0 +1,155 @@ +name: Build Static Node.js for OpenHarmony + +on: + push: + branches: [ "build-ohos-static" ] + workflow_dispatch: + inputs: + node_version: + description: 'Node.js version to build (e.g., v24.2.0)' + required: true + default: 'v24.2.0' + +permissions: write-all + +jobs: + build-static: + runs-on: ubuntu-latest + timeout-minutes: 120 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y curl jq git make gcc g++ python3 unzip + + - name: Set Node.js version + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + echo "VERSION=${{ github.event.inputs.node_version }}" >> $GITHUB_ENV + else + echo "VERSION=v24.2.0" >> $GITHUB_ENV + fi + + - name: Setup OpenHarmony SDK + run: | + query_component() { + component=$1 + curl -fsSL 'https://ci.openharmony.cn/api/daily_build/build/list/component' \ + -H 'Accept: application/json, text/plain, */*' \ + -H 'Content-Type: application/json' \ + --data-raw '{"projectName":"openharmony","branch":"master","pageNum":1,"pageSize":10,"deviceLevel":"","component":"'${component}'","type":1,"startTime":"2025080100000000","endTime":"20990101235959","sortType":"","sortField":"","hardwareBoard":"","buildStatus":"success","buildFailReason":"","withDomain":1}' + } + + sdk_download_url=$(query_component "ohos-sdk-public" | jq -r ".data.list.dataList[0].obsPath") + echo "Downloading SDK from: $sdk_download_url" + curl -L $sdk_download_url -o ohos-sdk-public.tar.gz + sudo mkdir -p /opt/ohos-sdk + sudo tar -zxf ohos-sdk-public.tar.gz -C /opt/ohos-sdk + rm -rf ohos-sdk-public.tar.gz + sudo rm -rf /opt/ohos-sdk/windows + cd /opt/ohos-sdk/linux + sudo unzip -q toolchains-*.zip + sudo rm -rf *.zip + cd - + + - name: Setup LLVM-19 + run: | + query_component() { + component=$1 + curl -fsSL 'https://ci.openharmony.cn/api/daily_build/build/list/component' \ + -H 'Accept: application/json, text/plain, */*' \ + -H 'Content-Type: application/json' \ + --data-raw '{"projectName":"openharmony","branch":"master","pageNum":1,"pageSize":10,"deviceLevel":"","component":"'${component}'","type":1,"startTime":"2025080100000000","endTime":"20990101235959","sortType":"","sortField":"","hardwareBoard":"","buildStatus":"success","buildFailReason":"","withDomain":1}' + } + + llvm19_download_url=$(query_component "LLVM-19" | jq -r ".data.list.dataList[0].obsPath") + echo "Downloading LLVM-19 from: $llvm19_download_url" + curl -L $llvm19_download_url -o LLVM-19.tar.gz + sudo mkdir -p /opt/llvm-19 + sudo tar -zxf LLVM-19.tar.gz -C /opt/llvm-19 + rm -rf LLVM-19.tar.gz + cd /opt/llvm-19 + sudo tar -zxf llvm-linux-x86_64.tar.gz + sudo tar -zxf ohos-sysroot.tar.gz + sudo rm -rf *.tar.gz + cd - + + - name: Clone Node.js source + run: | + git clone --branch ${{ env.VERSION }} --depth 1 https://github.com/nodejs/node.git + + - name: Build Node.js (Static) + run: | + cd node + + # Apply patch if needed + need_patch_versions="v24.2.0 v24.3.0 v24.4.0 v24.4.1 v24.5.0 v24.6.0" + if echo " $need_patch_versions " | grep -q " ${{ env.VERSION }} "; then + patch -p1 < ../0001-fix-argument-list-too-long.patch + fi + + # Setup compilers + export CC="/opt/llvm-19/llvm/bin/aarch64-unknown-linux-ohos-clang" + export CXX="/opt/llvm-19/llvm/bin/aarch64-unknown-linux-ohos-clang++" + + need_no_error_versions="v24.2.0 v24.3.0 v24.4.0 v24.4.1 v24.5.0 v24.6.0 v24.7.0 v24.8.0" + if echo " $need_no_error_versions " | grep -q " ${{ env.VERSION }} "; then + export CC="$CC -Wno-error=implicit-function-declaration" + export CXX="$CXX -Wno-error=implicit-function-declaration" + fi + + export CC_host="gcc" + export CXX_host="g++" + + # Configure with static linking + ./configure \ + --dest-cpu=arm64 \ + --dest-os=openharmony \ + --cross-compiling \ + --prefix=node-${{ env.VERSION }}-openharmony-arm64-static \ + --fully-static \ + --enable-static + + # Build + make -j$(nproc) + make install + + - name: Code signing + run: | + cd node + /opt/ohos-sdk/linux/toolchains/lib/binary-sign-tool sign \ + -inFile node-${{ env.VERSION }}-openharmony-arm64-static/bin/node \ + -outFile node-${{ env.VERSION }}-openharmony-arm64-static/bin/node \ + -selfSign 1 + + - name: Package + run: | + cd node + cp LICENSE node-${{ env.VERSION }}-openharmony-arm64-static/ + tar -zcf node-${{ env.VERSION }}-openharmony-arm64-static.tar.gz node-${{ env.VERSION }}-openharmony-arm64-static + + - name: Verify binary + run: | + cd node/node-${{ env.VERSION }}-openharmony-arm64-static/bin + file node + ls -lh node + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: node-${{ env.VERSION }}-openharmony-arm64-static + path: "./node/node-${{ env.VERSION }}-openharmony-arm64-static.tar.gz" + compression-level: 0 + retention-days: 30 + + - name: Create Release (on tag push) + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v1 + with: + files: "./node/node-${{ env.VERSION }}-openharmony-arm64-static.tar.gz" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e75426e6cc14bb65ede6b10155d7a6b079365e2c Mon Sep 17 00:00:00 2001 From: jimmy8854 Date: Thu, 18 Dec 2025 09:15:53 +0800 Subject: [PATCH 3/5] Add static build workflow --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 7dcc00a..649c9db 100755 --- a/build.sh +++ b/build.sh @@ -63,6 +63,7 @@ export CXX_host="g++" make -j$(nproc) make install + # code signing /opt/ohos-sdk/linux/toolchains/lib/binary-sign-tool sign \ -inFile node-${version}-openharmony-arm64/bin/node \ From d242452742f155659751021f21a84ec5783515b8 Mon Sep 17 00:00:00 2001 From: jimmy8854 Date: Thu, 18 Dec 2025 09:18:01 +0800 Subject: [PATCH 4/5] Add static build workflow for dev-ohos-static branch --- .github/workflows/build-static.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-static.yml b/.github/workflows/build-static.yml index 2726ac6..ed73df8 100644 --- a/.github/workflows/build-static.yml +++ b/.github/workflows/build-static.yml @@ -2,7 +2,7 @@ name: Build Static Node.js for OpenHarmony on: push: - branches: [ "build-ohos-static" ] + branches: [ "dev-ohos-static" ] workflow_dispatch: inputs: node_version: From cbb44774068b89f48faa0b21e331654bc4dc2528 Mon Sep 17 00:00:00 2001 From: jimmy8854 Date: Sat, 20 Dec 2025 00:52:38 +0800 Subject: [PATCH 5/5] modity ci --- .github/workflows/build-static.yml | 162 +++++------------------------ 1 file changed, 25 insertions(+), 137 deletions(-) diff --git a/.github/workflows/build-static.yml b/.github/workflows/build-static.yml index ed73df8..484b246 100644 --- a/.github/workflows/build-static.yml +++ b/.github/workflows/build-static.yml @@ -1,155 +1,43 @@ -name: Build Static Node.js for OpenHarmony +name: CI on: + release: + types: [created] push: - branches: [ "dev-ohos-static" ] - workflow_dispatch: - inputs: - node_version: - description: 'Node.js version to build (e.g., v24.2.0)' - required: true - default: 'v24.2.0' + branches: [ "main", "dev-ohos-static" ] + schedule: + - cron: '0 17 * * *' permissions: write-all jobs: - build-static: + build-and-release: runs-on: ubuntu-latest - timeout-minutes: 120 - steps: - - name: Checkout + - name: checkout uses: actions/checkout@v4 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y curl jq git make gcc g++ python3 unzip - - - name: Set Node.js version + - name: set Node.js branch or tag name run: | - if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then - echo "VERSION=${{ github.event.inputs.node_version }}" >> $GITHUB_ENV + if [ "${{ github.event_name }}" == "release" ]; then + echo "VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV else - echo "VERSION=v24.2.0" >> $GITHUB_ENV - fi - - - name: Setup OpenHarmony SDK - run: | - query_component() { - component=$1 - curl -fsSL 'https://ci.openharmony.cn/api/daily_build/build/list/component' \ - -H 'Accept: application/json, text/plain, */*' \ - -H 'Content-Type: application/json' \ - --data-raw '{"projectName":"openharmony","branch":"master","pageNum":1,"pageSize":10,"deviceLevel":"","component":"'${component}'","type":1,"startTime":"2025080100000000","endTime":"20990101235959","sortType":"","sortField":"","hardwareBoard":"","buildStatus":"success","buildFailReason":"","withDomain":1}' - } - - sdk_download_url=$(query_component "ohos-sdk-public" | jq -r ".data.list.dataList[0].obsPath") - echo "Downloading SDK from: $sdk_download_url" - curl -L $sdk_download_url -o ohos-sdk-public.tar.gz - sudo mkdir -p /opt/ohos-sdk - sudo tar -zxf ohos-sdk-public.tar.gz -C /opt/ohos-sdk - rm -rf ohos-sdk-public.tar.gz - sudo rm -rf /opt/ohos-sdk/windows - cd /opt/ohos-sdk/linux - sudo unzip -q toolchains-*.zip - sudo rm -rf *.zip - cd - - - - name: Setup LLVM-19 - run: | - query_component() { - component=$1 - curl -fsSL 'https://ci.openharmony.cn/api/daily_build/build/list/component' \ - -H 'Accept: application/json, text/plain, */*' \ - -H 'Content-Type: application/json' \ - --data-raw '{"projectName":"openharmony","branch":"master","pageNum":1,"pageSize":10,"deviceLevel":"","component":"'${component}'","type":1,"startTime":"2025080100000000","endTime":"20990101235959","sortType":"","sortField":"","hardwareBoard":"","buildStatus":"success","buildFailReason":"","withDomain":1}' - } - - llvm19_download_url=$(query_component "LLVM-19" | jq -r ".data.list.dataList[0].obsPath") - echo "Downloading LLVM-19 from: $llvm19_download_url" - curl -L $llvm19_download_url -o LLVM-19.tar.gz - sudo mkdir -p /opt/llvm-19 - sudo tar -zxf LLVM-19.tar.gz -C /opt/llvm-19 - rm -rf LLVM-19.tar.gz - cd /opt/llvm-19 - sudo tar -zxf llvm-linux-x86_64.tar.gz - sudo tar -zxf ohos-sysroot.tar.gz - sudo rm -rf *.tar.gz - cd - - - - name: Clone Node.js source - run: | - git clone --branch ${{ env.VERSION }} --depth 1 https://github.com/nodejs/node.git - - - name: Build Node.js (Static) - run: | - cd node - - # Apply patch if needed - need_patch_versions="v24.2.0 v24.3.0 v24.4.0 v24.4.1 v24.5.0 v24.6.0" - if echo " $need_patch_versions " | grep -q " ${{ env.VERSION }} "; then - patch -p1 < ../0001-fix-argument-list-too-long.patch + echo "VERSION=main" >> $GITHUB_ENV fi - - # Setup compilers - export CC="/opt/llvm-19/llvm/bin/aarch64-unknown-linux-ohos-clang" - export CXX="/opt/llvm-19/llvm/bin/aarch64-unknown-linux-ohos-clang++" - - need_no_error_versions="v24.2.0 v24.3.0 v24.4.0 v24.4.1 v24.5.0 v24.6.0 v24.7.0 v24.8.0" - if echo " $need_no_error_versions " | grep -q " ${{ env.VERSION }} "; then - export CC="$CC -Wno-error=implicit-function-declaration" - export CXX="$CXX -Wno-error=implicit-function-declaration" - fi - - export CC_host="gcc" - export CXX_host="g++" - - # Configure with static linking - ./configure \ - --dest-cpu=arm64 \ - --dest-os=openharmony \ - --cross-compiling \ - --prefix=node-${{ env.VERSION }}-openharmony-arm64-static \ - --fully-static \ - --enable-static - - # Build - make -j$(nproc) - make install - - - name: Code signing - run: | - cd node - /opt/ohos-sdk/linux/toolchains/lib/binary-sign-tool sign \ - -inFile node-${{ env.VERSION }}-openharmony-arm64-static/bin/node \ - -outFile node-${{ env.VERSION }}-openharmony-arm64-static/bin/node \ - -selfSign 1 - - - name: Package - run: | - cd node - cp LICENSE node-${{ env.VERSION }}-openharmony-arm64-static/ - tar -zcf node-${{ env.VERSION }}-openharmony-arm64-static.tar.gz node-${{ env.VERSION }}-openharmony-arm64-static - - - name: Verify binary - run: | - cd node/node-${{ env.VERSION }}-openharmony-arm64-static/bin - file node - ls -lh node - - - name: Upload artifact + - name: build + run: ./build.sh ${{ env.VERSION }} + - name: upload artifact uses: actions/upload-artifact@v4 with: - name: node-${{ env.VERSION }}-openharmony-arm64-static - path: "./node/node-${{ env.VERSION }}-openharmony-arm64-static.tar.gz" + path: "./node/node-${{ env.VERSION }}-openharmony-arm64.tar.gz" compression-level: 0 - retention-days: 30 - - - name: Create Release (on tag push) - if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 - with: - files: "./node/node-${{ env.VERSION }}-openharmony-arm64-static.tar.gz" + retention-days: 7 + - name: upload release asset + if: github.event_name == 'release' + uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: "./node/node-${{ env.VERSION }}-openharmony-arm64.tar.gz" + asset_name: "node-${{ env.VERSION }}-openharmony-arm64.tar.gz" + asset_content_type: application/octet-stream