|
| 1 | +name: Build esptool |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-esptool-binaries: |
| 7 | + name: Build esptool binaries for ${{ matrix.os }} |
| 8 | + runs-on: ${{ matrix.os }} |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + os: [macos-latest, ubuntu-latest, windows-latest] |
| 12 | + include: |
| 13 | + - os: macos-latest |
| 14 | + TARGET: macos |
| 15 | + - os: ubuntu-latest |
| 16 | + TARGET: linux-amd64 |
| 17 | + - os: windows-latest |
| 18 | + TARGET: win64 |
| 19 | + EXTEN: .exe |
| 20 | + env: |
| 21 | + DISTPATH: esptool-${{ matrix.TARGET }} |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v1 |
| 25 | + - name: Set up Python 3.8 |
| 26 | + uses: actions/setup-python@v1 |
| 27 | + with: |
| 28 | + python-version: 3.8 |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + pip install pyinstaller |
| 33 | + pip install --user -e . |
| 34 | + - name: Build with PyInstaller |
| 35 | + run: | |
| 36 | + pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=build_tools/espressif.ico esptool.py |
| 37 | + pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=build_tools/espressif.ico espefuse.py |
| 38 | + pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=build_tools/espressif.ico espsecure.py |
| 39 | + pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=build_tools/espressif.ico esp_rfc2217_server.py |
| 40 | + - name: Sign binaries |
| 41 | + if: matrix.os == 'windows-latest' |
| 42 | + env: |
| 43 | + CERTIFICATE: ${{ secrets.CERTIFICATE }} |
| 44 | + CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} |
| 45 | + shell: pwsh |
| 46 | + run: | |
| 47 | + ./build_tools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esptool.exe |
| 48 | + ./build_tools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espefuse.exe |
| 49 | + ./build_tools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espsecure.exe |
| 50 | + ./build_tools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esp_rfc2217_server.exe |
| 51 | + - name: Test binaries |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + ./${{ env.DISTPATH }}/esptool${{ matrix.EXTEN }} -h |
| 55 | + ./${{ env.DISTPATH }}/espefuse${{ matrix.EXTEN }} -h |
| 56 | + ./${{ env.DISTPATH }}/espsecure${{ matrix.EXTEN }} -h |
| 57 | + ./${{ env.DISTPATH }}/esp_rfc2217_server${{ matrix.EXTEN }} -h |
| 58 | + - name: Add license and readme |
| 59 | + shell: bash |
| 60 | + run: mv LICENSE README.md ./${{ env.DISTPATH }} |
| 61 | + - name: Archive artifact |
| 62 | + uses: actions/upload-artifact@v2 |
| 63 | + with: |
| 64 | + name: ${{ env.DISTPATH }} |
| 65 | + path: ${{ env.DISTPATH }} |
| 66 | + |
| 67 | + create_release: |
| 68 | + name: Create GitHub release |
| 69 | + if: startsWith(github.ref, 'refs/tags/') |
| 70 | + needs: build-esptool-binaries |
| 71 | + runs-on: ubuntu-latest |
| 72 | + outputs: |
| 73 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 74 | + VERSION: ${{ steps.get_version.outputs.VERSION }} |
| 75 | + steps: |
| 76 | + - name: Create release |
| 77 | + id: create_release |
| 78 | + uses: actions/create-release@v1 |
| 79 | + env: |
| 80 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + with: |
| 82 | + tag_name: ${{ github.ref }} |
| 83 | + release_name: Version ${{ github.ref }} |
| 84 | + draft: true |
| 85 | + prerelease: false |
| 86 | + - name: Get version |
| 87 | + id: get_version |
| 88 | + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} |
| 89 | + shell: bash |
| 90 | + |
| 91 | + upload_assets: |
| 92 | + name: Upload release assets |
| 93 | + if: startsWith(github.ref, 'refs/tags/') |
| 94 | + needs: create_release |
| 95 | + runs-on: ubuntu-latest |
| 96 | + strategy: |
| 97 | + matrix: |
| 98 | + TARGET: [macos, linux-amd64, win64] |
| 99 | + env: |
| 100 | + DISTPATH: esptool-${{ needs.create_release.outputs.VERSION }}-${{ matrix.TARGET }} |
| 101 | + steps: |
| 102 | + - name: Download built binaries |
| 103 | + uses: actions/download-artifact@v2 |
| 104 | + - name: Rename and package binaries |
| 105 | + run: | |
| 106 | + mv esptool-${{ matrix.TARGET }} ${{ env.DISTPATH }} |
| 107 | + zip -r ${{ env.DISTPATH }}.zip ./${{ env.DISTPATH }}/* |
| 108 | + - name: Upload release assets |
| 109 | + id: upload-release-asset |
| 110 | + uses: actions/upload-release-asset@v1 |
| 111 | + env: |
| 112 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 113 | + with: |
| 114 | + upload_url: ${{ needs.create_release.outputs.upload_url }} |
| 115 | + asset_path: "${{ env.DISTPATH }}.zip" |
| 116 | + asset_name: "${{ env.DISTPATH }}.zip" |
| 117 | + asset_content_type: application/zip |
0 commit comments