Skip to content

Commit da048a4

Browse files
authored
v5.0.0
1 parent 785a3db commit da048a4

File tree

12 files changed

+267
-178
lines changed

12 files changed

+267
-178
lines changed

.github/workflows/build_esptool.yml

Lines changed: 84 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
@@ -66,11 +72,8 @@ jobs:
6672
./${{ env.DISTPATH }}/espsecure -h || exit 1
6773
./${{ env.DISTPATH }}/esp_rfc2217_server -h || exit 1
6874
69-
# Add license and readme
70-
mv LICENSE README.md ./${{ env.DISTPATH }}
71-
7275
- name: Archive artifact
73-
uses: actions/upload-artifact@master
76+
uses: actions/upload-artifact@v4
7477
with:
7578
name: ${{ env.DISTPATH }}
7679
path: ${{ env.DISTPATH }}
@@ -91,7 +94,7 @@ jobs:
9194
SEPARATOR: ':'
9295
RUN_ON: macos-latest # Versions 14 and higher are ARM-based.
9396
- platform: windows
94-
TARGET: windows-amd64
97+
TARGET: win64
9598
EXTEN: .exe
9699
SEPARATOR: ';'
97100
RUN_ON: windows-latest
@@ -106,11 +109,16 @@ jobs:
106109
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
107110
steps:
108111
- name: Checkout repository
109-
uses: actions/checkout@master
112+
uses: actions/checkout@v4
110113
- name: Set up Python 3.11
111-
uses: actions/setup-python@master
114+
uses: actions/setup-python@v5
112115
with:
113-
python-version: "3.11"
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
114122
- name: Install dependencies
115123
run: |
116124
python -m pip install --upgrade pip
@@ -146,63 +154,76 @@ jobs:
146154
./${{ env.DISTPATH }}/espefuse${{ matrix.EXTEN }} -h
147155
./${{ env.DISTPATH }}/espsecure${{ matrix.EXTEN }} -h
148156
./${{ env.DISTPATH }}/esp_rfc2217_server${{ matrix.EXTEN }} -h
149-
- name: Add license and readme
150-
shell: bash
151-
run: mv LICENSE README.md ./${{ env.DISTPATH }}
152157
- name: Archive artifact
153-
uses: actions/upload-artifact@master
158+
uses: actions/upload-artifact@v4
154159
with:
155160
name: ${{ env.DISTPATH }}
156161
path: ${{ env.DISTPATH }}
162+
- name: Update package.json when a release tag is set
163+
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64'
164+
run: |
165+
rm -f package.json
166+
python ci/gen_pio_manifest.py -o "./" -s ${{ github.ref_name }}
167+
- name: Upload package.json artifact
168+
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64'
169+
uses: actions/upload-artifact@v4
170+
with:
171+
name: manifest
172+
path: /home/runner/work/esptool/esptool/package.json
157173

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

.github/workflows/dangerjs.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/dev_release_esptool_pypi.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/release_esptool_pypi.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

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", "pioarduino", "espressif", "esp8266", "esp32"],
13+
"license": "GPL-2.0-or-later",
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/pioarduino/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))

0 commit comments

Comments
 (0)