From 059f0b761d506111281af6d6792ea5313acb0020 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:44:34 +0200 Subject: [PATCH] Update build_esptool.yml --- .github/workflows/build_esptool.yml | 170 ++++++++++++++-------------- 1 file changed, 88 insertions(+), 82 deletions(-) diff --git a/.github/workflows/build_esptool.yml b/.github/workflows/build_esptool.yml index 57e6d92e2..faff0fec1 100644 --- a/.github/workflows/build_esptool.yml +++ b/.github/workflows/build_esptool.yml @@ -1,39 +1,34 @@ name: Build esptool -on: [push, pull_request] +on: + workflow_dispatch: + push: + tags: + - "v*.*.*" + paths-ignore: + - '.github/**' # Ignore changes towards the .github directory jobs: build-esptool-binaries: - name: Build esptool binaries for ${{ matrix.platform }} - runs-on: ${{ matrix.RUN_ON }} + name: Build esptool binaries for ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: matrix: - platform: [macos, windows, linux-amd64, linux-arm32, linux-arm64] + os: [macos-14, macos-13, ubuntu-latest, windows-latest] include: - - platform: macos + - os: macos-14 + TARGET: macos-arm + SEPARATOR: ':' + - os: macos-13 TARGET: macos SEPARATOR: ':' - RUN_ON: macos-latest - - platform: windows + - os: ubuntu-latest + TARGET: linux-amd64 + SEPARATOR: ':' + - os: windows-latest TARGET: win64 EXTEN: .exe SEPARATOR: ';' - RUN_ON: windows-latest - - platform: linux-amd64 - TARGET: linux-amd64 - SEPARATOR: ':' - RUN_ON: ubuntu-20.04 - - platform: linux-arm32 - CONTAINER: python:3.8-bullseye - TARGET: linux-arm32 - SEPARATOR: ':' - RUN_ON: [ARM, self-hosted, linux, docker] - - platform: linux-arm64 - CONTAINER: python:3.8-bullseye - TARGET: linux-arm64 - SEPARATOR: ':' - RUN_ON: [ARM64, self-hosted, linux] - container: ${{ matrix.CONTAINER }} # use python container on ARM env: DISTPATH: esptool-${{ matrix.TARGET }} STUBS_DIR: ./esptool/targets/stub_flasher/ @@ -41,13 +36,18 @@ jobs: PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi" steps: - name: Checkout repository - uses: actions/checkout@master - - name: Set up Python 3.8 - # Skip setting python on ARM because of missing compatibility: https://github.com/actions/setup-python/issues/108 - if: matrix.platform != 'linux-arm32' && matrix.platform != 'linux-arm64' - uses: actions/setup-python@master + uses: actions/checkout@v4 + with: + ref: main_work + - name: Set up Python 3.11 + uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.11 + - name: Update esptool version when releasing + if: startsWith(github.ref, 'refs/tags/') + run: | + python ci/patch_release.py --version ${{ github.ref_name }} esptool/__init__.py + #git diff - name: Install dependencies # PyInstaller >=6.0 results in significantly more antivirus false positives run: | @@ -60,17 +60,6 @@ jobs: pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico --add-data="${{ env.EFUSE_DIR }}*.yaml${{ matrix.SEPARATOR }}${{ env.EFUSE_DIR }}" espefuse.py pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico espsecure.py pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico esp_rfc2217_server.py - - name: Sign binaries - if: matrix.platform == 'windows' && github.event_name != 'pull_request' - env: - CERTIFICATE: ${{ secrets.CERTIFICATE }} - CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} - shell: pwsh - run: | - ./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esptool.exe - ./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espefuse.exe - ./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espsecure.exe - ./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esp_rfc2217_server.exe - name: Test binaries shell: bash run: | @@ -78,56 +67,73 @@ jobs: ./${{ env.DISTPATH }}/espefuse${{ matrix.EXTEN }} -h ./${{ env.DISTPATH }}/espsecure${{ matrix.EXTEN }} -h ./${{ env.DISTPATH }}/esp_rfc2217_server${{ matrix.EXTEN }} -h - - name: Add license and readme - shell: bash - run: mv LICENSE README.md ./${{ env.DISTPATH }} - name: Archive artifact uses: actions/upload-artifact@master with: name: ${{ env.DISTPATH }} path: ${{ env.DISTPATH }} + - name: Update package.json when a release tag is set + if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' + run: | + rm package.json + python ci/gen_pio_manifest.py -o "./" -s ${{ github.ref_name }} + - name: Upload package.json artifact + if: matrix.os == 'ubuntu-latest' + uses: jason2866/upload-artifact@v2.0.3 + with: + name: manifest + path: /home/runner/work/esptool/esptool/package.json - create_release: - name: Create GitHub release - if: startsWith(github.ref, 'refs/tags/') && !(contains(github.ref_name, 'dev')) + push_stubs: + name: Commit changed package.json needs: build-esptool-binaries runs-on: ubuntu-latest - env: - PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi" - permissions: - contents: write steps: - - name: Get version - id: get_version - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT - shell: bash - - name: Checkout - uses: actions/checkout@master + - name: Checkout repository + uses: actions/checkout@v4 with: - fetch-depth: 0 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install --user -e ".[dev]" - - name: Generate changelog - run: | - cz changelog ${{ steps.get_version.outputs.VERSION }} --template ci/gh_changelog_template.md.j2 --file-name changelog_body.md - cat changelog_body.md - - name: Download built binaries - uses: actions/download-artifact@master - - name: Compress and rename binaries - run: | - for dir in esptool-*; do - zip -r "esptool-v${{ steps.get_version.outputs.VERSION }}-${dir#esptool-}.zip" "$dir" - done - - name: Create release - id: create_release - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ref: main_work + - name: Download artifacts + uses: jason2866/download-artifact@v3.0.4 + with: + name: | + manifest + path: | + ./ + - uses: stefanzweifel/git-auto-commit-action@v5 with: - body_path: changelog_body.md - name: Version ${{ steps.get_version.outputs.VERSION }} - draft: true - prerelease: false - files: esptool-v${{ steps.get_version.outputs.VERSION }}-*.zip + commit_message: update manifest + + release: + name: Upload release binaries + needs: build-esptool-binaries + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: main_work + - name: Zip esptool.py + run: | + echo "Packaging new esptool release: ${{ github.ref_name }}" + python ci/patch_release.py --version ${{ github.ref_name }} esptool/__init__.py + rm package.json + python ci/gen_pio_manifest.py -o "./" -s ${{ github.ref_name }} + python ci/pack_python.py + - name: Download built binaries + uses: actions/download-artifact@master + - name: Rename and package binaries + run: | + zip -r esptool-macos-arm.zip ./esptool-macos-arm + zip -r esptool-macos.zip ./esptool-macos + zip -r esptool-linux-amd64.zip ./esptool-linux-amd64 + zip -r esptool-win64.zip ./esptool-win64 + - name: Release + uses: jason2866/action-gh-release@v1.3 + with: + prerelease: false + files: | + *.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}