Skip to content

Commit f5a040a

Browse files
committed
Merge branch 'master' into test_ci
2 parents 39842d9 + f267212 commit f5a040a

File tree

4 files changed

+384
-74
lines changed

4 files changed

+384
-74
lines changed

.github/workflows/build_py_tools.yml

Lines changed: 61 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,70 @@
1-
name: Build Python Tools
1+
name: Build Tools
22

33
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
1043

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
4147

48+
jobs:
4249
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
7153
env:
72-
DISTPATH: pytools-${{ matrix.TARGET }}
54+
DISTPATH: pytools-${{ inputs.target }}
7355
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi"
7456
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+
7563
- name: List changed tools
7664
shell: bash
7765
run: |
7866
CHANGED_FILES=()
79-
for file in ${{ needs.find-changed-tools.outputs.all_changed_files }}; do
67+
for file in ${{ inputs.changed_files }}; do
8068
file="${file#*\/}"
8169
file="${file%\.*}"
8270
CHANGED_FILES+=("$file")
@@ -89,12 +77,11 @@ jobs:
8977
- name: Checkout repository
9078
uses: actions/checkout@v4
9179
with:
92-
token: ${{ secrets.TOOLS_UPLOAD_PAT }}
93-
ref: ${{ github.event.pull_request.head.ref }}
80+
token: ${{ steps.create_token.outputs.token }}
9481
- name: Set up Python 3.8
9582
# 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
9885
with:
9986
python-version: 3.8
10087
- name: Install dependencies
@@ -108,7 +95,7 @@ jobs:
10895
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=.github/pytools/espressif.ico tools/$tool.py
10996
done
11097
- name: Sign binaries
111-
if: matrix.os == 'windows-latest' && env.CERTIFICATE != '' && env.CERTIFICATE_PASSWORD != ''
98+
if: inputs.os == 'windows-latest' && env.CERTIFICATE != ''
11299
env:
113100
CERTIFICATE: ${{ secrets.CERTIFICATE }}
114101
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
@@ -123,10 +110,10 @@ jobs:
123110
shell: bash
124111
run: |
125112
for tool in ${{ env.CHANGED_TOOLS }}; do
126-
./${{ env.DISTPATH }}/$tool${{ matrix.EXTEN }} -h
113+
./${{ env.DISTPATH }}/$tool${{ inputs.EXTEN }} -h
127114
done
128115
- name: Push binary to tools
129-
if: matrix.os == 'windows-latest'
116+
if: inputs.os == 'windows-latest'
130117
env:
131118
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
132119
shell: bash

.github/workflows/pytools.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Python Tools
2+
3+
on:
4+
pull_request_target:
5+
paths:
6+
- 'tools/get.py'
7+
- 'tools/espota.py'
8+
- 'tools/gen_esp32part.py'
9+
- 'tools/gen_insights_package.py'
10+
11+
permissions: { contents: read }
12+
13+
jobs:
14+
find-changed-tools:
15+
name: Check if tools have been changed
16+
runs-on: ubuntu-20.04
17+
outputs:
18+
any_changed: ${{ steps.verify-changed-files.outputs.any_changed }}
19+
all_changed_files: ${{ steps.verify-changed-files.outputs.all_changed_files }}
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 2
25+
repository: ${{ github.event.pull_request.head.repo.full_name }}
26+
- name: Verify Python Tools Changed
27+
uses: tj-actions/changed-files@v42
28+
id: verify-changed-files
29+
with:
30+
since_last_remote_commit: 'true'
31+
files: |
32+
tools/get.py
33+
tools/espota.py
34+
tools/gen_esp32part.py
35+
tools/gen_insights_package.py
36+
- name: List all changed files
37+
shell: bash
38+
run: |
39+
for file in ${{ steps.verify-changed-files.outputs.all_changed_files }}; do
40+
echo "$file was changed"
41+
done
42+
43+
call-build:
44+
name: Build
45+
uses: ./.github/workflows/build_py_tools.yml
46+
needs: find-changed-tools
47+
if: needs.find-changed-tools.outputs.any_changed == 'true'
48+
permissions:
49+
contents: write
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
os: [windows-latest, macos-latest, ubuntu-20.04, ARM, ARM64]
54+
include:
55+
- os: windows-latest
56+
TARGET: win64
57+
EXTEN: .exe
58+
SEPARATOR: ';'
59+
- os: macos-latest
60+
TARGET: macos
61+
SEPARATOR: ':'
62+
- os: ubuntu-20.04
63+
TARGET: linux-amd64
64+
SEPARATOR: ':'
65+
- os: ARM
66+
CONTAINER: python:3.8-bullseye
67+
TARGET: arm
68+
SEPARATOR: ':'
69+
- os: ARM64
70+
CONTAINER: python:3.8-bullseye
71+
TARGET: arm64
72+
SEPARATOR: ':'
73+
secrets:
74+
TOOLS_UPLOAD_APP_ID: ${{ secrets.TOOLS_UPLOAD_APP_ID }}
75+
TOOLS_UPLOAD_APP_TOKEN: ${{ secrets.TOOLS_UPLOAD_APP_TOKEN }}
76+
CERTIFICATE: ${{ secrets.CERTIFICATE }}
77+
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
78+
with:
79+
os: ${{ matrix.os }}
80+
container: ${{ matrix.CONTAINER }}
81+
target: ${{ matrix.TARGET }}
82+
exten: ${{ matrix.EXTEN }}
83+
separator: ${{ matrix.SEPARATOR }}
84+
changed_files: ${{ needs.find-changed-tools.outputs.all_changed_files }}
85+

0 commit comments

Comments
 (0)