Refactor GitHub Actions workflow for esptool builds #68
Workflow file for this run
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
name: Build esptool | |
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.runner }} | |
strategy: | |
matrix: | |
platform: [linux-amd64, macos-amd64, macos-arm64, linux-armv7, linux-aarch64] | |
include: | |
# - platform: windows-amd64 | |
# runner: windows-latest | |
- platform: linux-amd64 | |
runner: ubuntu-latest | |
- platform: macos-amd64 | |
runner: macos-13 | |
- platform: macos-arm64 | |
runner: macos-latest | |
- platform: linux-armv7 | |
runner: ubuntu-latest | |
- platform: linux-aarch64 | |
runner: ubuntu-24.04-arm | |
env: | |
DISTPATH: esptool-${{ matrix.platform }} | |
STUBS_DIR: ./esptool/targets/stub_flasher/ | |
EFUSE_DIR: ./espefuse/efuse_defs/ | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.13 | |
uses: actions/setup-python@v5 | |
if: (matrix.platform != 'linux-armv7') || contains(github.ref_name, 'dev') | |
with: | |
python-version: "3.13" | |
# Python is used only to apply dev-release patch on Linux runners and no packages are installed as the build happens in the container | |
cache: ${{ matrix.platform != 'linux-armv7' && matrix.platform != 'linux-aarch64' && matrix.platform != 'linux-amd64' && 'pip' || '' }} | |
- name: Patch version for dev releases | |
if: contains(github.ref_name, 'dev') | |
run: | | |
echo "Patching version for dev release: ${{ github.ref_name }}" | |
python ci/patch_dev_release.py --version ${{ github.ref_name }} esptool/__init__.py | |
git diff | |
- name: Build with PyInstaller | |
uses: espressif/python-binary-action@master | |
with: | |
scripts: 'esptool.py espefuse.py espsecure.py esp_rfc2217_server.py' | |
output-dir: ./${{ env.DISTPATH }} | |
include-data-dirs: | | |
{ | |
"esptool.py": [ | |
"${{ env.STUBS_DIR }}1", | |
"${{ env.STUBS_DIR }}2" | |
], | |
"espefuse.py": [ | |
"${{ env.EFUSE_DIR }}" | |
] | |
} | |
icon-file: ${{ matrix.platform == 'windows-amd64' && 'ci/espressif.ico' || '' }} | |
target-platform: ${{ matrix.platform }} | |
additional-arm-packages: 'openssl libffi-dev libssl-dev libffi7' | |
certificate: ${{ secrets.CERTIFICATE }} | |
certificate-password: ${{ secrets.CERTIFICATE_PASSWORD }} | |
- name: Archive artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.DISTPATH }} | |
path: ${{ env.DISTPATH }} | |
- 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 | |
- name: Update package.json when a release tag is set | |
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64' | |
run: | | |
rm -f package.json | |
python ci/gen_pio_manifest.py -o "./" -s ${{ github.ref_name }} | |
- name: Upload package.json artifact | |
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: manifest | |
path: /home/runner/work/esptool/esptool/package.json | |
push_stubs: | |
name: Commit changed package.json | |
needs: build-esptool-binaries | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: pioarduino | |
if: startsWith(github.ref, 'refs/tags/') | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
name: | | |
manifest | |
path: | | |
./ | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
commit_message: update manifest | |
release: | |
name: Upload release binaries | |
needs: [push_stubs] | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- 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@v4 | |
- name: Rename and package binaries | |
run: | | |
zip -r esptool-linux-armv7.zip ./esptool-linux-armv7 | |
zip -r esptool-linux-aarch64.zip ./esptool-linux-aarch64 | |
zip -r esptool-macos-arm64.zip ./esptool-macos-arm64 | |
zip -r esptool-macos-amd64.zip ./esptool-macos-amd64 | |
zip -r esptool-linux-amd64.zip ./esptool-linux-amd64 | |
# zip -r esptool-windows-amd64.zip ./esptool-windows-amd64 | |
- name: Release | |
uses: jason2866/[email protected] | |
with: | |
prerelease: false | |
files: | | |
*.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |