1
1
name : Cron Build
2
2
3
- on :
3
+ on :
4
4
schedule :
5
5
# ┌───────────── minute (0 - 59)
6
6
# │ ┌───────────── hour (0 - 23)
7
7
# │ │ ┌───────────── day of the month (1 - 31)
8
8
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
9
9
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
10
- # │ │ │ │ │
10
+ # │ │ │ │ │
11
11
# │ │ │ │ │
12
12
# │ │ │ │ │
13
13
# * * * * *
@@ -17,128 +17,187 @@ defaults:
17
17
run :
18
18
shell : bash
19
19
20
+ env :
21
+ LATEST_RELEASE_BRANCH : " release/v5.1" # Change this to the latest release branch so the checkouts are done correctly
22
+
20
23
jobs :
21
- run :
22
- name : Build with IDF ${{ matrix.idf_branch }}
24
+ gen-matrix :
25
+ name : Generate matrix
23
26
runs-on : ubuntu-latest
24
-
27
+ outputs :
28
+ matrix : ${{ steps.gen-matrix.outputs.matrix }}
29
+ branches : ${{ steps.gen-matrix.outputs.branches }}
30
+ steps :
31
+ - uses : actions/checkout@v4
32
+ with :
33
+ fetch-depth : 0
34
+
35
+ - name : Generate matrix
36
+ id : gen-matrix
37
+ env :
38
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
39
+ run : |
40
+ set -e
41
+
42
+ # Change this based on the IDF branches we want to build. Don't forget to update env.LATEST_RELEASE_BRANCH
43
+ all_branches=("release/v5.1")
44
+
45
+ # Change this based on the COMMON targets for all branches we want to build.
46
+ common_targets="[\"esp32\", \"esp32s2\", \"esp32s3\", \"esp32c2\", \"esp32c3\", \"esp32c6\", \"esp32h2\"]"
47
+
48
+ # For additional targets per branch, add them here
49
+ additional_targets="[{\"idf_branch\": \"release/v5.3\", \"target\": \"esp32p4\"}]"
50
+
51
+ branches="["
52
+ matrix="{"
53
+
54
+ for branch in ${all_branches[@]}; do
55
+ if [ "$branch" == "$LATEST_RELEASE_BRANCH" ]; then
56
+ git checkout master
57
+ else
58
+ git checkout $branch
59
+ fi
60
+ export IDF_BRANCH=$branch
61
+ source ./tools/check-deploy-needed.sh
62
+ if [ "$DEPLOY_NEEDED" == "1" ]; then
63
+ branches+="\"$branch\","
64
+ fi
65
+ done
66
+
67
+ branches="${branches%,}]"
68
+ matrix+="\"idf_branch\": $branches,"
69
+ matrix+="\"target\": $common_targets,"
70
+
71
+ matrix+="\"include\": "
72
+ # Add all additional targets that are in the selected branches
73
+ matrix+=$(echo $additional_targets | jq --argjson branches "$branches" '[.[] | select(.idf_branch as $branch | $branches | index($branch))]')
74
+
75
+ matrix+="}"
76
+
77
+ echo "Branches: $branches"
78
+
79
+ echo "Matrix:"
80
+ echo "$matrix" | jq .
81
+
82
+ if [ ! -x $GITHUB_OUTPUT ]; then
83
+ echo "matrix=$matrix" >> $GITHUB_OUTPUT
84
+ echo "branches=$branches" >> $GITHUB_OUTPUT
85
+ fi
86
+
87
+ build-libs :
88
+ name : Build with IDF ${{ matrix.idf_branch }} for ${{ matrix.target }}
89
+ runs-on : ubuntu-latest
90
+ if : needs.gen-matrix.outputs.branches != '[]'
91
+ needs : gen-matrix
25
92
strategy :
26
93
fail-fast : false
27
- matrix :
28
- idf_branch : [release/v5.1, release/v4.4] # , release/v3.3]
94
+ matrix : ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
29
95
steps :
30
96
- uses : actions/checkout@v4
31
97
with :
32
- fetch-depth : 0
98
+ # Useful workaround for the checkout action to work with the matrix
99
+ # https://github.com/actions/runner/issues/409#issuecomment-1013325196
100
+ ref : ${{ matrix.idf_branch == env.LATEST_RELEASE_BRANCH && 'master' || matrix.idf_branch }}
101
+
33
102
- name : Install dependencies
34
103
run : bash ./tools/prepare-ci.sh
104
+
35
105
- name : Build
36
106
env :
37
- GITHUB_TOKEN : ${{ secrets.PUSH_TOKEN }}
107
+ GITHUB_TOKEN : ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }}
38
108
GIT_AUTHOR_EMAIL : ${{ secrets.PUSH_EMAIL }}
39
109
GIT_COMMITTER_EMAIL : ${{ secrets.PUSH_EMAIL }}
40
110
IDF_BRANCH : ${{ matrix.idf_branch }}
111
+ TARGET : ${{ matrix.target }}
41
112
run : |
42
- git checkout ${{ matrix.idf_branch }} || echo "Using master branch"
43
113
bash ./tools/cron.sh
114
+
115
+ - name : Replace invalid characters in the artifact name
116
+ run : |
117
+ branch=${{ matrix.idf_branch }}
118
+ echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
119
+
44
120
- name : Upload build
45
121
if : failure()
46
122
uses : actions/upload-artifact@v4
47
123
with :
48
- name : build
124
+ name : build-${{ env.libs_branch }}-${{ matrix.target }}
49
125
path : build
50
- - name : Upload archive
126
+
127
+ - name : Upload library files
51
128
uses : actions/upload-artifact@v4
52
129
with :
53
- name : artifacts
130
+ name : libs-${{ env.libs_branch }}-${{ matrix.target }}
54
131
path : dist
55
132
133
+ combine-artifacts :
134
+ name : Combine artifacts for IDF ${{ matrix.idf_branch }}
135
+ runs-on : ubuntu-latest
136
+ needs : [gen-matrix, build-libs]
137
+ # Condition is evaluated before the job is run so it won't cause a failure
138
+ if : needs.gen-matrix.outputs.branches != '[]'
139
+ strategy :
140
+ fail-fast : false
141
+ matrix :
142
+ idf_branch : ${{ fromJson(needs.gen-matrix.outputs.branches) }}
143
+ steps :
144
+ - uses : actions/checkout@v4
145
+ with :
146
+ # Useful workaround for the checkout action to work with the matrix
147
+ # https://github.com/actions/runner/issues/409#issuecomment-1013325196
148
+ ref : ${{ matrix.idf_branch == env.LATEST_RELEASE_BRANCH && 'master' || matrix.idf_branch }}
149
+
150
+ - name : Replace invalid characters in the artifact name
151
+ run : |
152
+ branch=${{ matrix.idf_branch }}
153
+ echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
154
+
155
+ - name : Download artifacts
156
+ uses : actions/download-artifact@v4
157
+ with :
158
+ path : dist
159
+ pattern : libs-${{ env.libs_branch }}-*
160
+ merge-multiple : true
161
+
162
+ - name : Combine artifacts
163
+ run : |
164
+ set -e
165
+ mkdir -p out
166
+
167
+ libs_folder="out/tools/esp32-arduino-libs"
168
+
169
+ files=$(find dist -name 'arduino-esp32-libs-esp*.tar.gz')
170
+ for file in $files; do
171
+ echo "Extracting $file"
172
+ tar zxvf $file -C out
173
+ cat $libs_folder/versions.txt >> $libs_folder/versions_full.txt
174
+ done
175
+
176
+ # Merge versions.txt files
177
+ awk -i inplace '!seen[$0]++' $libs_folder/versions_full.txt
178
+ mv -f $libs_folder/versions_full.txt $libs_folder/versions.txt
179
+
180
+ cd $libs_folder && tar zcf ../../../dist/esp32-arduino-libs.tar.gz * && cd ../../..
181
+ cp out/package_esp32_index.template.json dist/package_esp32_index.template.json
182
+
183
+ - name : Upload full esp32-arduino-libs archive
184
+ uses : actions/upload-artifact@v4
185
+ with :
186
+ name : esp32-arduino-libs
187
+ path : dist/esp32-arduino-libs.tar.gz
56
188
57
- # check:
58
- # name: Check if result should be deployed
59
- # runs-on: ubuntu-latest
60
- # strategy:
61
- # matrix:
62
- # branch: [release/v5.1, release/v4.4] #, release/v3.3]
63
- # outputs:
64
- # idf_branch: ${{ steps.check.outputs.idf_branch }}
65
- # idf_commit: ${{ steps.check.outputs.idf_commit }}
66
- # ar_branch: ${{ steps.check.outputs.ar_branch }}
67
- # ar_new_commit_message: ${{ steps.check.outputs.ar_new_commit_message }}
68
- # ar_new_branch_name: ${{ steps.check.outputs.ar_new_branch_name }}
69
- # ar_new_pr_title: ${{ steps.check.outputs.ar_new_pr_title }}
70
- # ar_has_commit: ${{ steps.check.outputs.ar_has_commit }}
71
- # ar_has_branch: ${{ steps.check.outputs.ar_has_branch }}
72
- # ar_has_pr: ${{ steps.check.outputs.ar_has_pr }}
73
- # libs_version: ${{ steps.check.outputs.libs_version }}
74
- # libs_has_commit: ${{ steps.check.outputs.libs_has_commit }}
75
- # libs_has_branch: ${{ steps.check.outputs.libs_has_branch }}
76
- # steps:
77
- # - uses: actions/checkout@v3
78
- # - id: check
79
- # env:
80
- # GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
81
- # GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
82
- # GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
83
- # IDF_BRANCH: ${{ matrix.idf_branch }}
84
- # run: bash ./tools/check-deploy-needed.sh
85
-
86
- # build:
87
- # name: Build Libs for ${{ matrix.target }}
88
- # runs-on: ubuntu-latest
89
- # needs: check
90
- # if: needs.check.outputs.libs_has_commit == '0' || needs.check.outputs.ar_has_commit == '0'
91
- # strategy:
92
- # matrix:
93
- # target: [esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32h2]
94
- # fail-fast: false
95
- # steps:
96
- # - uses: actions/checkout@v3
97
- # # - name: Install dependencies
98
- # # run: bash ./tools/prepare-ci.sh
99
- # - shell: bash
100
- # name: Build Libs for ${{ matrix.target }}
101
- # run: echo ${{ matrix.target }}
102
- # # run: bash ./build.sh -t ${{ matrix.target }}
103
- # # - name: Upload archive
104
- # # uses: actions/upload-artifact@v3
105
- # # with:
106
- # # name: artifacts
107
- # # path: dist
108
-
109
- # deploy:
110
- # name: Deploy build
111
- # runs-on: ubuntu-latest
112
- # needs: [check, build]
113
- # steps:
114
- # - uses: actions/checkout@v3
115
- # - shell: bash
116
- # env:
117
- # GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
118
- # GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
119
- # GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
120
- # IDF_BRANCH: ${{ needs.check.outputs.idf_branch }}
121
- # IDF_COMMIT: ${{ needs.check.outputs.idf_commit }}
122
- # AR_BRANCH: ${{ needs.check.outputs.ar_branch }}
123
- # AR_NEW_COMMIT_MESSAGE: ${{ needs.check.outputs.ar_new_commit_message }}
124
- # AR_NEW_BRANCH_NAME: ${{ needs.check.outputs.ar_new_branch_name }}
125
- # AR_NEW_PR_TITLE: ${{ needs.check.outputs.ar_new_pr_title }}
126
- # AR_HAS_COMMIT: ${{ needs.check.outputs.ar_has_commit }}
127
- # AR_HAS_BRANCH: ${{ needs.check.outputs.ar_has_branch }}
128
- # AR_HAS_PR: ${{ needs.check.outputs.ar_has_pr }}
129
- # LIBS_VERSION: ${{ needs.check.outputs.libs_version }}
130
- # LIBS_HAS_COMMIT: ${{ needs.check.outputs.libs_has_commit }}
131
- # LIBS_HAS_BRANCH: ${{ needs.check.outputs.libs_has_branch }}
132
- # run: |
133
- # echo "IDF_COMMIT: $IDF_COMMIT"
134
- # echo "AR_BRANCH: $AR_BRANCH"
135
- # echo "AR_NEW_COMMIT_MESSAGE: $AR_NEW_COMMIT_MESSAGE"
136
- # echo "AR_NEW_BRANCH_NAME: $AR_NEW_BRANCH_NAME"
137
- # echo "AR_NEW_PR_TITLE: $AR_NEW_PR_TITLE"
138
- # echo "AR_HAS_COMMIT: $AR_HAS_COMMIT"
139
- # echo "AR_HAS_BRANCH: $AR_HAS_BRANCH"
140
- # echo "AR_HAS_PR: $AR_HAS_PR"
141
- # echo "LIBS_VERSION: $LIBS_VERSION"
142
- # echo "LIBS_HAS_COMMIT: $LIBS_HAS_COMMIT"
143
- # echo "LIBS_HAS_BRANCH: $LIBS_HAS_BRANCH"
189
+ - name : Upload package_esp32_index.template.json
190
+ uses : actions/upload-artifact@v4
191
+ with :
192
+ name : package-esp32-index-json
193
+ path : dist/package_esp32_index.template.json
144
194
195
+ - name : Push changes
196
+ if : github.repository == 'espressif/esp32-arduino-lib-builder'
197
+ env :
198
+ GITHUB_TOKEN : ${{ secrets.PUSH_TOKEN }}
199
+ GIT_AUTHOR_EMAIL : ${{ secrets.PUSH_EMAIL }}
200
+ GIT_COMMITTER_EMAIL : ${{ secrets.PUSH_EMAIL }}
201
+ IDF_BRANCH : ${{ matrix.idf_branch }}
202
+ run : |
203
+ bash ./tools/push-to-arduino.sh
0 commit comments