forked from espressif/esptool
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,857 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
name: Build esptool | ||
|
||
on: [push, pull_request] | ||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
paths-ignore: | ||
- '.github/**' # Ignore changes towards the .github directory | ||
|
||
jobs: | ||
build-esptool-binaries-arm: | ||
|
@@ -16,7 +22,7 @@ jobs: | |
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@master | ||
uses: actions/checkout@v4 | ||
- uses: uraimo/run-on-arch-action@v2 | ||
name: Build and test in ${{ matrix.platform }} | ||
with: | ||
|
@@ -55,11 +61,8 @@ jobs: | |
./${{ env.DISTPATH }}/espsecure -h || exit 1 | ||
./${{ env.DISTPATH }}/esp_rfc2217_server -h || exit 1 | ||
# Add license and readme | ||
mv LICENSE README.md ./${{ env.DISTPATH }} | ||
- name: Archive artifact | ||
uses: actions/upload-artifact@master | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.DISTPATH }} | ||
path: ${{ env.DISTPATH }} | ||
|
@@ -95,98 +98,104 @@ jobs: | |
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@master | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@master | ||
uses: actions/checkout@v4 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
python-version: 3.11 | ||
- name: Update esptool version when releasing | ||
if: startsWith(github.ref, 'refs/tags/') | ||
run: | | ||
python ci/patch_release.py --version ${{ github.ref_name }} esptool/__init__.py | ||
#git diff | ||
- name: Install dependencies | ||
# PyInstaller >=6.0 results in significantly more antivirus false positives | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pyinstaller==5.13.2 | ||
pip install pyinstaller==6.11.1 | ||
pip install --user -e . | ||
- name: Build with PyInstaller | ||
run: | | ||
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 | ||
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico --add-data="${{ env.EFUSE_DIR }}*.yaml${{ matrix.SEPARATOR }}${{ env.EFUSE_DIR }}" espefuse.py | ||
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico espsecure.py | ||
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=ci/espressif.ico esp_rfc2217_server.py | ||
- name: Sign binaries | ||
if: matrix.platform == 'windows' && github.event_name != 'pull_request' | ||
env: | ||
CERTIFICATE: ${{ secrets.CERTIFICATE }} | ||
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} | ||
shell: pwsh | ||
run: | | ||
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esptool.exe | ||
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espefuse.exe | ||
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espsecure.exe | ||
./ci/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esp_rfc2217_server.exe | ||
- name: Test binaries | ||
shell: bash | ||
run: | | ||
./${{ env.DISTPATH }}/esptool${{ matrix.EXTEN }} -h | ||
./${{ env.DISTPATH }}/espefuse${{ matrix.EXTEN }} -h | ||
./${{ env.DISTPATH }}/espsecure${{ matrix.EXTEN }} -h | ||
./${{ env.DISTPATH }}/esp_rfc2217_server${{ matrix.EXTEN }} -h | ||
- name: Add license and readme | ||
shell: bash | ||
run: mv LICENSE README.md ./${{ env.DISTPATH }} | ||
- name: Archive artifact | ||
uses: actions/upload-artifact@master | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.DISTPATH }} | ||
path: ${{ env.DISTPATH }} | ||
- name: Update package.json when a release tag is set | ||
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64' | ||
run: | | ||
rm -f package.json | ||
python ci/gen_pio_manifest.py -o "./" -s ${{ github.ref_name }} | ||
- name: Upload package.json artifact | ||
if: startsWith(github.ref, 'refs/tags/') && matrix.platform == 'linux-amd64' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: manifest | ||
path: /home/runner/work/esptool/esptool/package.json | ||
|
||
create_release: | ||
name: Create GitHub release | ||
if: startsWith(github.ref, 'refs/tags/') && !(contains(github.ref_name, 'dev')) | ||
needs: [build-esptool-binaries, build-esptool-binaries-arm] | ||
push_stubs: | ||
name: Commit changed package.json | ||
needs: build-esptool-binaries | ||
runs-on: ubuntu-latest | ||
env: | ||
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi" | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Get version | ||
id: get_version | ||
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | ||
shell: bash | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --user -e ".[dev]" | ||
- name: Generate changelog | ||
run: | | ||
cz changelog ${{ steps.get_version.outputs.VERSION }} --template ci/gh_changelog_template.md.j2 --file-name changelog_body.md | ||
cat changelog_body.md | ||
- name: Download built binaries | ||
uses: actions/download-artifact@master | ||
- name: Compress and rename binaries | ||
run: | | ||
for dir in esptool-*; do | ||
if [[ "$dir" == esptool-win* ]]; then | ||
zip -r "esptool-v${{ steps.get_version.outputs.VERSION }}-${dir#esptool-}.zip" "$dir" | ||
else | ||
chmod -R u=rwx,g=rx,o=rx "$dir" | ||
tar -cvzf "esptool-v${{ steps.get_version.outputs.VERSION }}-${dir#esptool-}.tar.gz" "$dir" | ||
fi | ||
done | ||
- name: Create release | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ref: main | ||
if: startsWith(github.ref, 'refs/tags/') | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
body_path: changelog_body.md | ||
name: Version ${{ steps.get_version.outputs.VERSION }} | ||
draft: true | ||
prerelease: false | ||
files: | | ||
esptool-v${{ steps.get_version.outputs.VERSION }}-*.zip | ||
esptool-v${{ steps.get_version.outputs.VERSION }}-*.tar.gz | ||
name: | | ||
manifest | ||
path: | | ||
./ | ||
- uses: stefanzweifel/git-auto-commit-action@v5 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
commit_message: update manifest | ||
|
||
release: | ||
name: Upload release binaries | ||
needs: [build-esptool-binaries, build-esptool-binaries-arm, push_stubs] | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Zip esptool.py | ||
run: | | ||
echo "Packaging new esptool release: ${{ github.ref_name }}" | ||
python ci/patch_release.py --version ${{ github.ref_name }} esptool/__init__.py | ||
rm package.json | ||
python ci/gen_pio_manifest.py -o "./" -s ${{ github.ref_name }} | ||
python ci/pack_python.py | ||
- name: Download built binaries | ||
uses: actions/download-artifact@v4 | ||
- name: Rename and package binaries | ||
run: | | ||
zip -r esptool-armv7.zip ./esptool-armv7 | ||
zip -r esptool-aarch64.zip ./esptool-aarch64 | ||
zip -r esptool-macos-arm64.zip ./esptool-macos-arm64 | ||
zip -r esptool-macos-amd64.zip ./esptool-macos-amd64 | ||
zip -r esptool-linux-amd64.zip ./esptool-linux-amd64 | ||
zip -r esptool-win64.zip ./esptool-win64 | ||
- name: Release | ||
uses: jason2866/[email protected] | ||
with: | ||
prerelease: false | ||
files: | | ||
*.zip | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ local.mk | |
report.xml | ||
|
||
docs/_build/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import argparse | ||
import json | ||
import os | ||
import re | ||
import sys | ||
import datetime | ||
|
||
MANIFEST_DATA = { | ||
"name": "tool-esptoolpy", | ||
"description": "A serial utility to communicate & flash code to Espressif chips", | ||
"keywords": ["tools", "uploader", "tasmota", "espressif", "esp8266", "esp32"], | ||
"license": "GPL-2.0-or-later", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/tasmota/esptool", | ||
}, | ||
} | ||
|
||
|
||
def convert_version(version_string): | ||
"""A helper function that converts a custom version string | ||
to a suitable SemVer alternative. For example: | ||
'release/v5.1' becomes '5.1.0', | ||
'v7.7.7' becomes '7.7.7' | ||
""" | ||
|
||
regex_pattern = ( | ||
r"v(?P<MAJOR>0|[1-9]\d*)\.(?P<MINOR>0|[1-9]\d*)\.*(?P<PATCH>0|[1-9]\d*)*" | ||
) | ||
match = re.search(regex_pattern, version_string) | ||
if not match: | ||
sys.stderr.write( | ||
f"Failed to find a regex match for '{regex_pattern}' in '{version_string}'\n" | ||
) | ||
return "" | ||
|
||
major, minor, patch = match.groups() | ||
if not patch: | ||
patch = "0" | ||
|
||
return ".".join((major, minor, patch)) | ||
|
||
|
||
def main(dst_dir, version_string): | ||
|
||
converted_version = convert_version(version_string) | ||
if not converted_version: | ||
sys.stderr.write(f"Failed to convert version '{version_string}'\n") | ||
return -1 | ||
|
||
manifest_file_path = os.path.join(dst_dir, "package.json") | ||
build_date = datetime.date.today() | ||
with open(manifest_file_path, "w", encoding="utf8") as fp: | ||
MANIFEST_DATA["version"] = f"{converted_version}" | ||
MANIFEST_DATA["date"] = f"{build_date}" | ||
json.dump(MANIFEST_DATA, fp, indent=2) | ||
|
||
print( | ||
f"Generated esptool package.json '{manifest_file_path}' with '{converted_version}' version" | ||
) | ||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"-o", | ||
"--dst-dir", | ||
dest="dst_dir", | ||
required=True, | ||
help="Destination folder where the 'package.json' manifest will be located", | ||
) | ||
parser.add_argument( | ||
"-s", | ||
"--version-string", | ||
dest="version_string", | ||
required=True, | ||
help="Version string in format v*.*.*", | ||
) | ||
args = parser.parse_args() | ||
|
||
sys.exit(main(args.dst_dir, args.version_string)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
|
||
import shutil | ||
import subprocess | ||
|
||
|
||
def main(): | ||
|
||
# remove not needed for plain python use | ||
shutil.rmtree("ci", ignore_errors=True) | ||
shutil.rmtree("docs", ignore_errors=True) | ||
shutil.rmtree("flasher_stub", ignore_errors=True) | ||
shutil.rmtree("test", ignore_errors=True) | ||
|
||
zipfile = "esptool.zip" | ||
|
||
print("Zip needed files into {}...".format(zipfile)) | ||
subprocess.run(["/usr/bin/7z", "a", "-mx=9", "-tzip", "-xr!.*", zipfile, "./"], check=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.