|
| 1 | +name: platformio |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ '*' ] |
| 6 | + tags: [ 'v*' ] |
| 7 | + pull_request: |
| 8 | + branches: [ '*' ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + |
| 12 | + build: |
| 13 | + needs: test |
| 14 | + runs-on: ubuntu-22.04 |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + target: ['esp32', 'esp8266'] |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - name: Extract Version |
| 21 | + run: | |
| 22 | + echo "build_name=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 23 | + echo "build_branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV |
| 24 | + echo "build_tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
| 25 | + echo "build_sha=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_ENV |
| 26 | +
|
| 27 | + - name: Make Version |
| 28 | + run: | |
| 29 | + echo "build_file_devel=espfc_${{ env.build_sha }}_${{ matrix.target }}" >> $GITHUB_ENV |
| 30 | + echo "build_file_release=espfc_${{ env.build_tag }}_${{ matrix.target }}" >> $GITHUB_ENV |
| 31 | +
|
| 32 | + - name: Print Version |
| 33 | + run: | |
| 34 | + echo SHA: ${{ env.build_sha }} |
| 35 | + echo TAG: ${{ env.build_tag }} |
| 36 | + echo BRANCH: ${{ env.build_branch }} |
| 37 | + echo NAME: ${{ env.build_name }} |
| 38 | + echo DEVEL: ${{ env.build_file_devel }} |
| 39 | + echo RELEASE: ${{ env.build_file_release }} |
| 40 | +
|
| 41 | + - name: Cache pip |
| 42 | + uses: actions/cache@v4 |
| 43 | + with: |
| 44 | + path: ~/.cache/pip |
| 45 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 46 | + restore-keys: | |
| 47 | + ${{ runner.os }}-pip- |
| 48 | +
|
| 49 | + - name: Cache PlatformIO |
| 50 | + uses: actions/cache@v4 |
| 51 | + with: |
| 52 | + path: ~/.platformio |
| 53 | + key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} |
| 54 | + |
| 55 | + - name: Set up Python |
| 56 | + uses: actions/setup-python@v5 |
| 57 | + with: |
| 58 | + python-version: '3.10' |
| 59 | + |
| 60 | + - name: Install Dependencies |
| 61 | + run: | |
| 62 | + python -m pip install --upgrade pip |
| 63 | + pip install platformio |
| 64 | +
|
| 65 | + - name: Build Development Target |
| 66 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 67 | + run: | |
| 68 | + platformio run -e ${{ matrix.target }} |
| 69 | + env: |
| 70 | + PLATFORMIO_BUILD_FLAGS: -DESPFC_REVISION=${{ env.build_sha }} |
| 71 | + |
| 72 | + - name: Build Release Target |
| 73 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 74 | + run: | |
| 75 | + platformio run -e ${{ matrix.target }} |
| 76 | + env: |
| 77 | + PLATFORMIO_BUILD_FLAGS: -DESPFC_REVISION=${{ env.build_sha }} -DESPFC_VERSION=${{ env.build_tag }} |
| 78 | + |
| 79 | + - name: Create Development Artifact |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 82 | + with: |
| 83 | + name: ${{ env.build_file_devel }}.bin |
| 84 | + path: .pio/build/${{ matrix.target }}/firmware.bin |
| 85 | + |
| 86 | + - name: Create Development Artifact Merged |
| 87 | + uses: actions/upload-artifact@v4 |
| 88 | + if: ${{ !startsWith(github.ref, 'refs/tags/') && startsWith(matrix.target, 'esp32') }} |
| 89 | + with: |
| 90 | + name: "${{ env.build_file_devel }}_0x00.bin" |
| 91 | + path: .pio/build/${{ matrix.target }}/firmware_0x00.bin |
| 92 | + |
| 93 | + |
| 94 | + - name: Create Release Artifact |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 97 | + with: |
| 98 | + name: ${{ env.build_file_release }}.bin |
| 99 | + path: .pio/build/${{ matrix.target }}/firmware.bin |
| 100 | + |
| 101 | + - name: Create Release Artifact Merged |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + if: ${{ startsWith(github.ref, 'refs/tags/') && startsWith(matrix.target, 'esp32') }} |
| 104 | + with: |
| 105 | + name: ${{ env.build_file_release }}_0x00.bin |
| 106 | + path: .pio/build/${{ matrix.target }}/firmware_0x00.bin |
0 commit comments