|
| 1 | +name: OpenHarmony hap |
| 2 | + |
| 3 | +# Tier 3 (platform/README.md): a community port built by a manually dispatched |
| 4 | +# workflow, never on pull requests. The HarmonyOS SDK and hvigor are not |
| 5 | +# anonymously downloadable, so the build job targets a self-hosted runner with |
| 6 | +# the toolchain described in platform/ohos/README.md. |
| 7 | +# |
| 8 | +# Pull request checks build unsigned: this workflow only runs on dispatch, and |
| 9 | +# signing material exists exclusively as repository secrets. |
| 10 | + |
| 11 | +on: |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + app: |
| 15 | + description: Application to package |
| 16 | + type: choice |
| 17 | + options: |
| 18 | + - mail |
| 19 | + - demo |
| 20 | + default: mail |
| 21 | + profile: |
| 22 | + description: Cargo profile |
| 23 | + type: choice |
| 24 | + options: |
| 25 | + - release |
| 26 | + - debug |
| 27 | + default: release |
| 28 | + sign: |
| 29 | + description: Sign with the AGC material stored in the repository secrets |
| 30 | + type: boolean |
| 31 | + default: false |
| 32 | + run_quality: |
| 33 | + description: Run the shared quality suite first |
| 34 | + type: boolean |
| 35 | + default: true |
| 36 | + |
| 37 | +permissions: |
| 38 | + contents: read |
| 39 | + |
| 40 | +concurrency: |
| 41 | + group: ohos-${{ github.ref }} |
| 42 | + cancel-in-progress: false |
| 43 | + |
| 44 | +jobs: |
| 45 | + quality: |
| 46 | + if: inputs.run_quality |
| 47 | + name: Shared quality suite |
| 48 | + uses: ./.github/workflows/quality.yml |
| 49 | + |
| 50 | + hap: |
| 51 | + name: ${{ inputs.app }} hap (${{ inputs.profile }}) |
| 52 | + needs: quality |
| 53 | + if: always() && (needs.quality.result == 'success' || needs.quality.result == 'skipped') |
| 54 | + runs-on: [self-hosted, linux, ohos] |
| 55 | + timeout-minutes: 180 |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 |
| 58 | + |
| 59 | + - name: Check the OHOS workspace formatting |
| 60 | + run: cargo fmt --manifest-path platform/ohos/Cargo.toml --all -- --check |
| 61 | + |
| 62 | + - name: Materialize signing material |
| 63 | + if: inputs.sign |
| 64 | + env: |
| 65 | + KEYSTORE_BASE64: ${{ secrets.FLECTAR_OHOS_KEYSTORE_BASE64 }} |
| 66 | + CERTIFICATE_BASE64: ${{ secrets.FLECTAR_OHOS_CERTIFICATE_BASE64 }} |
| 67 | + PROFILE_BASE64: ${{ secrets.FLECTAR_OHOS_PROFILE_BASE64 }} |
| 68 | + run: | |
| 69 | + test -n "$KEYSTORE_BASE64" |
| 70 | + test -n "$CERTIFICATE_BASE64" |
| 71 | + test -n "$PROFILE_BASE64" |
| 72 | + material="$RUNNER_TEMP/ohos-signing" |
| 73 | + umask 077 |
| 74 | + mkdir -p "$material" |
| 75 | + printf '%s' "$KEYSTORE_BASE64" | base64 --decode > "$material/keystore.p12" |
| 76 | + printf '%s' "$CERTIFICATE_BASE64" | base64 --decode > "$material/certificate.cer" |
| 77 | + printf '%s' "$PROFILE_BASE64" | base64 --decode > "$material/profile.p7b" |
| 78 | + { |
| 79 | + echo "RELEASE_SIGN=1" |
| 80 | + echo "RELEASE_P12=$material/keystore.p12" |
| 81 | + echo "RELEASE_CERT=$material/certificate.cer" |
| 82 | + echo "RELEASE_PROFILE=$material/profile.p7b" |
| 83 | + echo "RELEASE_KEY_ALIAS=${{ secrets.FLECTAR_OHOS_KEY_ALIAS }}" |
| 84 | + echo "RELEASE_KEY_PWD=${{ secrets.FLECTAR_OHOS_KEY_PASSWORD }}" |
| 85 | + echo "RELEASE_STORE_PWD=${{ secrets.FLECTAR_OHOS_STORE_PASSWORD }}" |
| 86 | + } >> "$GITHUB_ENV" |
| 87 | +
|
| 88 | + - name: Build the hap |
| 89 | + env: |
| 90 | + APP: ${{ inputs.app }} |
| 91 | + PROFILE: ${{ inputs.profile }} |
| 92 | + CARGO_BUILD_JOBS: "4" |
| 93 | + SKIP_SIGN: ${{ inputs.sign && '0' || '1' }} |
| 94 | + run: sh platform/ohos/scripts/build-hap.sh |
| 95 | + |
| 96 | + - name: Remove the signing material |
| 97 | + if: always() && inputs.sign |
| 98 | + run: rm -rf "$RUNNER_TEMP/ohos-signing" |
| 99 | + |
| 100 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 101 | + with: |
| 102 | + name: flectar-ohos-${{ inputs.app }}-${{ inputs.profile }} |
| 103 | + path: platform/ohos/build/*.hap |
| 104 | + if-no-files-found: error |
0 commit comments