Skip to content

Commit 61bc166

Browse files
peterdragundobairoland
authored andcommitted
ci(actions): Use new pyinstaller shared build action
1 parent a977cdf commit 61bc166

File tree

1 file changed

+51
-119
lines changed

1 file changed

+51
-119
lines changed

.github/workflows/build_esptool.yml

Lines changed: 51 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -3,148 +3,81 @@ name: Build esptool
33
on: [push, pull_request]
44

55
jobs:
6-
build-esptool-binaries-arm:
7-
name: Build esptool binaries for ${{ matrix.platform }}
8-
runs-on: ubuntu-latest
9-
strategy:
10-
matrix:
11-
platform: [armv7, aarch64]
12-
env:
13-
DISTPATH: esptool-linux-${{ matrix.platform }}
14-
STUBS_DIR: ./esptool/targets/stub_flasher/
15-
EFUSE_DIR: ./espefuse/efuse_defs/
16-
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
17-
steps:
18-
- name: Checkout repository
19-
uses: actions/checkout@master
20-
- uses: uraimo/run-on-arch-action@v2
21-
name: Build and test in ${{ matrix.platform }}
22-
with:
23-
arch: ${{ matrix.platform }}
24-
distro: ubuntu22.04
25-
shell: /bin/bash
26-
# Not required, but speeds up builds by storing container images in
27-
# a GitHub package registry.
28-
githubToken: ${{ github.token }}
29-
# Create an artifacts directory
30-
setup: mkdir -p "${PWD}/${{ env.DISTPATH }}"
31-
dockerRunArgs: --volume "${PWD}/${{ env.DISTPATH }}:/${{ env.DISTPATH }}"
32-
install: |
33-
apt-get update -y
34-
apt-get install -y software-properties-common
35-
add-apt-repository -y ppa:deadsnakes/ppa
36-
apt-get update -y
37-
apt-get install --ignore-missing -y python3.11 python3.11-dev python3-pip pkg-config openssl libffi-dev libssl-dev cargo rustc
38-
python3.11 -m pip install --upgrade pip setuptools wheel
39-
run: |
40-
python3.11 -m pip install --upgrade cffi
41-
adduser --disabled-password --gecos "" builder
42-
chmod -R a+rwx /home/runner/work/esptool
43-
su builder <<EOF
44-
export PATH=\$PATH:/home/builder/.local/bin
45-
# Install dependencies
46-
python3.11 -m pip install pyinstaller==6.11.1
47-
python3.11 -m pip install --user -e .
48-
49-
# Build with PyInstaller
50-
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
51-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico --add-data="${{ env.EFUSE_DIR }}*.yaml:${{ env.EFUSE_DIR }}" espefuse.py
52-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico espsecure.py
53-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico esp_rfc2217_server.py
54-
55-
# Test binaries
56-
./${{ env.DISTPATH }}/esptool -h || exit 1
57-
./${{ env.DISTPATH }}/espefuse -h || exit 1
58-
./${{ env.DISTPATH }}/espsecure -h || exit 1
59-
./${{ env.DISTPATH }}/esp_rfc2217_server -h || exit 1
60-
61-
# Add license and readme
62-
mv LICENSE README.md ./${{ env.DISTPATH }}
63-
64-
- name: Archive artifact
65-
uses: actions/upload-artifact@master
66-
with:
67-
name: ${{ env.DISTPATH }}
68-
path: ${{ env.DISTPATH }}
69-
706
build-esptool-binaries:
717
name: Build esptool binaries for ${{ matrix.platform }}
72-
runs-on: ${{ matrix.RUN_ON }}
8+
runs-on: ${{ matrix.runner }}
739
strategy:
7410
matrix:
75-
platform: [macos-amd64, macos-arm64, windows, linux-amd64]
11+
platform: [windows-amd64, linux-amd64, macos-amd64, macos-arm64, linux-armv7, linux-aarch64]
7612
include:
77-
- platform: macos-amd64
78-
TARGET: macos-amd64
79-
SEPARATOR: ':'
80-
RUN_ON: macos-13 # Versions 13 and lower are Intel-based.
81-
- platform: macos-arm64
82-
TARGET: macos-arm64
83-
SEPARATOR: ':'
84-
RUN_ON: macos-latest # Versions 14 and higher are ARM-based.
85-
- platform: windows
86-
TARGET: windows-amd64
87-
EXTEN: .exe
88-
SEPARATOR: ';'
89-
RUN_ON: windows-latest
90-
- platform: linux-amd64
91-
TARGET: linux-amd64
92-
SEPARATOR: ':'
93-
RUN_ON: ubuntu-22.04
13+
- platform: windows-amd64
14+
runner: windows-latest
15+
- platform: linux-amd64
16+
runner: ubuntu-latest
17+
- platform: macos-amd64
18+
runner: macos-13
19+
- platform: macos-arm64
20+
runner: macos-latest
21+
- platform: linux-armv7
22+
runner: ubuntu-latest
23+
- platform: linux-aarch64
24+
runner: ubuntu-24.04-arm
9425
env:
95-
DISTPATH: esptool-${{ matrix.TARGET }}
26+
DISTPATH: esptool-${{ matrix.platform }}
9627
STUBS_DIR: ./esptool/targets/stub_flasher/
9728
EFUSE_DIR: ./espefuse/efuse_defs/
98-
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
9929
steps:
10030
- name: Checkout repository
101-
uses: actions/checkout@master
102-
- name: Set up Python 3.11
103-
uses: actions/setup-python@master
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Python 3.13
34+
uses: actions/setup-python@v5
35+
if: (matrix.platform != 'linux-armv7') || contains(github.ref_name, 'dev')
10436
with:
105-
python-version: "3.11"
106-
- name: Install dependencies
37+
python-version: "3.13"
38+
# Python is used only to apply dev-release patch on Linux runners and no packages are installed as the build happens in the container
39+
cache: ${{ matrix.platform != 'linux-armv7' && matrix.platform != 'linux-aarch64' && matrix.platform != 'linux-amd64' && 'pip' || '' }}
40+
- name: Patch version for dev releases
41+
if: contains(github.ref_name, 'dev')
10742
run: |
108-
python -m pip install --upgrade pip
109-
pip install pyinstaller==6.11.1
110-
pip install --user -e .
43+
echo "Patching version for dev release: ${{ github.ref_name }}"
44+
python ci/patch_dev_release.py --version ${{ github.ref_name }} esptool/__init__.py
45+
git diff
11146
- name: Build with PyInstaller
112-
run: |
113-
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
114-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico --add-data="${{ env.EFUSE_DIR }}*.yaml${{ matrix.SEPARATOR }}${{ env.EFUSE_DIR }}" espefuse.py
115-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico espsecure.py
116-
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico esp_rfc2217_server.py
117-
- name: Sign binaries
118-
if: matrix.platform == 'windows' && github.event_name != 'pull_request' && github.repository == 'espressif/esptool'
119-
env:
120-
CERTIFICATE: ${{ secrets.CERTIFICATE }}
121-
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
122-
shell: pwsh
123-
run: |
124-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esptool.exe
125-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espefuse.exe
126-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espsecure.exe
127-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esp_rfc2217_server.exe
128-
- name: Test binaries
129-
shell: bash
130-
run: |
131-
./${{ env.DISTPATH }}/esptool${{ matrix.EXTEN }} -h
132-
./${{ env.DISTPATH }}/espefuse${{ matrix.EXTEN }} -h
133-
./${{ env.DISTPATH }}/espsecure${{ matrix.EXTEN }} -h
134-
./${{ env.DISTPATH }}/esp_rfc2217_server${{ matrix.EXTEN }} -h
47+
uses: espressif/python-binary-action@master
48+
with:
49+
scripts: 'esptool.py espefuse.py espsecure.py esp_rfc2217_server.py'
50+
output-dir: ./${{ env.DISTPATH }}
51+
include-data-dirs: |
52+
{
53+
"esptool.py": [
54+
"${{ env.STUBS_DIR }}1",
55+
"${{ env.STUBS_DIR }}2"
56+
],
57+
"espefuse.py": [
58+
"${{ env.EFUSE_DIR }}"
59+
]
60+
}
61+
icon-file: ${{ matrix.platform == 'windows-amd64' && 'ci/espressif.ico' || '' }}
62+
target-platform: ${{ matrix.platform }}
63+
additional-arm-packages: 'openssl libffi-dev libssl-dev libffi7'
64+
certificate: ${{ secrets.CERTIFICATE }}
65+
certificate-password: ${{ secrets.CERTIFICATE_PASSWORD }}
66+
13567
- name: Add license and readme
13668
shell: bash
13769
run: mv LICENSE README.md ./${{ env.DISTPATH }}
70+
13871
- name: Archive artifact
139-
uses: actions/upload-artifact@master
72+
uses: actions/upload-artifact@v4
14073
with:
14174
name: ${{ env.DISTPATH }}
14275
path: ${{ env.DISTPATH }}
14376

14477
create_release:
14578
name: Create GitHub release
14679
if: startsWith(github.ref, 'refs/tags/') && !(contains(github.ref_name, 'dev'))
147-
needs: [build-esptool-binaries, build-esptool-binaries-arm]
80+
needs: [build-esptool-binaries]
14881
runs-on: ubuntu-latest
14982
env:
15083
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
@@ -161,7 +94,6 @@ jobs:
16194
fetch-depth: 0
16295
- name: Install dependencies
16396
run: |
164-
python -m pip install --upgrade pip
16597
pip install --user -e ".[dev]"
16698
- name: Generate changelog
16799
run: |

0 commit comments

Comments
 (0)