Skip to content

Commit 784ff08

Browse files
authored
Changes pioarduino (#12)
* add OEM ESP32-S0WD-OEM * add release helpers
1 parent d3d6d7c commit 784ff08

File tree

8 files changed

+253
-65
lines changed

8 files changed

+253
-65
lines changed

.github/workflows/build_esptool.yml

Lines changed: 82 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Build esptool
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
paths-ignore:
9+
- '.github/**' # Ignore changes towards the .github directory
410

511
jobs:
612
build-esptool-binaries-arm:
@@ -10,13 +16,13 @@ jobs:
1016
matrix:
1117
platform: [armv7, aarch64]
1218
env:
13-
DISTPATH: esptool-linux-${{ matrix.platform }}
19+
DISTPATH: esptool-${{ matrix.platform }}
1420
STUBS_DIR: ./esptool/targets/stub_flasher/
1521
EFUSE_DIR: ./espefuse/efuse_defs/
1622
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
1723
steps:
1824
- name: Checkout repository
19-
uses: actions/checkout@master
25+
uses: actions/checkout@v4
2026
- uses: uraimo/run-on-arch-action@v2
2127
name: Build and test in ${{ matrix.platform }}
2228
with:
@@ -35,7 +41,7 @@ jobs:
3541
add-apt-repository -y ppa:deadsnakes/ppa
3642
apt-get update -y
3743
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
44+
python3.11 -m pip install --upgrade pip setuptools==74.1.3 wheel
3945
run: |
4046
python3.11 -m pip install --upgrade cffi
4147
adduser --disabled-password --gecos "" builder
@@ -58,11 +64,8 @@ jobs:
5864
./${{ env.DISTPATH }}/espsecure -h || exit 1
5965
./${{ env.DISTPATH }}/esp_rfc2217_server -h || exit 1
6066
61-
# Add license and readme
62-
mv LICENSE README.md ./${{ env.DISTPATH }}
63-
6467
- name: Archive artifact
65-
uses: actions/upload-artifact@master
68+
uses: actions/upload-artifact@v4
6669
with:
6770
name: ${{ env.DISTPATH }}
6871
path: ${{ env.DISTPATH }}
@@ -83,7 +86,7 @@ jobs:
8386
SEPARATOR: ':'
8487
RUN_ON: macos-latest # Versions 14 and higher are ARM-based.
8588
- platform: windows
86-
TARGET: windows-amd64
89+
TARGET: win64
8790
EXTEN: .exe
8891
SEPARATOR: ';'
8992
RUN_ON: windows-latest
@@ -98,11 +101,16 @@ jobs:
98101
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
99102
steps:
100103
- name: Checkout repository
101-
uses: actions/checkout@master
104+
uses: actions/checkout@v4
102105
- name: Set up Python 3.11
103-
uses: actions/setup-python@master
106+
uses: actions/setup-python@v5
104107
with:
105-
python-version: "3.11"
108+
python-version: 3.11
109+
- name: Update esptool version when releasing
110+
if: startsWith(github.ref, 'refs/tags/')
111+
run: |
112+
python ci/patch_release.py --version ${{ github.ref_name }} esptool/__init__.py
113+
#git diff
106114
- name: Install dependencies
107115
run: |
108116
python -m pip install --upgrade pip
@@ -132,63 +140,74 @@ jobs:
132140
./${{ env.DISTPATH }}/espefuse${{ matrix.EXTEN }} -h
133141
./${{ env.DISTPATH }}/espsecure${{ matrix.EXTEN }} -h
134142
./${{ env.DISTPATH }}/esp_rfc2217_server${{ matrix.EXTEN }} -h
135-
- name: Add license and readme
136-
shell: bash
137-
run: mv LICENSE README.md ./${{ env.DISTPATH }}
138143
- name: Archive artifact
139-
uses: actions/upload-artifact@master
144+
uses: actions/upload-artifact@v4
140145
with:
141146
name: ${{ env.DISTPATH }}
142147
path: ${{ env.DISTPATH }}
148+
- name: Update package.json when a release tag is set
149+
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64'
150+
run: |
151+
rm -f package.json
152+
python ci/gen_pio_manifest.py -o "./" -s ${{ github.ref_name }}
153+
- name: Upload package.json artifact
154+
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64'
155+
uses: actions/upload-artifact@v4
156+
with:
157+
name: manifest
158+
path: /home/runner/work/esptool/esptool/package.json
143159

144-
create_release:
145-
name: Create GitHub release
146-
if: startsWith(github.ref, 'refs/tags/') && !(contains(github.ref_name, 'dev'))
147-
needs: [build-esptool-binaries, build-esptool-binaries-arm]
160+
push_stubs:
161+
name: Commit changed package.json
162+
needs: build-esptool-binaries
148163
runs-on: ubuntu-latest
149-
env:
150-
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
151-
permissions:
152-
contents: write
153164
steps:
154-
- name: Get version
155-
id: get_version
156-
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
157-
shell: bash
158-
- name: Checkout
159-
uses: actions/checkout@master
165+
- name: Checkout repository
166+
uses: actions/checkout@v4
167+
if: startsWith(github.ref, 'refs/tags/')
168+
- name: Download artifacts
169+
uses: actions/download-artifact@v4
170+
if: startsWith(github.ref, 'refs/tags/')
160171
with:
161-
fetch-depth: 0
162-
- name: Install dependencies
163-
run: |
164-
python -m pip install --upgrade pip
165-
pip install --user -e ".[dev]"
166-
- name: Generate changelog
167-
run: |
168-
cz changelog ${{ steps.get_version.outputs.VERSION }} --template ci/gh_changelog_template.md.j2 --file-name changelog_body.md
169-
cat changelog_body.md
170-
- name: Download built binaries
171-
uses: actions/download-artifact@master
172-
- name: Compress and rename binaries
173-
run: |
174-
for dir in esptool-*; do
175-
if [[ "$dir" == esptool-win* ]]; then
176-
zip -r "esptool-v${{ steps.get_version.outputs.VERSION }}-${dir#esptool-}.zip" "$dir"
177-
else
178-
chmod -R u=rwx,g=rx,o=rx "$dir"
179-
tar -cvzf "esptool-v${{ steps.get_version.outputs.VERSION }}-${dir#esptool-}.tar.gz" "$dir"
180-
fi
181-
done
182-
- name: Create release
183-
id: create_release
184-
uses: softprops/action-gh-release@v1
185-
env:
186-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172+
name: |
173+
manifest
174+
path: |
175+
./
176+
- uses: stefanzweifel/git-auto-commit-action@v5
177+
if: startsWith(github.ref, 'refs/tags/')
187178
with:
188-
body_path: changelog_body.md
189-
name: Version ${{ steps.get_version.outputs.VERSION }}
190-
draft: true
191-
prerelease: false
192-
files: |
193-
esptool-v${{ steps.get_version.outputs.VERSION }}-*.zip
194-
esptool-v${{ steps.get_version.outputs.VERSION }}-*.tar.gz
179+
commit_message: update manifest
180+
181+
release:
182+
name: Upload release binaries
183+
needs: [build-esptool-binaries, build-esptool-binaries-arm, push_stubs]
184+
if: startsWith(github.ref, 'refs/tags/')
185+
runs-on: ubuntu-latest
186+
steps:
187+
- name: Checkout repository
188+
uses: actions/checkout@v4
189+
- name: Zip esptool.py
190+
run: |
191+
echo "Packaging new esptool release: ${{ github.ref_name }}"
192+
python ci/patch_release.py --version ${{ github.ref_name }} esptool/__init__.py
193+
rm package.json
194+
python ci/gen_pio_manifest.py -o "./" -s ${{ github.ref_name }}
195+
python ci/pack_python.py
196+
- name: Download built binaries
197+
uses: actions/download-artifact@v4
198+
- name: Rename and package binaries
199+
run: |
200+
zip -r esptool-armv7.zip ./esptool-armv7
201+
zip -r esptool-aarch64.zip ./esptool-aarch64
202+
zip -r esptool-macos-arm64.zip ./esptool-macos-arm64
203+
zip -r esptool-macos-amd64.zip ./esptool-macos-amd64
204+
zip -r esptool-linux-amd64.zip ./esptool-linux-amd64
205+
zip -r esptool-win64.zip ./esptool-win64
206+
- name: Release
207+
uses: jason2866/[email protected]
208+
with:
209+
prerelease: false
210+
files: |
211+
*.zip
212+
env:
213+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

ci/gen_pio_manifest.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# ruff: noqa
2+
import argparse
3+
import json
4+
import os
5+
import re
6+
import sys
7+
import datetime
8+
9+
MANIFEST_DATA = {
10+
"name": "tool-esptoolpy",
11+
"description": "A serial utility to communicate & flash code to Espressif chips",
12+
"keywords": ["tools", "uploader", "tasmota", "espressif", "esp8266", "esp32"],
13+
"license": "GPL-2.0-or-later",
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/tasmota/esptool",
17+
},
18+
}
19+
20+
21+
def convert_version(version_string):
22+
"""A helper function that converts a custom version string
23+
to a suitable SemVer alternative. For example:
24+
'release/v5.1' becomes '5.1.0',
25+
'v7.7.7' becomes '7.7.7'
26+
"""
27+
28+
regex_pattern = (
29+
r"v(?P<MAJOR>0|[1-9]\d*)\.(?P<MINOR>0|[1-9]\d*)\.*(?P<PATCH>0|[1-9]\d*)*"
30+
)
31+
match = re.search(regex_pattern, version_string)
32+
if not match:
33+
sys.stderr.write(
34+
f"No regex match found for '{regex_pattern}' in '{version_string}'\n"
35+
)
36+
return ""
37+
38+
major, minor, patch = match.groups()
39+
if not patch:
40+
patch = "0"
41+
42+
return ".".join((major, minor, patch))
43+
44+
45+
def main(dst_dir, version_string):
46+
47+
converted_version = convert_version(version_string)
48+
if not converted_version:
49+
sys.stderr.write(f"Failed to convert version '{version_string}'\n")
50+
return -1
51+
52+
manifest_file_path = os.path.join(dst_dir, "package.json")
53+
build_date = datetime.date.today()
54+
with open(manifest_file_path, "w", encoding="utf8") as fp:
55+
MANIFEST_DATA["version"] = f"{converted_version}"
56+
MANIFEST_DATA["date"] = f"{build_date}"
57+
json.dump(MANIFEST_DATA, fp, indent=2)
58+
59+
print(
60+
f"Generated '{manifest_file_path}' with '{converted_version}' version"
61+
)
62+
return 0
63+
64+
65+
if __name__ == "__main__":
66+
parser = argparse.ArgumentParser()
67+
parser.add_argument(
68+
"-o",
69+
"--dst-dir",
70+
dest="dst_dir",
71+
required=True,
72+
help="Destination where the 'package.json' will be located",
73+
)
74+
parser.add_argument(
75+
"-s",
76+
"--version-string",
77+
dest="version_string",
78+
required=True,
79+
help="Version string in format v*.*.*",
80+
)
81+
args = parser.parse_args()
82+
83+
sys.exit(main(args.dst_dir, args.version_string))

ci/pack_python.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
# ruff: noqa
3+
4+
import shutil
5+
import subprocess
6+
7+
8+
def main():
9+
10+
# remove not needed for plain python use
11+
shutil.rmtree("ci", ignore_errors=True)
12+
shutil.rmtree("docs", ignore_errors=True)
13+
shutil.rmtree("flasher_stub", ignore_errors=True)
14+
shutil.rmtree("test", ignore_errors=True)
15+
16+
zipfile = "esptool.zip"
17+
18+
print("Zip needed files into {}...".format(zipfile))
19+
subprocess.run(["/usr/bin/7z", "a", "-mx=9", "-tzip", "-xr!.*", zipfile, "./"], check=True) # noqa: E501
20+
21+
22+
if __name__ == "__main__":
23+
main()

ci/patch_release.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
#
3+
# SPDX-License-Identifier: GPL-2.0-or-later
4+
5+
# ruff: noqa
6+
import argparse
7+
import re
8+
9+
LINE_RE = re.compile(r"^__version__ = ['\"]([^'\"]*)['\"]")
10+
NEW_LINE = '__version__ = "{}"\n'
11+
12+
13+
def patch_file(path, new_version):
14+
new_version = new_version.lstrip("v")
15+
16+
with open(path, "r") as fin:
17+
lines = fin.readlines()
18+
19+
for i, line in enumerate(lines, start=0):
20+
m = LINE_RE.search(line)
21+
if m:
22+
lines[i] = NEW_LINE.format(new_version)
23+
break
24+
25+
with open(path, "w") as fout:
26+
fout.writelines(lines)
27+
28+
29+
def main():
30+
parser = argparse.ArgumentParser()
31+
parser.add_argument("file", help="Path to script with __version__")
32+
parser.add_argument(
33+
"--version", help="Version specifier to patch the version to"
34+
)
35+
args = parser.parse_args()
36+
patch_file(args.file, args.version)
37+
38+
39+
if __name__ == "__main__":
40+
main()

esptool/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"write_mem",
3232
]
3333

34-
__version__ = "4.8.1"
34+
__version__ = "5.0.0-dev"
3535

3636
import os
3737
import shlex

esptool/targets/esp32.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def get_chip_description(self):
227227
0: "ESP32-S0WDQ6" if sc else "ESP32-D0WDQ6-V3" if rev3 else "ESP32-D0WDQ6",
228228
1: "ESP32-S0WD" if sc else "ESP32-D0WD-V3" if rev3 else "ESP32-D0WD",
229229
2: "ESP32-D2WD",
230+
3: "ESP32-S0WD-OEM" if sc else "ESP32-D0WD-OEM",
230231
4: "ESP32-U4WDH",
231232
5: "ESP32-PICO-V3" if rev3 else "ESP32-PICO-D4",
232233
6: "ESP32-PICO-V3-02",

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "tool-esptoolpy",
3+
"description": "A serial utility to communicate & flash code to Espressif chips",
4+
"keywords": [
5+
"tools",
6+
"uploader",
7+
"tasmota",
8+
"espressif",
9+
"esp8266",
10+
"esp32"
11+
],
12+
"license": "GPL-2.0-or-later",
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/tasmota/esptool"
16+
},
17+
"version": "5.0.0-dev",
18+
"date": "2025-06-19"
19+
}

0 commit comments

Comments
 (0)