1
- name : Build Python Tools
1
+ name : Build Tools
2
2
3
3
on :
4
- pull_request :
5
- paths :
6
- - ' tools/get.py'
7
- - ' tools/espota.py'
8
- - ' tools/gen_esp32part.py'
9
- - ' tools/gen_insights_package.py'
4
+ workflow_call :
5
+ inputs :
6
+ os :
7
+ type : string
8
+ description : ' Operating system to build tools for'
9
+ required : true
10
+ container :
11
+ type : string
12
+ description : ' Container to use for building'
13
+ required : false
14
+ target :
15
+ type : string
16
+ description : ' Target to build tools for'
17
+ required : true
18
+ exten :
19
+ type : string
20
+ description : ' Extension of the binary'
21
+ required : false
22
+ separator :
23
+ type : string
24
+ description : ' Separator for the binary'
25
+ required : true
26
+ changed_files :
27
+ type : string
28
+ description : ' Changed files'
29
+ required : true
30
+ secrets :
31
+ APP_ID :
32
+ description : ' Push tools App ID'
33
+ required : true
34
+ APP_TOKEN :
35
+ description : ' Push tools App Token'
36
+ required : true
37
+ CERTIFICATE :
38
+ description : ' Certificate for signing'
39
+ required : true
40
+ CERTIFICATE_PASSWORD :
41
+ description : ' Certificate password'
42
+ required : false
10
43
11
- jobs :
12
- find-changed-tools :
13
- name : Check if tools have been changed
14
- runs-on : ubuntu-20.04
15
- outputs :
16
- any_changed : ${{ steps.verify-changed-files.outputs.any_changed }}
17
- all_changed_files : ${{ steps.verify-changed-files.outputs.all_changed_files }}
18
- steps :
19
- - name : Checkout repository
20
- uses : actions/checkout@v4
21
- with :
22
- fetch-depth : 2
23
- ref : ${{ github.event.pull_request.head.ref }}
24
- - name : Verify Python Tools Changed
25
- uses : tj-actions/changed-files@v41
26
- id : verify-changed-files
27
- with :
28
- fetch_depth : ' 2'
29
- since_last_remote_commit : ' true'
30
- files : |
31
- tools/get.py
32
- tools/espota.py
33
- tools/gen_esp32part.py
34
- tools/gen_insights_package.py
35
- - name : List all changed files
36
- shell : bash
37
- run : |
38
- for file in ${{ steps.verify-changed-files.outputs.all_changed_files }}; do
39
- echo "$file was changed"
40
- done
44
+ concurrency :
45
+ group : pytools-${{ github.event.pull_request.number || github.ref }}-${{ inputs.os }}
46
+ cancel-in-progress : true
41
47
48
+ jobs :
42
49
build-pytools-binaries :
43
- name : Build python tools binaries for ${{ matrix.os }}
44
- runs-on : ${{ matrix.os }}
45
- needs : find-changed-tools
46
- if : needs.find-changed-tools.outputs.any_changed == 'true'
47
- strategy :
48
- fail-fast : false
49
- matrix :
50
- os : [windows-latest, macos-latest, ubuntu-20.04, ARM, ARM64]
51
- include :
52
- - os : windows-latest
53
- TARGET : win64
54
- EXTEN : .exe
55
- SEPARATOR : ' ;'
56
- - os : macos-latest
57
- TARGET : macos
58
- SEPARATOR : ' :'
59
- - os : ubuntu-20.04
60
- TARGET : linux-amd64
61
- SEPARATOR : ' :'
62
- - os : ARM
63
- CONTAINER : python:3.8-bullseye
64
- TARGET : arm
65
- SEPARATOR : ' :'
66
- - os : ARM64
67
- CONTAINER : python:3.8-bullseye
68
- TARGET : arm64
69
- SEPARATOR : ' :'
70
- container : ${{ matrix.CONTAINER }} # use python container on ARM
50
+ name : Build python tools binaries for ${{ inputs.os }}
51
+ runs-on : ${{ inputs.os }}
52
+ container : ${{ inputs.container }} # use python container on ARM
71
53
env :
72
- DISTPATH : pytools-${{ matrix.TARGET }}
54
+ DISTPATH : pytools-${{ inputs.target }}
73
55
PIP_EXTRA_INDEX_URL : " https://dl.espressif.com/pypi"
74
56
steps :
57
+ - id : create_token
58
+ uses : tibdex/github-app-token@v2
59
+ with :
60
+ app_id : " ${{ secrets.TOOLS_UPLOAD_APP_ID }}"
61
+ private_key : " ${{ secrets.TOOLS_UPLOAD_APP_TOKEN }}"
62
+
75
63
- name : List changed tools
76
64
shell : bash
77
65
run : |
78
66
CHANGED_FILES=()
79
- for file in ${{ needs.find-changed-tools.outputs.all_changed_files }}; do
67
+ for file in ${{ inputs.changed_files }}; do
80
68
file="${file#*\/}"
81
69
file="${file%\.*}"
82
70
CHANGED_FILES+=("$file")
@@ -89,12 +77,11 @@ jobs:
89
77
- name : Checkout repository
90
78
uses : actions/checkout@v4
91
79
with :
92
- token : ${{ secrets.TOOLS_UPLOAD_PAT }}
93
- ref : ${{ github.event.pull_request.head.ref }}
80
+ token : ${{ steps.create_token.outputs.token }}
94
81
- name : Set up Python 3.8
95
82
# Skip setting python on ARM because of missing compatibility: https://github.com/actions/setup-python/issues/108
96
- if : matrix .os != 'ARM' && matrix .os != 'ARM64'
97
- uses : actions/setup-python@master
83
+ if : inputs .os != 'ARM' && inputs .os != 'ARM64'
84
+ uses : actions/setup-python@v5
98
85
with :
99
86
python-version : 3.8
100
87
- name : Install dependencies
108
95
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=.github/pytools/espressif.ico tools/$tool.py
109
96
done
110
97
- name : Sign binaries
111
- if : matrix .os == 'windows-latest' && env.CERTIFICATE != '' && env.CERTIFICATE_PASSWORD != ''
98
+ if : inputs .os == 'windows-latest' && env.CERTIFICATE != ''
112
99
env :
113
100
CERTIFICATE : ${{ secrets.CERTIFICATE }}
114
101
CERTIFICATE_PASSWORD : ${{ secrets.CERTIFICATE_PASSWORD }}
@@ -123,10 +110,10 @@ jobs:
123
110
shell : bash
124
111
run : |
125
112
for tool in ${{ env.CHANGED_TOOLS }}; do
126
- ./${{ env.DISTPATH }}/$tool${{ matrix .EXTEN }} -h
113
+ ./${{ env.DISTPATH }}/$tool${{ inputs .EXTEN }} -h
127
114
done
128
115
- name : Push binary to tools
129
- if : matrix .os == 'windows-latest'
116
+ if : inputs .os == 'windows-latest'
130
117
env :
131
118
GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
132
119
shell : bash
0 commit comments