Skip to content

Commit 8e7c162

Browse files
authored
Merge pull request #4919 from tonhuisman/feature/GH-up-download-delete-actions-fix
[Build] Fix buildscripts for v4 Actions `upload-artifact`, `download-artifact` and `delete-artifact`
2 parents 0c8a0d1 + c7608cf commit 8e7c162

File tree

3 files changed

+68
-117
lines changed

3 files changed

+68
-117
lines changed

.github/workflows/build.yml

+36-99
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
runs-on: ubuntu-22.04
2525
steps:
2626
- uses: actions/checkout@v4
27-
- uses: actions/setup-python@v4
27+
- uses: actions/setup-python@v5
2828
with:
2929
python-version: '3.x'
30-
- uses: actions/cache@v3
30+
- uses: actions/cache@v4
3131
with:
3232
path: ~/.cache/pip
3333
key: ${{ runner.os }}-docs-${{ hashFiles('docs/requirements.txt') }}
@@ -39,7 +39,7 @@ jobs:
3939
make html
4040
cd ..
4141
zip -r -qq ESPEasy_docs.zip docs/build/*
42-
- uses: actions/upload-artifact@v3
42+
- uses: actions/upload-artifact@v4
4343
with:
4444
name: Documentation
4545
path: ESPEasy_docs.zip
@@ -49,7 +49,7 @@ jobs:
4949
matrix: ${{ steps.set-matrix.outputs.matrix }}
5050
steps:
5151
- uses: actions/checkout@v4
52-
- uses: actions/setup-python@v4
52+
- uses: actions/setup-python@v5
5353
with:
5454
python-version: '3.x'
5555
- id: set-matrix
@@ -64,19 +64,19 @@ jobs:
6464
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
6565
steps:
6666
- uses: actions/checkout@v4
67-
- uses: actions/setup-python@v4
67+
- uses: actions/setup-python@v5
6868
with:
69-
python-version: '3.11'
70-
- uses: actions/cache@v3
69+
python-version: '3.x'
70+
- uses: actions/cache@v4
7171
with:
7272
path: ~/.cache/pip
7373
key: ${{ runner.os }}-${{ hashFiles('requirements.txt') }}
74-
- uses: actions/cache@v3
74+
- uses: actions/cache@v4
7575
if: ${{ contains(matrix.env, 'esp32') }}
7676
with:
7777
path: ~/.platformio
7878
key: ${{ runner.os }}-esp32-${{ hashFiles('platformio*.ini') }}
79-
- uses: actions/cache@v3
79+
- uses: actions/cache@v4
8080
if: ${{ contains(matrix.env, 'esp8266') }}
8181
with:
8282
path: ~/.platformio
@@ -89,123 +89,60 @@ jobs:
8989
pip install wheel
9090
pip install -r requirements.txt
9191
platformio update
92+
- name: Get current date
93+
id: date
94+
run: |
95+
echo "builddate=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
9296
- name: Build and archive
9397
id: build-and-archive
9498
env:
9599
CHIP: ${{ matrix.chip }}
96100
ENV: ${{ matrix.env }}
97101
run: |
98102
python tools/ci/build-and-archive.py
99-
- uses: actions/upload-artifact@v3
103+
- id: string
104+
uses: Entepotenz/change-string-case-action-min-dependencies@v1
105+
with:
106+
string: ${{ matrix.chip }}
107+
- uses: actions/upload-artifact@v4
100108
with:
101-
name: Binaries
109+
# FIXME Workaround to (temporarily) not use # in the artifact name, see https://github.com/actions/upload-artifact/issues/473
110+
name: Bin-${{ steps.string.outputs.uppercase }}-${{ matrix.env }}-${{ steps.date.outputs.builddate }}_PR_${{ github.event.number }}_${{ github.run_id }} # Sort by ESP type
102111
path: |
103112
bin
104113
if-no-files-found: ignore
105114

106-
# Repackage separately for ESP82xx and ESP32
107-
repackage:
115+
# Package all ESP82xx and ESP32 into a single ESPEasy-all-Binaries-<date>_PR#<pr_nr>_<runnr>.zip
116+
combine_package:
108117
needs: build
109118
runs-on: ubuntu-22.04
110119
steps:
111120
- uses: actions/checkout@v4
112-
- uses: actions/setup-python@v4
121+
- uses: actions/setup-python@v5
113122
with:
114123
python-version: '3.x'
115-
- uses: actions/cache@v3
124+
- uses: actions/cache@v4
116125
with:
117126
path: ~/.cache/pip
118127
key: ${{ runner.os }}-docs-${{ hashFiles('docs/requirements.txt') }}
119128
- name: Get current date
120129
id: date
121130
run: |
122131
echo "builddate=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
123-
- uses: actions/download-artifact@v3
132+
- name: Download all artifacts
133+
uses: actions/download-artifact@v4
124134
with:
125-
path: artifacts/
126-
- name: Prepare artifacts
135+
path: artifacts/Binaries/bin/
136+
pattern: Bin-*
137+
merge-multiple: true
138+
- name: List all files in the package for single-archive upload
127139
run: |
128-
# ESP82xx
129-
mkdir ESPEasy_dist_ESP82xx
130-
cd dist
131-
find . -exec cp -r --parents {} ../ESPEasy_dist_ESP82xx/ \;
132-
rm ../ESPEasy_dist_ESP82xx/bin/blank_8MB.bin
133-
cd ../artifacts/Binaries
134-
find . -not -name '*ESP32*' -exec mv {} ../../ESPEasy_dist_ESP82xx/bin/ \;
135-
cd ../..
136-
# ESP32 and derived cpus, ESP32 (classic) _MUST_ be last in this list!
137-
for cpu in ESP32s2 ESP32c3 ESP32s3 ESP32c2 ESP32c6 ESP32h2 ESP32solo1 ESP32
138-
do
139-
mkdir ESPEasy_dist_${cpu}
140-
spec="*${cpu}*"
141-
_files=$(find ./artifacts/Binaries -name "$spec"|wc -l)
142-
if [[ $_files > 0 ]]; then
143-
cd dist
144-
find . -exec cp -r --parents {} ../ESPEasy_dist_${cpu}/ \;
145-
cd ../ESPEasy_dist_${cpu}
146-
rm bin/blank_1MB.bin bin/blank_2MB.bin bin/ESPEasy_2step_UploaderMega_1024.bin
147-
cd ../artifacts/Binaries
148-
find . -name "$spec" -exec mv {} ../../ESPEasy_dist_${cpu}/bin/ \;
149-
cd ../..
150-
fi
151-
done
152-
# Each supported cpu has to be listed separately, but empty folders are ignored
153-
- uses: actions/upload-artifact@v3
154-
with:
155-
name: ESPEasy_mega_${{ steps.date.outputs.builddate }}_ESP32_PR#${{ github.event.number }}_${{ github.run_id }}
156-
path: |
157-
ESPEasy_dist_ESP32/*
158-
if-no-files-found: ignore
159-
- uses: actions/upload-artifact@v3
160-
with:
161-
name: ESPEasy_mega_${{ steps.date.outputs.builddate }}_ESP32solo1_PR#${{ github.event.number }}_${{ github.run_id }}
162-
path: |
163-
ESPEasy_dist_ESP32solo1/*
164-
if-no-files-found: ignore
165-
- uses: actions/upload-artifact@v3
140+
cd artifacts/Binaries/
141+
ls -R
142+
- uses: actions/upload-artifact@v4
166143
with:
167-
name: ESPEasy_mega_${{ steps.date.outputs.builddate }}_ESP32s2_PR#${{ github.event.number }}_${{ github.run_id }}
144+
# FIXME Workaround to (temporarily) not use # in the artifact name, see https://github.com/actions/upload-artifact/issues/473
145+
name: ESPEasy-all-Binaries-${{ steps.date.outputs.builddate }}_PR_${{ github.event.number }}_${{ github.run_id }}
168146
path: |
169-
ESPEasy_dist_ESP32s2/*
147+
artifacts/Binaries/
170148
if-no-files-found: ignore
171-
- uses: actions/upload-artifact@v3
172-
with:
173-
name: ESPEasy_mega_${{ steps.date.outputs.builddate }}_ESP32c3_PR#${{ github.event.number }}_${{ github.run_id }}
174-
path: |
175-
ESPEasy_dist_ESP32c3/*
176-
if-no-files-found: ignore
177-
- uses: actions/upload-artifact@v3
178-
with:
179-
name: ESPEasy_mega_${{ steps.date.outputs.builddate }}_ESP32s3_PR#${{ github.event.number }}_${{ github.run_id }}
180-
path: |
181-
ESPEasy_dist_ESP32s3/*
182-
if-no-files-found: ignore
183-
- uses: actions/upload-artifact@v3
184-
with:
185-
name: ESPEasy_mega_${{ steps.date.outputs.builddate }}_ESP32c2_PR#${{ github.event.number }}_${{ github.run_id }}
186-
path: |
187-
ESPEasy_dist_ESP32c2/*
188-
if-no-files-found: ignore
189-
- uses: actions/upload-artifact@v3
190-
with:
191-
name: ESPEasy_mega_${{ steps.date.outputs.builddate }}_ESP32c6_PR#${{ github.event.number }}_${{ github.run_id }}
192-
path: |
193-
ESPEasy_dist_ESP32c6/*
194-
if-no-files-found: ignore
195-
- uses: actions/upload-artifact@v3
196-
with:
197-
name: ESPEasy_mega_${{ steps.date.outputs.builddate }}_ESP32h2_PR#${{ github.event.number }}_${{ github.run_id }}
198-
path: |
199-
ESPEasy_dist_ESP32h2/*
200-
if-no-files-found: ignore
201-
- uses: actions/upload-artifact@v3
202-
with:
203-
name: ESPEasy_mega_${{ steps.date.outputs.builddate }}_ESP82xx_PR#${{ github.event.number }}_${{ github.run_id }}
204-
path: |
205-
ESPEasy_dist_ESP82xx/*
206-
if-no-files-found: ignore
207-
# When successfully re-packaged, the original Binaries can be removed
208-
# comment below 3 lines to not remove the Binaries artifact after repackaging
209-
- uses: geekyeggo/delete-artifact@v2
210-
with:
211-
name: Binaries

.github/workflows/release.yml

+21-16
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
matrix: ${{ steps.set-matrix.outputs.matrix }}
2323
steps:
2424
- uses: actions/checkout@v4
25-
- uses: actions/setup-python@v4
25+
- uses: actions/setup-python@v5
2626
with:
2727
python-version: '3.x'
2828
- id: set-matrix
@@ -37,19 +37,19 @@ jobs:
3737
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
3838
steps:
3939
- uses: actions/checkout@v4
40-
- uses: actions/setup-python@v4
40+
- uses: actions/setup-python@v5
4141
with:
4242
python-version: '3.x'
43-
- uses: actions/cache@v3
43+
- uses: actions/cache@v4
4444
with:
4545
path: ~/.cache/pip
4646
key: ${{ runner.os }}-${{ hashFiles('requirements.txt') }}
47-
- uses: actions/cache@v3
47+
- uses: actions/cache@v4
4848
if: ${{ contains(matrix.env, 'esp32') }}
4949
with:
5050
path: ~/.platformio
5151
key: ${{ runner.os }}-esp32-${{ hashFiles('platformio*.ini') }}
52-
- uses: actions/cache@v3
52+
- uses: actions/cache@v4
5353
if: ${{ contains(matrix.env, 'esp8266') }}
5454
with:
5555
path: ~/.platformio
@@ -66,9 +66,13 @@ jobs:
6666
ENV: ${{ matrix.env }}
6767
run: |
6868
python tools/ci/build-and-archive.py
69-
- uses: actions/upload-artifact@v3
69+
- id: string
70+
uses: Entepotenz/change-string-case-action-min-dependencies@v1
7071
with:
71-
name: Binaries
72+
string: ${{ matrix.chip }}
73+
- uses: actions/upload-artifact@v4
74+
with:
75+
name: Bin-${{ steps.string.outputs.uppercase }}-${{ matrix.env }}
7276
path: |
7377
bin
7478
if-no-files-found: ignore
@@ -78,10 +82,10 @@ jobs:
7882
runs-on: ubuntu-22.04
7983
steps:
8084
- uses: actions/checkout@v4
81-
- uses: actions/setup-python@v4
85+
- uses: actions/setup-python@v5
8286
with:
8387
python-version: '3.x'
84-
- uses: actions/cache@v3
88+
- uses: actions/cache@v4
8589
with:
8690
path: ~/.cache/pip
8791
key: ${{ runner.os }}-docs-${{ hashFiles('docs/requirements.txt') }}
@@ -98,7 +102,7 @@ jobs:
98102
cd dist
99103
zip -r -qq ../ESPEasy_dist.zip *
100104
cd ..
101-
- uses: actions/upload-artifact@v3
105+
- uses: actions/upload-artifact@v4
102106
with:
103107
name: Distribution
104108
path: |
@@ -112,7 +116,7 @@ jobs:
112116
notes: ${{ steps.release-notes.outputs.result }}
113117
steps:
114118
- id: release-notes
115-
uses: actions/github-script@v6
119+
uses: actions/github-script@v7
116120
with:
117121
result-encoding: string
118122
script: |
@@ -134,23 +138,24 @@ jobs:
134138
needs: [build, prepare-dist, prepare-notes]
135139
runs-on: ubuntu-22.04
136140
steps:
137-
- uses: actions/setup-python@v4
141+
- uses: actions/setup-python@v5
138142
with:
139143
python-version: '3.x'
140144
- name: Get current date
141145
id: date
142146
run: |
143147
echo "builddate=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
144-
- uses: actions/download-artifact@v3
148+
- name: Download all artifacts
149+
uses: actions/download-artifact@v4
145150
with:
146-
path: artifacts/
151+
path: artifacts/Binaries/bin/
152+
pattern: Bin-*
153+
merge-multiple: true
147154
- name: Repackage for release upload
148155
run: |
149156
ls -R
150157
sudo apt install zipmerge zip
151158
cd artifacts/Binaries
152-
mkdir bin
153-
mv *.* bin
154159
find . -not -name '*ESP32*' -print | zip -@ ../../ESPEasy_ESP82xx.zip
155160
# ESP32 and derived chips
156161
# TODO if/when available: ESP32h2

tools/ci/generate-matrix.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,25 @@
77

88
import json
99
import os
10+
import re
1011
from platformio.project.config import ProjectConfig
1112

1213

1314
def get_jobs(cfg):
15+
regex = re.compile(r".*(ESP[^_]*).*")
1416
for env in cfg.envs():
1517
platform = cfg.get("env:{}".format(env), "platform")
18+
match = regex.match(env)
19+
if type(match) == re.Match:
20+
typ = match.group(1)
21+
if "ESP8285" == typ:
22+
typ = "ESP8266" # Generalize ESP8285 into ESP8266
23+
else:
24+
typ = "ESP8266" # Catch WROOM02 and some other 'hard_' builds
1625
if "espressif8266" in platform:
17-
yield {"chip": "esp8266", "env": env}
26+
yield {"chip": typ.lower(), "env": env}
1827
elif "espressif32" in platform:
19-
yield {"chip": "esp32", "env": env}
28+
yield {"chip": typ.lower(), "env": env}
2029
else:
2130
raise ValueError(
2231
"Unknown `platform = {}` for `[env:{}]`".format(platform, env)

0 commit comments

Comments
 (0)