name: Reusable build util on: workflow_call: inputs: port: required: true type: string boards: required: true type: string toolchain: required: true type: string toolchain_version: required: false type: string jobs: board: # a pull request's selection can leave a port no boards, and an empty matrix is an error if: fromJSON(inputs.boards)[0] != null runs-on: ubuntu-latest strategy: fail-fast: false matrix: board: ${{ fromJSON(inputs.boards) }} steps: - name: Checkout uses: actions/checkout@v4 with: submodules: true - name: Fetch tags run: git fetch --tags --no-recurse-submodules - name: Setup Toolchain id: setup-toolchain uses: ./.github/actions/setup_toolchain with: toolchain: ${{ inputs.toolchain }} toolchain_version: ${{ inputs.toolchain_version }} - name: Get Dependencies run: | python tools/get_deps.py --board ${{ matrix.board }} echo BIN_PATH=ports/${{ inputs.port }}/_bin/${{ matrix.board }} >> $GITHUB_ENV - name: Build if: inputs.toolchain != 'esp-idf' run: | cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DBOARD=${{ matrix.board }} ports/${{ inputs.port }} cmake --build build - name: Build using ESP-IDF docker if: inputs.toolchain == 'esp-idf' run: docker run --rm -v $PWD:/project -w /project espressif/idf:${{ inputs.toolchain_version }} /bin/bash -c "git config --global --add safe.directory /project && idf.py -C ports/espressif -DBOARD=${{ matrix.board }} build" - uses: actions/upload-artifact@v4 with: name: ${{ matrix.board }} path: ${{ env.BIN_PATH }} - name: Prepare Release Asset if: github.event_name == 'release' run: | if [ ${{ inputs.toolchain }} == esp-idf ]; then zip -jr tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.zip ${{ env.BIN_PATH }} cp ${{ env.BIN_PATH }}/combined.bin combined.bin [ -f ${{ env.BIN_PATH }}/combined-ota.bin ] && cp ${{ env.BIN_PATH }}/combined-ota.bin combined-ota.bin cp ${{ env.BIN_PATH }}/apps/update-tinyuf2.uf2 update-tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.uf2 else UPDATE_UF2=${{ env.BIN_PATH }}/apps/update-tinyuf2.uf2 [ -f $UPDATE_UF2 ] && cp $UPDATE_UF2 update-tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.uf2 zip -jr tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.zip ${{ env.BIN_PATH }} fi - name: Upload Release Asset uses: softprops/action-gh-release@v2 if: github.event_name == 'release' with: files: | tinyuf2-${{ matrix.board }}-*.zip update-tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.uf2 - name: Upload Release Assets To AWS S3 env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} if: github.event_name == 'release' && inputs.port == 'espressif' run: | if [ -n \"$AWS_ACCESS_KEY_ID\" ]; then aws s3 cp tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.zip s3://adafruit-circuit-python/bootloaders/esp32/${{ matrix.board }}/tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.zip --no-progress --region us-east-1 aws s3 cp update-tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.uf2 s3://adafruit-circuit-python/bootloaders/esp32/${{ matrix.board }}/update-tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.uf2 --no-progress --region us-east-1 aws s3 cp combined.bin s3://adafruit-circuit-python/bootloaders/esp32/${{ matrix.board }}/tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}-combined.bin --no-progress --region us-east-1 if [ -f combined-ota.bin ]; then aws s3 cp combined-ota.bin s3://adafruit-circuit-python/bootloaders/esp32/${{ matrix.board }}/tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}-combined-ota.bin --no-progress --region us-east-1 fi fi