@@ -3,10 +3,17 @@ name: Build Python Tools
3
3
on :
4
4
pull_request :
5
5
paths :
6
- - ' tools/get.py'
7
- - ' tools/espota.py'
8
- - ' tools/gen_esp32part.py'
9
- - ' tools/gen_insights_package.py'
6
+ - ' tools/get.py'
7
+ - ' tools/espota.py'
8
+ - ' tools/gen_esp32part.py'
9
+ - ' tools/gen_insights_package.py'
10
+ push :
11
+ branches :
12
+ - master
13
+
14
+ concurrency :
15
+ group : pytools-${{ github.event.pull_request.number || github.ref }}
16
+ cancel-in-progress : true
10
17
11
18
jobs :
12
19
find-changed-tools :
@@ -20,18 +27,17 @@ jobs:
20
27
uses : actions/checkout@v4
21
28
with :
22
29
fetch-depth : 2
23
- ref : ${{ github.event.pull_request.head.ref }}
30
+
24
31
- name : Verify Python Tools Changed
25
32
uses : tj-actions/changed-files@v41
26
33
id : verify-changed-files
27
34
with :
28
- fetch_depth : ' 2'
29
- since_last_remote_commit : ' true'
30
35
files : |
31
36
tools/get.py
32
37
tools/espota.py
33
38
tools/gen_esp32part.py
34
39
tools/gen_insights_package.py
40
+
35
41
- name : List all changed files
36
42
shell : bash
37
43
run : |
@@ -86,29 +92,41 @@ jobs:
86
92
for tool in ${{ env.CHANGED_TOOLS }}; do
87
93
echo "tool $tool was changed"
88
94
done
95
+
96
+ - name : Get token
97
+ if : github.event_name == 'push'
98
+ uses : actions/create-github-app-token@v1
99
+ id : get_token
100
+ with :
101
+ app-id : ${{ secrets.TOOLS_UPLOAD_APP_ID }}
102
+ private-key : ${{ secrets.TOOLS_UPLOAD_APP_TOKEN }}
103
+
89
104
- name : Checkout repository
90
105
uses : actions/checkout@v4
91
106
with :
92
- token : ${{ secrets.TOOLS_UPLOAD_PAT }}
93
- ref : ${{ github.event.pull_request.head.ref }}
107
+ token : ${{ steps.get_token.outputs.token || github.token }}
108
+
94
109
- name : Set up Python 3.8
95
110
# Skip setting python on ARM because of missing compatibility: https://github.com/actions/setup-python/issues/108
96
111
if : matrix.os != 'ARM' && matrix.os != 'ARM64'
97
- uses : actions/setup-python@master
112
+ uses : actions/setup-python@v5
98
113
with :
99
114
python-version : 3.8
115
+
100
116
- name : Install dependencies
101
117
run : |
102
118
python -m pip install --upgrade pip
103
119
pip install pyinstaller requests
120
+
104
121
- name : Build with PyInstaller
105
122
shell : bash
106
123
run : |
107
124
for tool in ${{ env.CHANGED_TOOLS }}; do
108
125
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=.github/pytools/espressif.ico tools/$tool.py
109
126
done
127
+
110
128
- name : Sign binaries
111
- if : matrix.os == 'windows-latest' && env.CERTIFICATE != ' ' && env.CERTIFICATE_PASSWORD != ''
129
+ if : matrix.os == 'windows-latest' && github.event_name == 'push ' && env.CERTIFICATE != ''
112
130
env :
113
131
CERTIFICATE : ${{ secrets.CERTIFICATE }}
114
132
CERTIFICATE_PASSWORD : ${{ secrets.CERTIFICATE_PASSWORD }}
@@ -119,22 +137,33 @@ jobs:
119
137
{
120
138
./.github/pytools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/$node.exe
121
139
}
140
+
122
141
- name : Test binaries
123
142
shell : bash
124
143
run : |
125
144
for tool in ${{ env.CHANGED_TOOLS }}; do
126
145
./${{ env.DISTPATH }}/$tool${{ matrix.EXTEN }} -h
127
146
done
147
+
128
148
- name : Push binary to tools
129
- if : matrix.os == 'windows-latest'
149
+ if : matrix.os == 'windows-latest' && github.event_name == 'push'
130
150
env :
131
- GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN }}
151
+ GITHUB_TOKEN : ${{ steps.get_token.outputs.token }}
132
152
shell : bash
133
153
run : |
134
154
for tool in ${{ env.CHANGED_TOOLS }}; do
135
155
cp -f ./${{ env.DISTPATH }}/$tool.exe tools/$tool.exe
136
156
done
137
- bash .github/scripts/upload_py_tools.sh "${{ env.CHANGED_TOOLS }}"
157
+
158
+ echo "Pushing '${{ env.CHANGED_TOOLS }}' as github-actions[bot]"
159
+ git config --global user.name "github-actions[bot]"
160
+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
161
+ for tool in ${{ env.CHANGED_TOOLS }}; do
162
+ git add tools/$tool.exe
163
+ done
164
+ git commit -m "change(tools): Push generated tools binaries"
165
+ git push
166
+
138
167
- name : Archive artifact
139
168
uses : actions/upload-artifact@master
140
169
with :
0 commit comments