Skip to content

Commit

Permalink
Use file to define build targets
Browse files Browse the repository at this point in the history
  • Loading branch information
krichardsson committed Oct 3, 2022
1 parent 2463025 commit 90a3b0e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 27 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
46 changes: 34 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,7 +53,7 @@ jobs:
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt
path: release_url.txt

upload:
permissions:
Expand All @@ -42,16 +64,16 @@ 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
with:
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
Expand All @@ -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
7 changes: 7 additions & 0 deletions build_targets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"platform" : [
"cf2",
"bolt",
"tag"
]
}
11 changes: 0 additions & 11 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,5 @@
"environmentReqs": {
"build": ["arm-none-eabi"],
"build-docs": ["doxygen"]
},
"actions": {
"artifacts": [
".bin",
".dfu"
],
"targets" : [
"cf2",
"bolt",
"tag"
]
}
}

0 comments on commit 90a3b0e

Please sign in to comment.