Skip to content

Commit 617da2f

Browse files
committed
ci(tools): Push exe tools only after merged in master
1 parent fa89bfb commit 617da2f

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

.github/scripts/upload_py_tools.sh

-11
This file was deleted.

.github/workflows/build_py_tools.yml

+43-14
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ name: Build Python Tools
33
on:
44
pull_request:
55
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
1017

1118
jobs:
1219
find-changed-tools:
@@ -20,18 +27,17 @@ jobs:
2027
uses: actions/checkout@v4
2128
with:
2229
fetch-depth: 2
23-
ref: ${{ github.event.pull_request.head.ref }}
30+
2431
- name: Verify Python Tools Changed
2532
uses: tj-actions/changed-files@v41
2633
id: verify-changed-files
2734
with:
28-
fetch_depth: '2'
29-
since_last_remote_commit: 'true'
3035
files: |
3136
tools/get.py
3237
tools/espota.py
3338
tools/gen_esp32part.py
3439
tools/gen_insights_package.py
40+
3541
- name: List all changed files
3642
shell: bash
3743
run: |
@@ -86,29 +92,41 @@ jobs:
8692
for tool in ${{ env.CHANGED_TOOLS }}; do
8793
echo "tool $tool was changed"
8894
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+
89104
- name: Checkout repository
90105
uses: actions/checkout@v4
91106
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+
94109
- name: Set up Python 3.8
95110
# Skip setting python on ARM because of missing compatibility: https://github.com/actions/setup-python/issues/108
96111
if: matrix.os != 'ARM' && matrix.os != 'ARM64'
97-
uses: actions/setup-python@master
112+
uses: actions/setup-python@v5
98113
with:
99114
python-version: 3.8
115+
100116
- name: Install dependencies
101117
run: |
102118
python -m pip install --upgrade pip
103119
pip install pyinstaller requests
120+
104121
- name: Build with PyInstaller
105122
shell: bash
106123
run: |
107124
for tool in ${{ env.CHANGED_TOOLS }}; do
108125
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=.github/pytools/espressif.ico tools/$tool.py
109126
done
127+
110128
- 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 != ''
112130
env:
113131
CERTIFICATE: ${{ secrets.CERTIFICATE }}
114132
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
@@ -119,22 +137,33 @@ jobs:
119137
{
120138
./.github/pytools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/$node.exe
121139
}
140+
122141
- name: Test binaries
123142
shell: bash
124143
run: |
125144
for tool in ${{ env.CHANGED_TOOLS }}; do
126145
./${{ env.DISTPATH }}/$tool${{ matrix.EXTEN }} -h
127146
done
147+
128148
- name: Push binary to tools
129-
if: matrix.os == 'windows-latest'
149+
if: matrix.os == 'windows-latest' && github.event_name == 'push'
130150
env:
131-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
151+
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
132152
shell: bash
133153
run: |
134154
for tool in ${{ env.CHANGED_TOOLS }}; do
135155
cp -f ./${{ env.DISTPATH }}/$tool.exe tools/$tool.exe
136156
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+
138167
- name: Archive artifact
139168
uses: actions/upload-artifact@master
140169
with:

0 commit comments

Comments
 (0)