Skip to content

Commit c651422

Browse files
committed
Merge branch 'test/build_action' into 'master'
feat: Build executables and attach to GitHub release Closes IDFGH-14261 See merge request espressif/esp-idf-monitor!94
2 parents 70088ea + fb2676e commit c651422

File tree

3 files changed

+109
-44
lines changed

3 files changed

+109
-44
lines changed

.github/workflows/build.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Build IDF Monitor
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-idf-monitor-binaries:
7+
name: Build IDF Monitor binaries for ${{ matrix.platform }}
8+
runs-on: ${{ matrix.runner }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
platform: [windows-amd64, linux-amd64, macos-amd64, macos-arm64, linux-armv7, linux-aarch64]
13+
include:
14+
- platform: windows-amd64
15+
runner: windows-latest
16+
- platform: linux-amd64
17+
runner: ubuntu-24.04
18+
- platform: macos-amd64
19+
runner: macos-13
20+
- platform: macos-arm64
21+
runner: macos-latest
22+
- platform: linux-armv7
23+
runner: ubuntu-latest
24+
- platform: linux-aarch64
25+
runner: ubuntu-24.04-arm
26+
env:
27+
DISTPATH: idf-monitor-${{ matrix.platform }}
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Python 3.13
33+
uses: actions/setup-python@v5
34+
# Python is not needed for Linux runners, as they are running in a container
35+
if: matrix.platform != 'linux-armv7' && matrix.platform != 'linux-aarch64' && matrix.platform != 'linux-amd64'
36+
with:
37+
python-version: "3.13"
38+
cache: pip
39+
- name: Build with PyInstaller
40+
uses: espressif/python-binary-action@master
41+
with:
42+
scripts: 'esp_idf_monitor/__main__.py'
43+
script-name: 'esp_idf_monitor'
44+
output-dir: ./${{ env.DISTPATH }}
45+
target-platform: ${{ matrix.platform }}
46+
47+
- name: Add license and readme
48+
shell: bash
49+
run: mv LICENSE README.md ./${{ env.DISTPATH }}
50+
51+
- name: Archive artifact
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: ${{ env.DISTPATH }}
55+
path: ${{ env.DISTPATH }}
56+
57+
create_release:
58+
name: Create GitHub release
59+
runs-on: ubuntu-latest
60+
if: startsWith(github.ref, 'refs/tags/v')
61+
needs: build-idf-monitor-binaries
62+
permissions:
63+
contents: write
64+
steps:
65+
- name: Get version
66+
id: get_version
67+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
68+
shell: bash
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
- name: Install dependencies
74+
run: |
75+
python -m pip install --upgrade pip
76+
pip install --user -e ".[dev]"
77+
- name: Generate changelog
78+
run: |
79+
cz changelog ${{ steps.get_version.outputs.VERSION }} --file-name changelog_body.md
80+
cat changelog_body.md
81+
- name: Download built binaries
82+
uses: actions/download-artifact@v4
83+
- name: Compress and rename binaries
84+
run: |
85+
for dir in idf-monitor-*; do
86+
if [[ "$dir" == idf-monitor-win* ]]; then
87+
zip -r "idf-monitor-v${{ steps.get_version.outputs.VERSION }}-${dir#idf-monitor-}.zip" "$dir"
88+
else
89+
chmod -R u=rwx,g=rx,o=rx "$dir"
90+
tar -cvzf "idf-monitor-v${{ steps.get_version.outputs.VERSION }}-${dir#idf-monitor-}.tar.gz" "$dir"
91+
fi
92+
done
93+
- name: Create release
94+
id: create_release
95+
uses: softprops/action-gh-release@v2
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
with:
99+
body_path: changelog_body.md
100+
name: Version ${{ steps.get_version.outputs.VERSION }}
101+
draft: true
102+
prerelease: false
103+
files: |
104+
idf-monitor-v${{ steps.get_version.outputs.VERSION }}-*.zip
105+
idf-monitor-v${{ steps.get_version.outputs.VERSION }}-*.tar.gz

.github/workflows/create_gh_release.yaml

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

esp_idf_monitor/idf_monitor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import serial
3535
from serial.tools import list_ports, miniterm
3636

37+
from esp_idf_monitor import __version__
3738
# Windows console stuff
3839
from esp_idf_monitor.base.ansi_color_converter import get_ansi_converter
3940
from esp_idf_monitor.base.argument_parser import get_parser
@@ -69,8 +70,6 @@
6970
from esp_idf_monitor.base.web_socket_client import WebSocketClient
7071
from esp_idf_monitor.config import Config
7172

72-
from . import __version__
73-
7473
key_description = miniterm.key_description
7574

7675

@@ -356,11 +355,12 @@ def detect_port() -> Union[str, NoReturn]:
356355

357356

358357
def main() -> None:
359-
if not sys.stdin.isatty() and not os.environ.get('ESP_IDF_MONITOR_TEST'):
360-
sys.exit('Error: Monitor requires standard input to be attached to TTY. Try using a different terminal.')
361358
parser = get_parser()
362359
args = parser.parse_args()
363360

361+
if not sys.stdin.isatty() and not os.environ.get('ESP_IDF_MONITOR_TEST'):
362+
sys.exit('Error: Monitor requires standard input to be attached to TTY. Try using a different terminal.')
363+
364364
# use EOL from argument; defaults to LF for Linux targets and CR otherwise
365365
args.eol = args.eol or ('LF' if args.target == 'linux' else 'CR')
366366

0 commit comments

Comments
 (0)