From 90a3b0e5596f831fd2d91035d1f9c830f14f243f Mon Sep 17 00:00:00 2001 From: Kristoffer Richardsson Date: Mon, 3 Oct 2022 17:37:25 +0200 Subject: [PATCH] Use file to define build targets --- .github/workflows/CI.yml | 24 +++++++++++++++--- .github/workflows/release.yml | 46 ++++++++++++++++++++++++++--------- build_targets.json | 7 ++++++ module.json | 11 --------- 4 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 build_targets.json diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f547bf2451..c227285887 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,7 +14,26 @@ permissions: contents: read jobs: + read_targets_from_file: + runs-on: ubuntu-latest + outputs: + platforms: ${{ steps.read-build-target-from-file.outputs.platforms }} + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + submodules: false + + - id: read-build-target-from-file + run: | + content=`cat ./build_targets.json` + # the following lines are required for multi line json + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + # end of handling for multi line json + echo "::set-output name=platforms::$content" basic_build: needs: read_targets_from_file @@ -23,10 +42,7 @@ jobs: strategy: fail-fast: false matrix: - platform: - - cf2 - - bolt - - tag + ${{fromJson(needs.read_targets_from_file.outputs.platforms)}} steps: - name: Checkout Repo diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0ee715585..d77eb22f24 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,10 +9,32 @@ permissions: contents: read jobs: + read_targets_from_file: + runs-on: ubuntu-latest + outputs: + platforms: ${{ steps.read-build-target-from-file.outputs.platforms }} + + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + submodules: false + + - id: read-build-target-from-file + run: | + content=`cat ./build_targets.json` + # the following lines are required for multi line json + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + # end of handling for multi line json + echo "::set-output name=platforms::$content" + release: permissions: contents: write # for actions/create-release to create a release name: Create Release on Github + needs: read_targets_from_file runs-on: ubuntu-latest steps: - name: Create Release @@ -31,7 +53,7 @@ jobs: uses: actions/upload-artifact@v1 with: name: release_url - path: release_url.txt + path: release_url.txt upload: permissions: @@ -42,8 +64,8 @@ jobs: strategy: fail-fast: false matrix: - platforms: [cf2, tag, bolt] - + ${{fromJson(needs.read_targets_from_file.outputs.platforms)}} + steps: - name: Checkout Repo uses: actions/checkout@v2 @@ -51,7 +73,7 @@ jobs: submodules: true - name: Build - run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "make ${{ matrix.platforms }}_defconfig && ./tools/build/build PLATFORM=${{ matrix.platforms }} UNIT_TEST_STYLE=min" + run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "make ${{ matrix.platform }}_defconfig && ./tools/build/build PLATFORM=${{ matrix.platform }} UNIT_TEST_STYLE=min" - name: Load Release URL File from release job uses: actions/download-artifact@v1 @@ -63,19 +85,19 @@ jobs: run: | value=`cat release_url/release_url.txt` echo ::set-output name=upload_url::$value - - - name: Get the version - id: get_release_version - env: + + - name: Get the version + id: get_release_version + env: GITHUB_REF : ${{ github.ref }} run: echo ::set-output name=release_version::${GITHUB_REF/refs\/tags\//} - - - name: Upload ${{ matrix.platforms }} bin + + - name: Upload ${{ matrix.platform }} bin uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.get_release_info.outputs.upload_url }} - asset_path: ${{ matrix.platforms }}.bin - asset_name: ${{ matrix.platforms }}-${{ steps.get_release_version.outputs.release_version }}.bin + asset_path: ${{ matrix.platform }}.bin + asset_name: ${{ matrix.platform }}-${{ steps.get_release_version.outputs.release_version }}.bin asset_content_type: application/octet-stream diff --git a/build_targets.json b/build_targets.json new file mode 100644 index 0000000000..3857ea63bd --- /dev/null +++ b/build_targets.json @@ -0,0 +1,7 @@ +{ + "platform" : [ + "cf2", + "bolt", + "tag" + ] + } diff --git a/module.json b/module.json index 7890dc6b51..92eae26e05 100644 --- a/module.json +++ b/module.json @@ -3,16 +3,5 @@ "environmentReqs": { "build": ["arm-none-eabi"], "build-docs": ["doxygen"] - }, - "actions": { - "artifacts": [ - ".bin", - ".dfu" - ], - "targets" : [ - "cf2", - "bolt", - "tag" - ] } }