|
| 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.libs_has_asset == '0' |
| 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: | |
| 107 | + always() && |
| 108 | + needs.check-if-needed.result == 'success' && |
| 109 | + needs.check-if-needed.outputs.deploy_needed == '1' |
| 110 | + steps: |
| 111 | + - uses: actions/checkout@v4 |
| 112 | + with: |
| 113 | + ref: ${{ inputs.lib_builder_branch }} |
| 114 | + |
| 115 | + - name: Replace invalid characters in the artifact name |
| 116 | + if: needs.check-if-needed.outputs.libs_has_asset == '0' |
| 117 | + run: | |
| 118 | + branch=${{ inputs.idf_branch }} |
| 119 | + echo "libs_branch=${branch//\//_}" >> $GITHUB_ENV |
| 120 | +
|
| 121 | + - name: Download artifacts |
| 122 | + if: needs.check-if-needed.outputs.libs_has_asset == '0' |
| 123 | + uses: actions/download-artifact@v4 |
| 124 | + with: |
| 125 | + path: dist |
| 126 | + pattern: libs-${{ env.libs_branch }}-* |
| 127 | + merge-multiple: true |
| 128 | + |
| 129 | + - name: Combine artifacts |
| 130 | + if: needs.check-if-needed.outputs.libs_has_asset == '0' |
| 131 | + run: bash ./tools/combine-artifacts.sh |
| 132 | + |
| 133 | + - name: Upload full esp32-arduino-libs archive |
| 134 | + if: needs.check-if-needed.outputs.libs_has_asset == '0' |
| 135 | + uses: actions/upload-artifact@v4 |
| 136 | + with: |
| 137 | + name: esp32-arduino-libs-${{ env.libs_branch }} |
| 138 | + path: dist/esp32-arduino-libs.zip |
| 139 | + compression-level: 0 |
| 140 | + |
| 141 | + - name: Push changes |
| 142 | + if: github.repository == 'espressif/esp32-arduino-lib-builder' |
| 143 | + env: |
| 144 | + GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} |
| 145 | + GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }} |
| 146 | + GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }} |
| 147 | + IDF_COMMIT: ${{ needs.check-if-needed.outputs.idf_commit }} |
| 148 | + AR_BRANCH: ${{ needs.check-if-needed.outputs.ar_branch }} |
| 149 | + AR_NEW_COMMIT_MESSAGE: ${{ needs.check-if-needed.outputs.ar_new_commit_message }} |
| 150 | + AR_NEW_BRANCH_NAME: ${{ needs.check-if-needed.outputs.ar_new_branch_name }} |
| 151 | + AR_NEW_PR_TITLE: ${{ needs.check-if-needed.outputs.ar_new_pr_title }} |
| 152 | + AR_HAS_COMMIT: ${{ needs.check-if-needed.outputs.ar_has_commit }} |
| 153 | + AR_HAS_BRANCH: ${{ needs.check-if-needed.outputs.ar_has_branch }} |
| 154 | + AR_HAS_PR: ${{ needs.check-if-needed.outputs.ar_has_pr }} |
| 155 | + LIBS_RELEASE_TAG: ${{ needs.check-if-needed.outputs.libs_release_tag }} |
| 156 | + LIBS_VERSION: ${{ needs.check-if-needed.outputs.libs_version }} |
| 157 | + LIBS_RELEASE_ID: ${{ needs.check-if-needed.outputs.libs_release_id }} |
| 158 | + LIBS_HAS_RELEASE: ${{ needs.check-if-needed.outputs.libs_has_release }} |
| 159 | + LIBS_ASSET_ID: ${{ needs.check-if-needed.outputs.libs_asset_id }} |
| 160 | + LIBS_HAS_ASSET: ${{ needs.check-if-needed.outputs.libs_has_asset }} |
| 161 | + run: | |
| 162 | + bash ./tools/push-to-arduino.sh |
| 163 | +
|
| 164 | + - name: Upload package_esp32_index.template.json |
| 165 | + uses: actions/upload-artifact@v4 |
| 166 | + with: |
| 167 | + name: package-esp32-index-json-${{ env.libs_branch }} |
| 168 | + path: out/package_esp32_index.template.json |
0 commit comments