Skip to content

Commit 1440c02

Browse files
authored
pioarduino changes
1 parent 538f80f commit 1440c02

File tree

15 files changed

+1859
-89
lines changed

15 files changed

+1859
-89
lines changed

.github/workflows/build_esptool.yml

Lines changed: 83 additions & 74 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:
@@ -16,7 +22,7 @@ jobs:
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:
@@ -55,11 +61,8 @@ jobs:
5561
./${{ env.DISTPATH }}/espsecure -h || exit 1
5662
./${{ env.DISTPATH }}/esp_rfc2217_server -h || exit 1
5763
58-
# Add license and readme
59-
mv LICENSE README.md ./${{ env.DISTPATH }}
60-
6164
- name: Archive artifact
62-
uses: actions/upload-artifact@master
65+
uses: actions/upload-artifact@v4
6366
with:
6467
name: ${{ env.DISTPATH }}
6568
path: ${{ env.DISTPATH }}
@@ -95,98 +98,104 @@ jobs:
9598
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
9699
steps:
97100
- name: Checkout repository
98-
uses: actions/checkout@master
99-
- name: Set up Python 3.8
100-
uses: actions/setup-python@master
101+
uses: actions/checkout@v4
102+
- name: Set up Python 3.11
103+
uses: actions/setup-python@v5
101104
with:
102-
python-version: 3.8
105+
python-version: 3.11
106+
- name: Update esptool version when releasing
107+
if: startsWith(github.ref, 'refs/tags/')
108+
run: |
109+
python ci/patch_release.py --version ${{ github.ref_name }} esptool/__init__.py
110+
#git diff
103111
- name: Install dependencies
104-
# PyInstaller >=6.0 results in significantly more antivirus false positives
105112
run: |
106113
python -m pip install --upgrade pip
107-
pip install pyinstaller==5.13.2
114+
pip install pyinstaller==6.11.1
108115
pip install --user -e .
109116
- name: Build with PyInstaller
110117
run: |
111118
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
112119
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico --add-data="${{ env.EFUSE_DIR }}*.yaml${{ matrix.SEPARATOR }}${{ env.EFUSE_DIR }}" espefuse.py
113120
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico espsecure.py
114121
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico esp_rfc2217_server.py
115-
- name: Sign binaries
116-
if: matrix.platform == 'windows' && github.event_name != 'pull_request'
117-
env:
118-
CERTIFICATE: ${{ secrets.CERTIFICATE }}
119-
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
120-
shell: pwsh
121-
run: |
122-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esptool.exe
123-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espefuse.exe
124-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espsecure.exe
125-
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esp_rfc2217_server.exe
126122
- name: Test binaries
127123
shell: bash
128124
run: |
129125
./${{ env.DISTPATH }}/esptool${{ matrix.EXTEN }} -h
130126
./${{ env.DISTPATH }}/espefuse${{ matrix.EXTEN }} -h
131127
./${{ env.DISTPATH }}/espsecure${{ matrix.EXTEN }} -h
132128
./${{ env.DISTPATH }}/esp_rfc2217_server${{ matrix.EXTEN }} -h
133-
- name: Add license and readme
134-
shell: bash
135-
run: mv LICENSE README.md ./${{ env.DISTPATH }}
136129
- name: Archive artifact
137-
uses: actions/upload-artifact@master
130+
uses: actions/upload-artifact@v4
138131
with:
139132
name: ${{ env.DISTPATH }}
140133
path: ${{ env.DISTPATH }}
134+
- name: Update package.json when a release tag is set
135+
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64'
136+
run: |
137+
rm -f package.json
138+
python ci/gen_pio_manifest.py -o "./" -s ${{ github.ref_name }}
139+
- name: Upload package.json artifact
140+
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64'
141+
uses: actions/upload-artifact@v4
142+
with:
143+
name: manifest
144+
path: /home/runner/work/esptool/esptool/package.json
141145

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

.github/workflows/test_esptool.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
11+
python-version: ['3.9', '3.10', '3.11', '3.12']
1212

1313
steps:
1414
- name: Checkout ref commit
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25-
pip install 'setuptools>=64'
25+
pip install setuptools
2626
2727
- name: SoftHSM2 setup
2828
run: |
@@ -51,11 +51,10 @@ jobs:
5151
steps:
5252
- name: Checkout
5353
uses: actions/checkout@master
54-
55-
- name: Set up Python 3.13
54+
- name: Set up Python 3.12
5655
uses: actions/setup-python@master
5756
with:
58-
python-version: 3.13
57+
python-version: 3.12
5958

6059
- name: Check if flasher stubs are up-to-date
6160
run: |
@@ -67,13 +66,12 @@ jobs:
6766
steps:
6867
- name: Checkout
6968
uses: actions/checkout@master
70-
71-
- name: Set up Python 3.7
69+
- name: Set up Python 3.9
7270
uses: actions/setup-python@master
7371
with:
74-
python-version: 3.7
75-
76-
- name: Run pre-commit hooks
72+
python-version: '3.9'
73+
- name: Lint and format with ruff
7774
run: |
7875
pip install --extra-index-url https://dl.espressif.com/pypi -e .[dev]
79-
pre-commit run --all-files
76+
python -m ruff check
77+
python -m ruff format

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ local.mk
1414
report.xml
1515

1616
docs/_build/
17+
.DS_Store

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A Python-based, open-source, platform-independent utility to communicate with the ROM bootloader in Espressif chips.
44

5-
[![Test esptool](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml) [![Build esptool](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml)
5+
[![Test esptool](https://github.com/jason2866/esptool/actions/workflows/test_esptool.yml/badge.svg?branch=main_work)](https://github.com/jason2866/esptool/actions/workflows/test_esptool.yml) [![Build esptool](https://github.com/jason2866/esptool/actions/workflows/build_esptool.yml/badge.svg?branch=main_work)](https://github.com/jason2866/esptool/actions/workflows/build_esptool.yml)
66

77
## Documentation
88

ci/gen_pio_manifest.py

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

ci/pack_python.py

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

0 commit comments

Comments
 (0)