mathieucarbou/MycilaUtilities @ 4.3.0 #694
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: Build Firmware | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: ["v*"] | |
| branches: ["*"] | |
| paths-ignore: ["docs/**", "**/*.md", "docs/**", "**/portal/**", "tools/**", "test/**", "**/*.md", "*.md"] | |
| pull_request: | |
| paths-ignore: ["docs/**", "**/*.md", "docs/**", "**/portal/**", "tools/**", "test/**", "**/*.md", "*.md"] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| pio_envs: | |
| if: ${{ github.repository == 'mathieucarbou/Beelance' }} | |
| name: Get PlatformIO Envs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Cache | |
| uses: actions/cache@v5 | |
| with: | |
| key: ${{ runner.os }}-pio_envs | |
| path: ~/.cache/pip | |
| - name: Pyhton | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: PlatformIO | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install --upgrade platformio | |
| pip install --upgrade intelhex | |
| pip install --upgrade rich_click | |
| - name: Get Envs | |
| id: envs | |
| run: | | |
| rm -f platformio_override.ini | |
| echo "pio_name=$(pio project config --json-output | jq -cr '.[0][1][0][1]')" >> $GITHUB_OUTPUT | |
| echo "pio_default_envs=$(pio project config --json-output | jq -cr '[ .[][0] | select(startswith("env:") and (endswith("-debug")|not)) | .[4:] ]')" >> $GITHUB_OUTPUT | |
| outputs: | |
| pio_name: ${{ steps.envs.outputs.pio_name }} | |
| pio_default_envs: ${{ steps.envs.outputs.pio_default_envs }} | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: [pio_envs] | |
| strategy: | |
| matrix: | |
| environment: ${{ fromJSON(needs.pio_envs.outputs.pio_default_envs) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Get Tags | |
| run: git fetch --force --tags origin | |
| - name: Cache PlatformIO | |
| uses: actions/cache@v5 | |
| with: | |
| key: ${{ runner.os }}-pio | |
| path: | | |
| ~/.cache/pip | |
| ~/.platformio | |
| - name: Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: Build | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install --upgrade platformio | |
| pip install --upgrade cryptography | |
| pip install --upgrade intelhex | |
| pip install --upgrade rich_click | |
| REF_NAME="${{ github.ref_name }}" pio run -e ${{ matrix.environment }} | |
| ref="${{ github.ref_name }}" | |
| ref="${ref//\//}" | |
| mv .pio/build/${{ matrix.environment }}/firmware.bin ./${{ needs.pio_envs.outputs.pio_name }}-$ref-${{ matrix.environment }}.OTA.bin | |
| mv .pio/build/${{ matrix.environment }}/firmware.factory.bin ./${{ needs.pio_envs.outputs.pio_name }}-$ref-${{ matrix.environment }}.FACTORY.bin | |
| - name: Upload | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ matrix.environment }} | |
| if-no-files-found: error | |
| path: | | |
| *.bin | |
| release: | |
| name: Release | |
| if: ${{ github.repository_owner == 'mathieucarbou' && github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }} | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Download | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: artifacts/ | |
| - name: Move | |
| run: | | |
| ls -R artifacts | |
| find artifacts -name '*.bin' -exec mv {} artifacts/ \; | |
| - name: Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| files: artifacts/*.bin |