Skip to content

Commit 26ff50a

Browse files
committed
Move to workflow call
1 parent 18e877b commit 26ff50a

File tree

4 files changed

+164
-185
lines changed

4 files changed

+164
-185
lines changed

Diff for: .github/workflows/cron.yml

+11-180
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Cron Build
1+
name: Cron Deploy
22

33
on:
44
schedule:
@@ -17,187 +17,18 @@ defaults:
1717
run:
1818
shell: bash
1919

20-
env:
21-
LATEST_RELEASE_BRANCH: "release/v5.1" # Change this to the latest release branch so the checkouts are done correctly
22-
2320
jobs:
24-
gen-matrix:
25-
name: Generate matrix
26-
runs-on: ubuntu-latest
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-
8721
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
92-
strategy:
93-
fail-fast: false
94-
matrix: ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
95-
steps:
96-
- uses: actions/checkout@v4
97-
with:
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-
102-
- name: Install dependencies
103-
run: bash ./tools/prepare-ci.sh
104-
105-
- name: Build
106-
env:
107-
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }}
108-
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
109-
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
110-
IDF_BRANCH: ${{ matrix.idf_branch }}
111-
TARGET: ${{ matrix.target }}
112-
run: |
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-
120-
- name: Upload build
121-
if: failure()
122-
uses: actions/upload-artifact@v4
123-
with:
124-
name: build-${{ env.libs_branch }}-${{ matrix.target }}
125-
path: build
126-
127-
- name: Upload library files
128-
uses: actions/upload-artifact@v4
129-
with:
130-
name: libs-${{ env.libs_branch }}-${{ matrix.target }}
131-
path: dist
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 != '[]'
22+
name: Build with IDF ${{ matrix.idf_branch }}
23+
uses: ./.github/workflows/cron_build.yml
24+
with:
25+
idf_branch: ${{ matrix.idf_branch }}
26+
lib_builder_branch: ${{ matrix.lib_builder_branch }}
27+
targets: ${{ matrix.targets }}
13928
strategy:
14029
fail-fast: false
14130
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
188-
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
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
31+
include:
32+
- idf_branch: "release/v5.1"
33+
lib_builder_branch: "master"
34+
targets: "esp32,esp32s2,esp32s3,esp32c3,esp32c6,esp32h2"

Diff for: .github/workflows/cron_build.yml

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Cron Build Matrix
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
idf_branch:
7+
type: string
8+
required: true
9+
description: 'IDF branch to build'
10+
lib_builder_branch:
11+
type: string
12+
required: true
13+
description: 'Branch of the lib-builder to use'
14+
targets:
15+
type: string
16+
required: true
17+
description: 'Targets to build'
18+
19+
env:
20+
IDF_BRANCH: ${{ inputs.idf_branch }}
21+
22+
jobs:
23+
check-if-needed:
24+
name: Check if deploy is needed for ${{ inputs.idf_branch }}
25+
runs-on: ubuntu-latest
26+
outputs:
27+
deploy_needed: ${{ steps.check.outputs.deploy_needed }}
28+
targets_list: ${{ steps.check.outputs.targets_list }}
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
ref: ${{ inputs.lib_builder_branch }}
33+
34+
- name: Check deploy and generate variables
35+
id: check
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
source ./tools/check-deploy-needed.sh
40+
targets_list=$(echo "${{ inputs.targets }}" | sed 's/ *, */,/g' | sed 's/^/["/' | sed 's/$/"]/' | sed 's/,/","/g')
41+
echo "Targets list: $targets_list"
42+
echo "deploy_needed=$DEPLOY_NEEDED" >> $GITHUB_OUTPUT
43+
echo "targets_list=$targets_list" >> $GITHUB_OUTPUT
44+
45+
build-libs:
46+
name: Build for ${{ matrix.target }} (${{ inputs.idf_branch }})
47+
runs-on: ubuntu-latest
48+
if: needs.check-if-needed.outputs.deploy_needed == '1'
49+
needs: check-if-needed
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
target: ${{ fromJson(needs.check-if-needed.outputs.targets_list) }}
54+
steps:
55+
- uses: actions/checkout@v4
56+
with:
57+
ref: ${{ inputs.lib_builder_branch }}
58+
59+
- name: Install dependencies
60+
run: bash ./tools/prepare-ci.sh
61+
62+
- name: Build
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }}
65+
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
66+
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
67+
TARGET: ${{ matrix.target }}
68+
run: |
69+
bash ./tools/cron.sh
70+
71+
- name: Replace invalid characters in the artifact name
72+
run: |
73+
branch=${{ inputs.idf_branch }}
74+
echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
75+
76+
- name: Upload build
77+
if: failure()
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: build-${{ env.libs_branch }}-${{ matrix.target }}
81+
path: build
82+
83+
- name: Upload library files
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: libs-${{ env.libs_branch }}-${{ matrix.target }}
87+
path: dist
88+
89+
combine-artifacts:
90+
name: Combine artifacts for IDF ${{ inputs.idf_branch }}
91+
runs-on: ubuntu-latest
92+
needs: [check-if-needed, build-libs]
93+
if: needs.check-if-needed.outputs.deploy_needed == '1'
94+
steps:
95+
- uses: actions/checkout@v4
96+
with:
97+
ref: ${{ inputs.lib_builder_branch }}
98+
99+
- name: Replace invalid characters in the artifact name
100+
run: |
101+
branch=${{ inputs.idf_branch }}
102+
echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
103+
104+
- name: Download artifacts
105+
uses: actions/download-artifact@v4
106+
with:
107+
path: dist
108+
pattern: libs-${{ env.libs_branch }}-*
109+
merge-multiple: true
110+
111+
- name: Combine artifacts
112+
run: bash ./tools/combine-artifacts.sh
113+
114+
- name: Upload full esp32-arduino-libs archive
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: esp32-arduino-libs-${{ env.libs_branch }}
118+
path: dist/esp32-arduino-libs.tar.gz
119+
120+
- name: Upload package_esp32_index.template.json
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: package-esp32-index-json-${{ env.libs_branch }}
124+
path: dist/package_esp32_index.template.json
125+
126+
- name: Push changes
127+
if: github.repository == 'espressif/esp32-arduino-lib-builder'
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
130+
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
131+
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
132+
run: |
133+
bash ./tools/push-to-arduino.sh

Diff for: tools/combine-artifacts.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -e
4+
mkdir -p out
5+
6+
libs_folder="out/tools/esp32-arduino-libs"
7+
8+
files=$(find dist -name 'arduino-esp32-libs-esp*.tar.gz')
9+
for file in $files; do
10+
echo "Extracting $file"
11+
tar zxvf $file -C out
12+
cat $libs_folder/versions.txt >> $libs_folder/versions_full.txt
13+
done
14+
15+
# Merge versions.txt files
16+
awk -i inplace '!seen[$0]++' $libs_folder/versions_full.txt
17+
mv -f $libs_folder/versions_full.txt $libs_folder/versions.txt
18+
19+
cd $libs_folder && tar zcf ../../../dist/esp32-arduino-libs.tar.gz * && cd ../../..
20+
cp out/package_esp32_index.template.json dist/package_esp32_index.template.json

Diff for: tools/cron.sh

-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/bin/bash
22

3-
if [ ! "$GITHUB_EVENT_NAME" == "schedule" ]; then
4-
echo "Wrong event '$GITHUB_EVENT_NAME'!"
5-
exit 1
6-
fi
7-
83
if [ -z "$TARGET" ]; then
94
TARGET="all"
105
fi

0 commit comments

Comments
 (0)