From 39b0564263c2c6ff958abd346616ac0c8a23a3b3 Mon Sep 17 00:00:00 2001 From: Francesco Pham Date: Wed, 11 Dec 2024 16:36:59 +0100 Subject: [PATCH] Add Build Verification CI Workflow This PR adds a `Verify Build` GitHub Actions workflow to automate building and verifying the application on the `main` branch. The workflow includes: - Checking out the repository. - Setting up signing certificates from GitHub Secrets. - Installing OpenHarmony tools and dependencies. - Building the application with `hvigorw`. - Uploading generated HAP packages as artifacts. This ensures a reliable and consistent build process for continuous integration. Signed-off-by: Francesco Pham --- .github/workflows/build.yml | 88 +++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..753420a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,88 @@ +name: Verify Build + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + name: Build and Verify Application + runs-on: macos-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install tree command + run: brew install tree + + - name: Setup signing certificates and keystore + # This step extracts the required signing materials from a base64 encoded zip stored in GitHub Secrets + # The zip contains: + # - .cer file: Developer certificate for signing + # - .p7b file: Profile for app provisioning + # - .p12 file: Keystore containing private key + run: | + # Decode base64 secret to zip file + echo "${{ secrets.ONIRO_APP_SIGNATURE_ZIP }}" | base64 -d > secrets.zip + + # Extract files while preserving directory structure + unzip -o secrets.zip + + # Cleanup temporary zip file + rm secrets.zip + + # Display extracted files for verification + echo "=== Extracted Signing Materials ===" + tree .secret -L 4 + + - name: Set up tools and dependencies + uses: Snapp-Mobile/oh-action@main + + - name: Verify Installation + run: | + echo "=== Environment Variables ===" + echo "PATH: $PATH" + echo "OHOS_BASE_SDK_HOME: $OHOS_BASE_SDK_HOME" + echo "CMD_PATH: $CMD_PATH" + + echo "=== OHPM Installation ===" + which ohpm + ohpm -v + + echo "=== Hvigor Installation ===" + which hvigorw + hvigorw --version + + echo "=== Installation Directories ===" + echo "Command-line Tools:" + tree -L 3 $CMD_PATH + + echo "OpenHarmony SDK:" + tree -L 3 $OHOS_BASE_SDK_HOME + + echo "=== Node.js Version ===" + node --version + npm --version + + echo "=== NPM Configuration ===" + cat $HOME/.npmrc + + - name: Install OpenHarmony Dependencies + run: ohpm install --all + + - name: Initialize and Build + run: | + hvigorw --version --accept-license + hvigorw clean --no-parallel --no-daemon + hvigorw assembleHap --mode module -p product=default --stacktrace --no-parallel --no-daemon + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: HAP packages + path: ./entry/build/default/outputs/default \ No newline at end of file