Skip to content

Commit 65e6fb1

Browse files
Split cron jobs and move libs to releases (#187)
* Split cron jobs using matrix * Move to workflow call * Use github releases for libs * Enable ccache by default * Fix push --------- Co-authored-by: Me No Dev <[email protected]>
1 parent 2a45ca0 commit 65e6fb1

10 files changed

+379
-281
lines changed

Diff for: .github/workflows/cron.yml

+15-123
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,36 @@
1-
name: Cron Build
1+
name: Cron Deploy
22

3-
on:
3+
on:
44
schedule:
55
# ┌───────────── minute (0 - 59)
66
# │ ┌───────────── hour (0 - 23)
77
# │ │ ┌───────────── day of the month (1 - 31)
88
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
99
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
10-
# │ │ │ │ │
10+
# │ │ │ │ │
1111
# │ │ │ │ │
1212
# │ │ │ │ │
1313
# * * * * *
1414
- cron: '0 */6 * * *'
15+
workflow_dispatch: # For testing
1516

1617
defaults:
1718
run:
1819
shell: bash
1920

2021
jobs:
21-
run:
22+
build-libs:
2223
name: Build with IDF ${{ matrix.idf_branch }}
23-
runs-on: ubuntu-latest
24-
24+
uses: ./.github/workflows/cron_build.yml
25+
with:
26+
idf_branch: ${{ matrix.idf_branch }}
27+
lib_builder_branch: ${{ matrix.lib_builder_branch }}
28+
targets: ${{ matrix.targets }}
29+
secrets: inherit
2530
strategy:
2631
fail-fast: false
2732
matrix:
28-
idf_branch: [release/v5.1, release/v4.4] #, release/v3.3]
29-
steps:
30-
- uses: actions/checkout@v4
31-
with:
32-
fetch-depth: 0
33-
- name: Install dependencies
34-
run: bash ./tools/prepare-ci.sh
35-
- name: Build
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
38-
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
39-
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
40-
IDF_BRANCH: ${{ matrix.idf_branch }}
41-
run: |
42-
git checkout ${{ matrix.idf_branch }} || echo "Using master branch"
43-
bash ./tools/cron.sh
44-
- name: Upload build
45-
if: failure()
46-
uses: actions/upload-artifact@v4
47-
with:
48-
name: build
49-
path: build
50-
- name: Upload archive
51-
uses: actions/upload-artifact@v4
52-
with:
53-
name: artifacts
54-
path: dist
55-
56-
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"
144-
33+
include:
34+
- idf_branch: "release/v5.1"
35+
lib_builder_branch: "master"
36+
targets: "esp32,esp32s2,esp32s3,esp32c3,esp32c6,esp32h2"

Diff for: .github/workflows/cron_build.yml

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
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+
idf_commit: ${{ steps.check.outputs.idf_commit }}
28+
ar_branch: ${{ steps.check.outputs.ar_branch }}
29+
ar_new_commit_message: ${{ steps.check.outputs.ar_new_commit_message }}
30+
ar_new_branch_name: ${{ steps.check.outputs.ar_new_branch_name }}
31+
ar_new_pr_title: ${{ steps.check.outputs.ar_new_pr_title }}
32+
ar_has_commit: ${{ steps.check.outputs.ar_has_commit }}
33+
ar_has_branch: ${{ steps.check.outputs.ar_has_branch }}
34+
ar_has_pr: ${{ steps.check.outputs.ar_has_pr }}
35+
libs_release_tag: ${{ steps.check.outputs.libs_release_tag }}
36+
libs_version: ${{ steps.check.outputs.libs_version }}
37+
libs_release_id: ${{ steps.check.outputs.libs_release_id }}
38+
libs_has_release: ${{ steps.check.outputs.libs_has_release }}
39+
libs_asset_id: ${{ steps.check.outputs.libs_asset_id }}
40+
libs_has_asset: ${{ steps.check.outputs.libs_has_asset }}
41+
deploy_needed: ${{ steps.check.outputs.deploy_needed }}
42+
targets_list: ${{ steps.check.outputs.targets_list }}
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
ref: ${{ inputs.lib_builder_branch }}
47+
48+
- name: Check deploy and generate variables
49+
id: check
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
run: |
53+
source ./tools/check-deploy-needed.sh
54+
targets_list=$(echo "${{ inputs.targets }}" | sed 's/ *, */,/g' | sed 's/^/["/' | sed 's/$/"]/' | sed 's/,/","/g')
55+
echo "Targets list: $targets_list"
56+
echo "targets_list=$targets_list" >> $GITHUB_OUTPUT
57+
58+
build-libs:
59+
name: Build for ${{ matrix.target }} (${{ inputs.idf_branch }})
60+
runs-on: ubuntu-latest
61+
if: needs.check-if-needed.outputs.deploy_needed == '1'
62+
needs: check-if-needed
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
target: ${{ fromJson(needs.check-if-needed.outputs.targets_list) }}
67+
steps:
68+
- uses: actions/checkout@v4
69+
with:
70+
ref: ${{ inputs.lib_builder_branch }}
71+
72+
- name: Install dependencies
73+
run: bash ./tools/prepare-ci.sh
74+
75+
- name: Build
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }}
78+
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
79+
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
80+
TARGET: ${{ matrix.target }}
81+
run: |
82+
bash ./tools/cron.sh
83+
84+
- name: Replace invalid characters in the artifact name
85+
run: |
86+
branch=${{ inputs.idf_branch }}
87+
echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
88+
89+
- name: Upload build
90+
if: failure()
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: build-${{ env.libs_branch }}-${{ matrix.target }}
94+
path: build
95+
96+
- name: Upload library files
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: libs-${{ env.libs_branch }}-${{ matrix.target }}
100+
path: dist
101+
102+
combine-artifacts:
103+
name: Combine artifacts and push changes for IDF ${{ inputs.idf_branch }}
104+
runs-on: ubuntu-latest
105+
needs: [check-if-needed, build-libs]
106+
if: needs.check-if-needed.outputs.deploy_needed == '1'
107+
steps:
108+
- uses: actions/checkout@v4
109+
with:
110+
ref: ${{ inputs.lib_builder_branch }}
111+
112+
- name: Replace invalid characters in the artifact name
113+
run: |
114+
branch=${{ inputs.idf_branch }}
115+
echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV
116+
117+
- name: Download artifacts
118+
uses: actions/download-artifact@v4
119+
with:
120+
path: dist
121+
pattern: libs-${{ env.libs_branch }}-*
122+
merge-multiple: true
123+
124+
- name: Combine artifacts
125+
run: bash ./tools/combine-artifacts.sh
126+
127+
- name: Upload full esp32-arduino-libs archive
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: esp32-arduino-libs-${{ env.libs_branch }}
131+
path: dist/esp32-arduino-libs.zip
132+
compression-level: 0
133+
134+
- name: Push changes
135+
if: github.repository == 'espressif/esp32-arduino-lib-builder'
136+
env:
137+
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
138+
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
139+
GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }}
140+
IDF_COMMIT: ${{ needs.check-if-needed.outputs.idf_commit }}
141+
AR_BRANCH: ${{ needs.check-if-needed.outputs.ar_branch }}
142+
AR_NEW_COMMIT_MESSAGE: ${{ needs.check-if-needed.outputs.ar_new_commit_message }}
143+
AR_NEW_BRANCH_NAME: ${{ needs.check-if-needed.outputs.ar_new_branch_name }}
144+
AR_NEW_PR_TITLE: ${{ needs.check-if-needed.outputs.ar_new_pr_title }}
145+
AR_HAS_COMMIT: ${{ needs.check-if-needed.outputs.ar_has_commit }}
146+
AR_HAS_BRANCH: ${{ needs.check-if-needed.outputs.ar_has_branch }}
147+
AR_HAS_PR: ${{ needs.check-if-needed.outputs.ar_has_pr }}
148+
LIBS_RELEASE_TAG: ${{ needs.check-if-needed.outputs.libs_release_tag }}
149+
LIBS_VERSION: ${{ needs.check-if-needed.outputs.libs_version }}
150+
LIBS_RELEASE_ID: ${{ needs.check-if-needed.outputs.libs_release_id }}
151+
LIBS_HAS_RELEASE: ${{ needs.check-if-needed.outputs.libs_has_release }}
152+
LIBS_ASSET_ID: ${{ needs.check-if-needed.outputs.libs_asset_id }}
153+
LIBS_HAS_ASSET: ${{ needs.check-if-needed.outputs.libs_has_asset }}
154+
run: |
155+
bash ./tools/push-to-arduino.sh
156+
157+
- name: Upload package_esp32_index.template.json
158+
uses: actions/upload-artifact@v4
159+
with:
160+
name: package-esp32-index-json-${{ env.libs_branch }}
161+
path: out/package_esp32_index.template.json

0 commit comments

Comments
 (0)