Skip to content

Commit 7dc0808

Browse files
authored
Refactor GitHub Actions workflow for esptool builds
1 parent f5cc2e5 commit 7dc0808

File tree

1 file changed

+49
-129
lines changed

1 file changed

+49
-129
lines changed

.github/workflows/build_esptool.yml

Lines changed: 49 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -9,156 +9,76 @@ on:
99
- '.github/**' # Ignore changes towards the .github directory
1010

1111
jobs:
12-
build-esptool-binaries-arm:
13-
name: Build esptool binaries for ${{ matrix.platform }}
14-
runs-on: ubuntu-latest
15-
strategy:
16-
matrix:
17-
platform: [armv7, aarch64]
18-
env:
19-
DISTPATH: esptool-${{ matrix.platform }}
20-
STUBS_DIR: ./esptool/targets/stub_flasher/
21-
EFUSE_DIR: ./espefuse/efuse_defs/
22-
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
23-
steps:
24-
- name: Checkout repository
25-
uses: actions/checkout@v4
26-
- uses: uraimo/run-on-arch-action@v2
27-
name: Build and test in ${{ matrix.platform }}
28-
with:
29-
arch: ${{ matrix.platform }}
30-
distro: ubuntu22.04
31-
shell: /bin/bash
32-
# Not required, but speeds up builds by storing container images in
33-
# a GitHub package registry.
34-
githubToken: ${{ github.token }}
35-
# Create an artifacts directory
36-
setup: mkdir -p "${PWD}/${{ env.DISTPATH }}"
37-
dockerRunArgs: --volume "${PWD}/${{ env.DISTPATH }}:/${{ env.DISTPATH }}"
38-
install: |
39-
apt-get update -y
40-
apt-get install -y software-properties-common
41-
add-apt-repository -y ppa:deadsnakes/ppa
42-
apt-get update -y
43-
apt-get install --ignore-missing -y python3.11 python3.11-dev python3-pip pkg-config openssl libffi-dev libssl-dev cargo rustc
44-
python3.11 -m pip install --upgrade pip setuptools==74.1.3 wheel
45-
run: |
46-
python3.11 -m pip install --upgrade cffi
47-
adduser --disabled-password --gecos "" builder
48-
chmod -R a+rwx /home/runner/work/esptool
49-
su builder <<EOF
50-
export PATH=\$PATH:/home/builder/.local/bin
51-
52-
# Patch version for dev releases
53-
if [[ "${{ github.ref_name }}" == *"dev"* ]]; then
54-
echo "Patching version for dev release: ${{ github.ref_name }}"
55-
python3.11 ci/patch_dev_release.py --version ${{ github.ref_name }} esptool/__init__.py
56-
git diff
57-
fi
58-
59-
# Install dependencies
60-
python3.11 -m pip install pyinstaller==6.11.1
61-
python3.11 -m pip install --user -e .
62-
63-
# Build with PyInstaller
64-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico --add-data="${{ env.STUBS_DIR }}1/*.json:${{ env.STUBS_DIR }}1/" --add-data="${{ env.STUBS_DIR }}2/*.json:${{ env.STUBS_DIR }}2/" esptool.py
65-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico --add-data="${{ env.EFUSE_DIR }}*.yaml:${{ env.EFUSE_DIR }}" espefuse.py
66-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico espsecure.py
67-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico esp_rfc2217_server.py
68-
69-
# Test binaries
70-
./${{ env.DISTPATH }}/esptool -h || exit 1
71-
./${{ env.DISTPATH }}/espefuse -h || exit 1
72-
./${{ env.DISTPATH }}/espsecure -h || exit 1
73-
./${{ env.DISTPATH }}/esp_rfc2217_server -h || exit 1
74-
75-
- name: Archive artifact
76-
uses: actions/upload-artifact@v4
77-
with:
78-
name: ${{ env.DISTPATH }}
79-
path: ${{ env.DISTPATH }}
80-
8112
build-esptool-binaries:
8213
name: Build esptool binaries for ${{ matrix.platform }}
83-
runs-on: ${{ matrix.RUN_ON }}
14+
runs-on: ${{ matrix.runner }}
8415
strategy:
8516
matrix:
86-
platform: [macos-amd64, macos-arm64, linux-amd64]
17+
platform: [linux-amd64, macos-amd64, macos-arm64, linux-armv7, linux-aarch64]
8718
include:
88-
- platform: macos-amd64
89-
TARGET: macos-amd64
90-
SEPARATOR: ':'
91-
RUN_ON: macos-13 # Versions 13 and lower are Intel-based.
92-
- platform: macos-arm64
93-
TARGET: macos-arm64
94-
SEPARATOR: ':'
95-
RUN_ON: macos-latest # Versions 14 and higher are ARM-based.
96-
# - platform: windows
97-
# TARGET: win64
98-
# EXTEN: .exe
99-
# SEPARATOR: ';'
100-
# RUN_ON: windows-latest
101-
- platform: linux-amd64
102-
TARGET: linux-amd64
103-
SEPARATOR: ':'
104-
RUN_ON: ubuntu-22.04
19+
# - platform: windows-amd64
20+
# runner: windows-latest
21+
- platform: linux-amd64
22+
runner: ubuntu-latest
23+
- platform: macos-amd64
24+
runner: macos-13
25+
- platform: macos-arm64
26+
runner: macos-latest
27+
- platform: linux-armv7
28+
runner: ubuntu-latest
29+
- platform: linux-aarch64
30+
runner: ubuntu-24.04-arm
10531
env:
106-
DISTPATH: esptool-${{ matrix.TARGET }}
32+
DISTPATH: esptool-${{ matrix.platform }}
10733
STUBS_DIR: ./esptool/targets/stub_flasher/
10834
EFUSE_DIR: ./espefuse/efuse_defs/
109-
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
11035
steps:
11136
- name: Checkout repository
11237
uses: actions/checkout@v4
113-
- name: Set up Python 3.11
38+
39+
- name: Set up Python 3.13
11440
uses: actions/setup-python@v5
41+
if: (matrix.platform != 'linux-armv7') || contains(github.ref_name, 'dev')
11542
with:
116-
python-version: 3.11
117-
- name: Update esptool version when releasing
118-
if: startsWith(github.ref, 'refs/tags/')
119-
run: |
120-
python ci/patch_release.py --version ${{ github.ref_name }} esptool/__init__.py
121-
#git diff
122-
- name: Install dependencies
123-
run: |
124-
python -m pip install --upgrade pip
125-
pip install pyinstaller==6.11.1
126-
pip install --user -e .
43+
python-version: "3.13"
44+
# Python is used only to apply dev-release patch on Linux runners and no packages are installed as the build happens in the container
45+
cache: ${{ matrix.platform != 'linux-armv7' && matrix.platform != 'linux-aarch64' && matrix.platform != 'linux-amd64' && 'pip' || '' }}
12746
- name: Patch version for dev releases
12847
if: contains(github.ref_name, 'dev')
12948
run: |
13049
echo "Patching version for dev release: ${{ github.ref_name }}"
13150
python ci/patch_dev_release.py --version ${{ github.ref_name }} esptool/__init__.py
13251
git diff
13352
- name: Build with PyInstaller
134-
run: |
135-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico --add-data="${{ env.STUBS_DIR }}1/*.json${{ matrix.SEPARATOR }}${{ env.STUBS_DIR }}1/" --add-data="${{ env.STUBS_DIR }}2/*.json${{ matrix.SEPARATOR }}${{ env.STUBS_DIR }}2/" esptool.py
136-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico --add-data="${{ env.EFUSE_DIR }}*.yaml${{ matrix.SEPARATOR }}${{ env.EFUSE_DIR }}" espefuse.py
137-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico espsecure.py
138-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico esp_rfc2217_server.py
139-
- name: Sign binaries
140-
if: matrix.platform == 'windows' && github.event_name != 'pull_request' && github.repository == 'espressif/esptool'
141-
env:
142-
CERTIFICATE: ${{ secrets.CERTIFICATE }}
143-
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
144-
shell: pwsh
145-
run: |
146-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esptool.exe
147-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espefuse.exe
148-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espsecure.exe
149-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esp_rfc2217_server.exe
150-
- name: Test binaries
151-
shell: bash
152-
run: |
153-
./${{ env.DISTPATH }}/esptool${{ matrix.EXTEN }} -h
154-
./${{ env.DISTPATH }}/espefuse${{ matrix.EXTEN }} -h
155-
./${{ env.DISTPATH }}/espsecure${{ matrix.EXTEN }} -h
156-
./${{ env.DISTPATH }}/esp_rfc2217_server${{ matrix.EXTEN }} -h
53+
uses: espressif/python-binary-action@master
54+
with:
55+
scripts: 'esptool.py espefuse.py espsecure.py esp_rfc2217_server.py'
56+
output-dir: ./${{ env.DISTPATH }}
57+
include-data-dirs: |
58+
{
59+
"esptool.py": [
60+
"${{ env.STUBS_DIR }}1",
61+
"${{ env.STUBS_DIR }}2"
62+
],
63+
"espefuse.py": [
64+
"${{ env.EFUSE_DIR }}"
65+
]
66+
}
67+
icon-file: ${{ matrix.platform == 'windows-amd64' && 'ci/espressif.ico' || '' }}
68+
target-platform: ${{ matrix.platform }}
69+
additional-arm-packages: 'openssl libffi-dev libssl-dev libffi7'
70+
certificate: ${{ secrets.CERTIFICATE }}
71+
certificate-password: ${{ secrets.CERTIFICATE_PASSWORD }}
72+
15773
- name: Archive artifact
15874
uses: actions/upload-artifact@v4
15975
with:
16076
name: ${{ env.DISTPATH }}
16177
path: ${{ env.DISTPATH }}
78+
- name: Update esptool version when releasing
79+
if: startsWith(github.ref, 'refs/tags/')
80+
run: |
81+
python ci/patch_release.py --version ${{ github.ref_name }} esptool/__init__.py
16282
- name: Update package.json when a release tag is set
16383
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64'
16484
run: |
@@ -196,7 +116,7 @@ jobs:
196116

197117
release:
198118
name: Upload release binaries
199-
needs: [build-esptool-binaries, build-esptool-binaries-arm, push_stubs]
119+
needs: [push_stubs]
200120
if: startsWith(github.ref, 'refs/tags/')
201121
runs-on: ubuntu-latest
202122
steps:
@@ -213,12 +133,12 @@ jobs:
213133
uses: actions/download-artifact@v4
214134
- name: Rename and package binaries
215135
run: |
216-
zip -r esptool-armv7.zip ./esptool-armv7
217-
zip -r esptool-aarch64.zip ./esptool-aarch64
136+
zip -r esptool-linux-armv7.zip ./esptool-linux-armv7
137+
zip -r esptool-linux-aarch64.zip ./esptool-linux-aarch64
218138
zip -r esptool-macos-arm64.zip ./esptool-macos-arm64
219139
zip -r esptool-macos-amd64.zip ./esptool-macos-amd64
220140
zip -r esptool-linux-amd64.zip ./esptool-linux-amd64
221-
# zip -r esptool-win64.zip ./esptool-win64
141+
# zip -r esptool-windows-amd64.zip ./esptool-windows-amd64
222142
- name: Release
223143
uses: jason2866/[email protected]
224144
with:

0 commit comments

Comments
 (0)