|
| 1 | +--- |
| 2 | +name: Build the application for all devices and upload the artifact |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + app_repository: |
| 8 | + description: 'The GIT repository to build (defaults to `github.repository`)' |
| 9 | + required: false |
| 10 | + default: ${{ github.repository }} |
| 11 | + type: string |
| 12 | + app_branch_name: |
| 13 | + description: 'The GIT branch to build (defaults to `github.ref`)' |
| 14 | + required: false |
| 15 | + default: ${{ github.ref }} |
| 16 | + type: string |
| 17 | + flags: |
| 18 | + description: "Additional compilation flags (default to none)" |
| 19 | + required: false |
| 20 | + default: '' |
| 21 | + type: string |
| 22 | + upload_app_binaries_artifact: |
| 23 | + description: "The name of the artifact containing the built application binary file(s) to be tested" |
| 24 | + required: false |
| 25 | + default: '' |
| 26 | + type: string |
| 27 | + |
| 28 | +jobs: |
| 29 | + call_get_app_metadata: |
| 30 | + # This job digests inputs and repository metadata provided by the `ledger_app.toml` manifest |
| 31 | + # file, in order to output relevant directories, compatible devices, and other variables needed |
| 32 | + # by following jobs. |
| 33 | + name: Retrieve application metadata |
| 34 | + uses: LedgerHQ/ledger-app-workflows/.github/workflows/_get_app_metadata.yml@v1 |
| 35 | + with: |
| 36 | + app_repository: ${{ inputs.app_repository }} |
| 37 | + app_branch_name: ${{ inputs.app_branch_name }} |
| 38 | + compatible_devices: 'None' |
| 39 | + |
| 40 | + build: |
| 41 | + name: Build application for NanoS, X, S+, and Stax |
| 42 | + needs: call_get_app_metadata |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + device: ${{ fromJSON(needs.call_get_app_metadata.outputs.compatible_devices) }} |
| 47 | + runs-on: ubuntu-latest |
| 48 | + container: |
| 49 | + image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest |
| 50 | + |
| 51 | + steps: |
| 52 | + - name: Clone |
| 53 | + uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + repository: ${{ inputs.app_repository }} |
| 56 | + ref: ${{ inputs.app_branch_name }} |
| 57 | + submodules: recursive |
| 58 | + |
| 59 | + - name: Use this version of the ethereum SDK |
| 60 | + run: | |
| 61 | + rm -rf ./ethereum-plugin-sdk |
| 62 | +
|
| 63 | + - name: Checkout SDK PR branch |
| 64 | + uses: actions/checkout@v4 |
| 65 | + with: |
| 66 | + path: ethereum-plugin-sdk/ |
| 67 | + ref: ${{ github.ref }} |
| 68 | + repository: ${{ github.repository }} |
| 69 | + |
| 70 | + - name: Build application |
| 71 | + id: "build" |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + if [[ "${{ needs.call_get_app_metadata.outputs.is_rust }}" == "true" ]]; |
| 75 | + then |
| 76 | + BUILD_DEVICE_NAME="$(echo ${{ matrix.device }} | sed 's/nanosp/nanosplus/')" && \ |
| 77 | + cd ${{ needs.call_get_app_metadata.outputs.build_directory }} && \ |
| 78 | + cargo +$RUST_NIGHTLY update ledger_device_sdk && \ |
| 79 | + cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys && \ |
| 80 | + cargo ledger build ${BUILD_DEVICE_NAME} && \ |
| 81 | + echo "binary_path=${{ needs.call_get_app_metadata.outputs.build_directory }}/target/*" >> $GITHUB_OUTPUT && \ |
| 82 | + echo "Build complete" |
| 83 | + else |
| 84 | + eval "BOLOS_SDK=\$$(echo ${{ matrix.device }} | tr [:lower:] [:upper:])_SDK" && \ |
| 85 | + echo "BOLOS_SDK value will be: ${BOLOS_SDK}" && \ |
| 86 | + make -C ${{ needs.call_get_app_metadata.outputs.build_directory }} -j ${{ inputs.flags }} BOLOS_SDK=${BOLOS_SDK} && \ |
| 87 | + echo "binary_path=${{ needs.call_get_app_metadata.outputs.build_directory }}/build/*" >> $GITHUB_OUTPUT |
| 88 | + echo "Build complete" |
| 89 | + fi |
| 90 | +
|
| 91 | + - name: Remove build artifacts before upload |
| 92 | + run: | |
| 93 | + if [[ "${{ needs.call_get_app_metadata.outputs.is_rust }}" == "true" ]]; |
| 94 | + then |
| 95 | + find ${{ needs.call_get_app_metadata.outputs.build_directory }}/target -mindepth 3 -maxdepth 3 -type d -exec rm -rf {} + |
| 96 | + else |
| 97 | + find ${{ needs.call_get_app_metadata.outputs.build_directory }}/build/ -mindepth 2 -maxdepth 2 -type d ! -name 'bin' -exec rm -r {} + |
| 98 | + fi |
| 99 | +
|
| 100 | + - name: Upload app binary |
| 101 | + if: ${{ inputs.upload_app_binaries_artifact != '' }} |
| 102 | + uses: actions/upload-artifact@v3 |
| 103 | + with: |
| 104 | + name: ${{ inputs.upload_app_binaries_artifact }} |
| 105 | + path: ${{ steps.build.outputs.binary_path }} |
| 106 | + if-no-files-found: error |
0 commit comments