11name : 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
511jobs :
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 :
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
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 }}
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+ 208+ with :
209+ prerelease : false
210+ files : |
211+ *.zip
212+ env :
213+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments