|
| 1 | +name: Build IDF Monitor |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-idf-monitor-binaries: |
| 7 | + name: Build IDF Monitor binaries for ${{ matrix.platform }} |
| 8 | + runs-on: ${{ matrix.runner }} |
| 9 | + strategy: |
| 10 | + fail-fast: false |
| 11 | + matrix: |
| 12 | + platform: [windows-amd64, linux-amd64, macos-amd64, macos-arm64, linux-armv7, linux-aarch64] |
| 13 | + include: |
| 14 | + - platform: windows-amd64 |
| 15 | + runner: windows-latest |
| 16 | + - platform: linux-amd64 |
| 17 | + runner: ubuntu-24.04 |
| 18 | + - platform: macos-amd64 |
| 19 | + runner: macos-13 |
| 20 | + - platform: macos-arm64 |
| 21 | + runner: macos-latest |
| 22 | + - platform: linux-armv7 |
| 23 | + runner: ubuntu-latest |
| 24 | + - platform: linux-aarch64 |
| 25 | + runner: ubuntu-24.04-arm |
| 26 | + env: |
| 27 | + DISTPATH: idf-monitor-${{ matrix.platform }} |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Set up Python 3.13 |
| 33 | + uses: actions/setup-python@v5 |
| 34 | + # Python is not needed for Linux runners, as they are running in a container |
| 35 | + if: matrix.platform != 'linux-armv7' && matrix.platform != 'linux-aarch64' && matrix.platform != 'linux-amd64' |
| 36 | + with: |
| 37 | + python-version: "3.13" |
| 38 | + cache: pip |
| 39 | + - name: Build with PyInstaller |
| 40 | + uses: espressif/python-binary-action@master |
| 41 | + with: |
| 42 | + scripts: 'esp_idf_monitor/__main__.py' |
| 43 | + script-name: 'esp_idf_monitor' |
| 44 | + output-dir: ./${{ env.DISTPATH }} |
| 45 | + target-platform: ${{ matrix.platform }} |
| 46 | + |
| 47 | + - name: Add license and readme |
| 48 | + shell: bash |
| 49 | + run: mv LICENSE README.md ./${{ env.DISTPATH }} |
| 50 | + |
| 51 | + - name: Archive artifact |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: ${{ env.DISTPATH }} |
| 55 | + path: ${{ env.DISTPATH }} |
| 56 | + |
| 57 | + create_release: |
| 58 | + name: Create GitHub release |
| 59 | + runs-on: ubuntu-latest |
| 60 | + if: startsWith(github.ref, 'refs/tags/v') |
| 61 | + needs: build-idf-monitor-binaries |
| 62 | + permissions: |
| 63 | + contents: write |
| 64 | + steps: |
| 65 | + - name: Get version |
| 66 | + id: get_version |
| 67 | + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 68 | + shell: bash |
| 69 | + - name: Checkout |
| 70 | + uses: actions/checkout@v4 |
| 71 | + with: |
| 72 | + fetch-depth: 0 |
| 73 | + - name: Install dependencies |
| 74 | + run: | |
| 75 | + python -m pip install --upgrade pip |
| 76 | + pip install --user -e ".[dev]" |
| 77 | + - name: Generate changelog |
| 78 | + run: | |
| 79 | + cz changelog ${{ steps.get_version.outputs.VERSION }} --file-name changelog_body.md |
| 80 | + cat changelog_body.md |
| 81 | + - name: Download built binaries |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + - name: Compress and rename binaries |
| 84 | + run: | |
| 85 | + for dir in idf-monitor-*; do |
| 86 | + if [[ "$dir" == idf-monitor-win* ]]; then |
| 87 | + zip -r "idf-monitor-v${{ steps.get_version.outputs.VERSION }}-${dir#idf-monitor-}.zip" "$dir" |
| 88 | + else |
| 89 | + chmod -R u=rwx,g=rx,o=rx "$dir" |
| 90 | + tar -cvzf "idf-monitor-v${{ steps.get_version.outputs.VERSION }}-${dir#idf-monitor-}.tar.gz" "$dir" |
| 91 | + fi |
| 92 | + done |
| 93 | + - name: Create release |
| 94 | + id: create_release |
| 95 | + uses: softprops/action-gh-release@v2 |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + with: |
| 99 | + body_path: changelog_body.md |
| 100 | + name: Version ${{ steps.get_version.outputs.VERSION }} |
| 101 | + draft: true |
| 102 | + prerelease: false |
| 103 | + files: | |
| 104 | + idf-monitor-v${{ steps.get_version.outputs.VERSION }}-*.zip |
| 105 | + idf-monitor-v${{ steps.get_version.outputs.VERSION }}-*.tar.gz |
0 commit comments