12
12
# │ │ │ │ │
13
13
# * * * * *
14
14
- 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'
29
15
30
16
defaults :
31
17
run :
32
18
shell : bash
33
19
20
+ env :
21
+ LATEST_RELEASE_BRANCH : " release/v5.1" # Change this to the latest release branch so the checkouts are done correctly
22
+
34
23
jobs :
35
24
gen-matrix :
36
25
name : Generate matrix
@@ -40,34 +29,75 @@ jobs:
40
29
branches : ${{ steps.gen-matrix.outputs.branches }}
41
30
steps :
42
31
- uses : actions/checkout@v4
32
+ with :
33
+ fetch-depth : 0
34
+
43
35
- name : Generate matrix
44
36
id : gen-matrix
45
37
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
47
84
48
85
build-libs :
49
86
name : Build with IDF ${{ matrix.idf_branch }} for ${{ matrix.target }}
50
87
runs-on : ubuntu-latest
88
+ if : needs.gen-matrix.outputs.branches != '[]'
51
89
needs : gen-matrix
52
90
strategy :
53
91
fail-fast : false
54
92
matrix : ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
55
93
steps :
56
94
- uses : actions/checkout@v4
57
95
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 }}
68
99
69
100
- name : Install dependencies
70
- if : env.libs_has_commit == '0' || env.ar_has_commit == '0'
71
101
run : bash ./tools/prepare-ci.sh
72
102
73
103
- name : Build
@@ -77,75 +107,91 @@ jobs:
77
107
GIT_COMMITTER_EMAIL : ${{ secrets.PUSH_EMAIL }}
78
108
IDF_BRANCH : ${{ matrix.idf_branch }}
79
109
TARGETS : ${{ matrix.target }}
80
- if : env.libs_has_commit == '0' || env.ar_has_commit == '0'
81
110
run : |
82
111
bash ./tools/cron.sh
83
112
113
+ - name : Replace invalid characters in the artifact name
114
+ run : |
115
+ branch=${{ matrix.idf_branch }}
116
+ echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
117
+
84
118
- name : Upload build
85
- if : failure() && (env.libs_has_commit == '0' || env.ar_has_commit == '0')
119
+ if : failure()
86
120
uses : actions/upload-artifact@v4
87
121
with :
88
- name : build-${{ env.libs_version }}-${{ matrix.target }}
122
+ name : build-${{ env.libs_branch }}-${{ matrix.target }}
89
123
path : build
90
124
91
125
- name : Upload library files
92
- if : env.libs_has_commit == '0' || env.ar_has_commit == '0'
93
126
uses : actions/upload-artifact@v4
94
127
with :
95
- name : libs-${{ env.libs_version }}-${{ matrix.target }}
128
+ name : libs-${{ env.libs_branch }}-${{ matrix.target }}
96
129
path : dist
97
130
98
131
combine-artifacts :
99
132
name : Combine artifacts for IDF ${{ matrix.idf_branch }}
100
133
runs-on : ubuntu-latest
101
134
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 != '[]'
102
137
strategy :
103
138
fail-fast : false
104
139
matrix :
105
140
idf_branch : ${{ fromJson(needs.gen-matrix.outputs.branches) }}
106
141
steps :
107
142
- uses : actions/checkout@v4
108
143
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 }}
110
147
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
116
149
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
119
152
120
153
- name : Download artifacts
121
- if : env.libs_has_commit == '0' || env.ar_has_commit == '0'
122
154
uses : actions/download-artifact@v4
123
155
with :
124
156
path : dist
125
- pattern : libs-${{ env.libs_version }}-*
157
+ pattern : libs-${{ env.libs_branch }}-*
126
158
merge-multiple : true
127
159
128
160
- name : Combine artifacts
129
- if : env.libs_has_commit == '0' || env.ar_has_commit == '0'
130
161
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
132
180
133
181
- name : Upload full esp32-arduino-libs archive
134
- if : env.libs_has_commit == '0' || env.ar_has_commit == '0'
135
182
uses : actions/upload-artifact@v4
136
183
with :
137
184
name : esp32-arduino-libs
138
185
path : dist/esp32-arduino-libs.tar.gz
139
186
140
187
- name : Upload package_esp32_index.template.json
141
- if : env.libs_has_commit == '0' || env.ar_has_commit == '0'
142
188
uses : actions/upload-artifact@v4
143
189
with :
144
190
name : package-esp32-index-json
145
191
path : dist/package_esp32_index.template.json
146
192
147
193
- 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'
149
195
env :
150
196
GITHUB_TOKEN : ${{ secrets.PUSH_TOKEN }}
151
197
GIT_AUTHOR_EMAIL : ${{ secrets.PUSH_EMAIL }}
0 commit comments