Skip to content

Commit 4bef12c

Browse files
committed
update
1 parent 6f6313f commit 4bef12c

File tree

4 files changed

+94
-132
lines changed

4 files changed

+94
-132
lines changed

.github/workflows/cron.yml

+92-46
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,14 @@ on:
1212
# │ │ │ │ │
1313
# * * * * *
1414
- cron: '0 */6 * * *'
15-
workflow_dispatch:
16-
inputs:
17-
idf_branch:
18-
# This input can be a comma-separated list of strings (e.g. "release/v5.1,release/v5.3") or "all" to build all branches.
19-
# For IDF versions before v5.1, "all" is not supported. Use a specific branch instead.
20-
description: 'IDF branch to build (check workflow file for instructions on how to use this input)'
21-
required: true
22-
default: 'all'
23-
target:
24-
# This input can be a comma-separated list of strings (e.g. "esp32,esp32s2") or "all" to build all targets.
25-
# For IDF versions before v5.1, "all" is not supported. Use a specific target list instead.
26-
description: 'Target to build (check workflow file for instructions on how to use this input)'
27-
required: true
28-
default: 'all'
2915

3016
defaults:
3117
run:
3218
shell: bash
3319

20+
env:
21+
LATEST_RELEASE_BRANCH: "release/v5.1" # Change this to the latest release branch so the checkouts are done correctly
22+
3423
jobs:
3524
gen-matrix:
3625
name: Generate matrix
@@ -40,34 +29,75 @@ jobs:
4029
branches: ${{ steps.gen-matrix.outputs.branches }}
4130
steps:
4231
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
4335
- name: Generate matrix
4436
id: gen-matrix
4537
run: |
46-
bash ./tools/cron-gen-matrix.sh "${{ github.event.inputs.idf_branch }}" "${{ github.event.inputs.target }}"
38+
set -e
39+
40+
# Change this based on the IDF branches we want to build. Don't forget to update env.LATEST_RELEASE_BRANCH
41+
all_branches=("release/v5.1")
42+
43+
# Change this based on the COMMON targets for all branches we want to build.
44+
common_targets="[\"esp32\", \"esp32s2\", \"esp32s3\", \"esp32c2\", \"esp32c3\", \"esp32c6\", \"esp32h2\"]"
45+
46+
# For additional targets per branch, add them here
47+
additional_targets="[{\"idf_branch\": \"release/v5.3\", \"target\": \"esp32p4\"}]"
48+
49+
branches="["
50+
matrix="{"
51+
52+
for branch in ${all_branches[@]}; do
53+
if [ "$branch" == "$LATEST_RELEASE_BRANCH" ]; then
54+
git checkout master
55+
else
56+
git checkout $branch
57+
fi
58+
export IDF_BRANCH=$branch
59+
./tools/check-deploy-needed.sh
60+
if [ "$DEPLOY_NEEDED" == "1" ]; then
61+
branches+="\"$branch\","
62+
fi
63+
done
64+
65+
branches="${branches%,}]"
66+
matrix+="\"idf_branch\": $branches,"
67+
matrix+="\"target\": $common_targets,"
68+
69+
matrix+="\"include\": "
70+
# Add all additional targets that are in the selected branches
71+
matrix+=$(echo $additional_targets | jq --argjson branches "$branches" '[.[] | select(.idf_branch as $branch | $branches | index($branch))]')
72+
73+
matrix+="}"
74+
75+
echo "Branches: $branches"
76+
77+
echo "Matrix:"
78+
echo "$matrix" | jq .
79+
80+
if [ ! -x $GITHUB_OUTPUT ]; then
81+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
82+
echo "branches=$branches" >> $GITHUB_OUTPUT
83+
fi
4784
4885
build-libs:
4986
name: Build with IDF ${{ matrix.idf_branch }} for ${{ matrix.target }}
5087
runs-on: ubuntu-latest
88+
if: needs.gen-matrix.outputs.branches != '[]'
5189
needs: gen-matrix
5290
strategy:
5391
fail-fast: false
5492
matrix: ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
5593
steps:
5694
- uses: actions/checkout@v4
5795
with:
58-
fetch-depth: 0
59-
60-
- name: Check if result should be deployed
61-
id: check
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }}
64-
IDF_BRANCH: ${{ matrix.idf_branch }}
65-
run: |
66-
git checkout ${{ env.IDF_BRANCH }} || echo "Using master branch"
67-
bash ./tools/check-deploy-needed.sh
96+
# Useful workaround for the checkout action to work with the matrix
97+
# https://github.com/actions/runner/issues/409#issuecomment-1013325196
98+
ref: ${{ matrix.idf_branch == env.LATEST_RELEASE_BRANCH && 'master' || matrix.idf_branch }}
6899

69100
- name: Install dependencies
70-
if: env.libs_has_commit == '0' || env.ar_has_commit == '0'
71101
run: bash ./tools/prepare-ci.sh
72102

73103
- name: Build
@@ -77,75 +107,91 @@ jobs:
77107
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
78108
IDF_BRANCH: ${{ matrix.idf_branch }}
79109
TARGETS: ${{ matrix.target }}
80-
if: env.libs_has_commit == '0' || env.ar_has_commit == '0'
81110
run: |
82111
bash ./tools/cron.sh
83112
113+
- name: Replace invalid characters in the artifact name
114+
run: |
115+
branch=${{ matrix.idf_branch }}
116+
echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
117+
84118
- name: Upload build
85-
if: failure() && (env.libs_has_commit == '0' || env.ar_has_commit == '0')
119+
if: failure()
86120
uses: actions/upload-artifact@v4
87121
with:
88-
name: build-${{ env.libs_version }}-${{ matrix.target }}
122+
name: build-${{ env.libs_branch }}-${{ matrix.target }}
89123
path: build
90124

91125
- name: Upload library files
92-
if: env.libs_has_commit == '0' || env.ar_has_commit == '0'
93126
uses: actions/upload-artifact@v4
94127
with:
95-
name: libs-${{ env.libs_version }}-${{ matrix.target }}
128+
name: libs-${{ env.libs_branch }}-${{ matrix.target }}
96129
path: dist
97130

98131
combine-artifacts:
99132
name: Combine artifacts for IDF ${{ matrix.idf_branch }}
100133
runs-on: ubuntu-latest
101134
needs: [gen-matrix, build-libs]
135+
# Condition is evaluated before the job is run so it won't cause a failure
136+
if: needs.gen-matrix.outputs.branches != '[]'
102137
strategy:
103138
fail-fast: false
104139
matrix:
105140
idf_branch: ${{ fromJson(needs.gen-matrix.outputs.branches) }}
106141
steps:
107142
- uses: actions/checkout@v4
108143
with:
109-
fetch-depth: 0
144+
# Useful workaround for the checkout action to work with the matrix
145+
# https://github.com/actions/runner/issues/409#issuecomment-1013325196
146+
ref: ${{ matrix.idf_branch == env.LATEST_RELEASE_BRANCH && 'master' || matrix.idf_branch }}
110147

111-
- name: Check if result should be deployed
112-
id: check
113-
env:
114-
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }}
115-
IDF_BRANCH: ${{ matrix.idf_branch }}
148+
- name: Replace invalid characters in the artifact name
116149
run: |
117-
git checkout ${{ env.IDF_BRANCH }} || echo "Using master branch"
118-
bash ./tools/check-deploy-needed.sh
150+
branch=${{ matrix.idf_branch }}
151+
echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
119152
120153
- name: Download artifacts
121-
if: env.libs_has_commit == '0' || env.ar_has_commit == '0'
122154
uses: actions/download-artifact@v4
123155
with:
124156
path: dist
125-
pattern: libs-${{ env.libs_version }}-*
157+
pattern: libs-${{ env.libs_branch }}-*
126158
merge-multiple: true
127159

128160
- name: Combine artifacts
129-
if: env.libs_has_commit == '0' || env.ar_has_commit == '0'
130161
run: |
131-
bash ./tools/cron-combine.sh
162+
set -e
163+
mkdir -p out
164+
165+
libs_folder="out/tools/esp32-arduino-libs"
166+
167+
files=$(find dist -name 'arduino-esp32-libs-esp*.tar.gz')
168+
for file in $files; do
169+
echo "Extracting $file"
170+
tar zxvf $file -C out
171+
cat $libs_folder/versions.txt >> $libs_folder/versions_full.txt
172+
done
173+
174+
# Merge versions.txt files
175+
awk -i inplace '!seen[$0]++' $libs_folder/versions_full.txt
176+
mv -f $libs_folder/versions_full.txt $libs_folder/versions.txt
177+
178+
cd $libs_folder && tar zcf ../../../dist/esp32-arduino-libs.tar.gz * && cd ../../..
179+
cp out/package_esp32_index.template.json dist/package_esp32_index.template.json
132180
133181
- name: Upload full esp32-arduino-libs archive
134-
if: env.libs_has_commit == '0' || env.ar_has_commit == '0'
135182
uses: actions/upload-artifact@v4
136183
with:
137184
name: esp32-arduino-libs
138185
path: dist/esp32-arduino-libs.tar.gz
139186

140187
- name: Upload package_esp32_index.template.json
141-
if: env.libs_has_commit == '0' || env.ar_has_commit == '0'
142188
uses: actions/upload-artifact@v4
143189
with:
144190
name: package-esp32-index-json
145191
path: dist/package_esp32_index.template.json
146192

147193
- name: Push changes
148-
if: github.repository == 'espressif/esp32-arduino-lib-builder' && (env.libs_has_commit == '0' || env.ar_has_commit == '0')
194+
if: github.repository == 'espressif/esp32-arduino-lib-builder'
149195
env:
150196
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
151197
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}

tools/check-deploy-needed.sh

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ fi
9191

9292
if [ "$LIBS_HAS_COMMIT" == "0" ] || [ "$AR_HAS_COMMIT" == "0" ]; then
9393
echo "Deploy needed"
94+
export DEPLOY_NEEDED="1"
9495
else
9596
echo "Deploy not needed. Skipping..."
97+
export DEPLOY_NEEDED="0"
9698
fi

tools/cron-combine.sh

-20
This file was deleted.

tools/cron-gen-matrix.sh

-66
This file was deleted.

0 commit comments

Comments
 (0)