|  | 
| 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 | #             * * * * * | 
| 14 | 14 |     - cron:  '0 */6 * * *' | 
|  | 15 | +  workflow_dispatch: | 
|  | 16 | +    inputs: | 
|  | 17 | +      idf_branch: | 
|  | 18 | +        # This input can be an escaped JSON list of strings e.g. [\"release/v5.1\"] 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 an escaped JSON 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' | 
| 15 | 29 | 
 | 
| 16 | 30 | defaults: | 
| 17 | 31 |   run: | 
| 18 | 32 |     shell: bash | 
| 19 | 33 | 
 | 
| 20 | 34 | jobs: | 
| 21 |  | -  run: | 
| 22 |  | -    name: Build with IDF ${{ matrix.idf_branch }} | 
|  | 35 | +  gen-matrix: | 
|  | 36 | +    name: Generate matrix | 
| 23 | 37 |     runs-on: ubuntu-latest | 
| 24 |  | -     | 
|  | 38 | +    outputs: | 
|  | 39 | +      matrix: ${{ steps.gen-matrix.outputs.matrix }} | 
|  | 40 | +      branches: ${{ steps.gen-matrix.outputs.branches }} | 
|  | 41 | +    steps: | 
|  | 42 | +      - name: Generate matrix | 
|  | 43 | +        id: gen-matrix | 
|  | 44 | +        run: | | 
|  | 45 | +          # Change this based on the IDF branches we want to build | 
|  | 46 | +          all_branches="[\"release/v5.1\"]" | 
|  | 47 | +
 | 
|  | 48 | +          # Change this based on the COMMON targets for all branches we want to build. | 
|  | 49 | +          common_targets="[\"esp32\", \"esp32s2\", \"esp32s3\", \"esp32c2\", \"esp32c3\", \"esp32c6\", \"esp32h2\"]" | 
|  | 50 | +
 | 
|  | 51 | +          # For additional targets per branch, add them here | 
|  | 52 | +          additional_targets="[{\"idf_branch\": \"release/v5.3\", \"target\": \"esp32p4\"}]" | 
|  | 53 | +
 | 
|  | 54 | +          branches="${{ github.event.inputs.idf_branch }}" | 
|  | 55 | +          targets="${{ github.event.inputs.target }}" | 
|  | 56 | +
 | 
|  | 57 | +          if [ -z "$branches" ] || [ "$branches" == "all" ]; then | 
|  | 58 | +            branches=$all_branches | 
|  | 59 | +          fi | 
|  | 60 | +
 | 
|  | 61 | +          if [ -z "$targets" ]; then | 
|  | 62 | +            targets="all" | 
|  | 63 | +          fi | 
|  | 64 | +
 | 
|  | 65 | +          echo "Inputs:" | 
|  | 66 | +          echo "idf_branch: ${{ github.event.inputs.idf_branch }}" | 
|  | 67 | +          echo "target: ${{ github.event.inputs.target }}" | 
|  | 68 | +
 | 
|  | 69 | +          matrix="{" | 
|  | 70 | +          matrix+="\"idf_branch\": $branches," | 
|  | 71 | +
 | 
|  | 72 | +          if [ "$targets" == "all" ]; then | 
|  | 73 | +            matrix+="\"target\": $common_targets," | 
|  | 74 | +            matrix+="\"include\": " | 
|  | 75 | +            # Add all additional targets that are in the selected branches | 
|  | 76 | +            matrix+=$(echo $additional_targets | jq --argjson branches "$branches" '[.[] | select(.idf_branch as $branch | $branches | index($branch))]') | 
|  | 77 | +          else | 
|  | 78 | +            matrix+="\"target\": $targets" | 
|  | 79 | +          fi | 
|  | 80 | +
 | 
|  | 81 | +          matrix+="}" | 
|  | 82 | +
 | 
|  | 83 | +          echo "Branches: $branches" | 
|  | 84 | +          echo "Targets: $targets" | 
|  | 85 | +          echo "Matrix:" | 
|  | 86 | +          echo "$matrix" | jq . | 
|  | 87 | +          echo "matrix=$matrix" >> $GITHUB_OUTPUT | 
|  | 88 | +          echo "branches=$branches" >> $GITHUB_OUTPUT | 
|  | 89 | +
 | 
|  | 90 | +  build-libs: | 
|  | 91 | +    name: Build with IDF ${{ matrix.idf_branch }} for ${{ matrix.target }} | 
|  | 92 | +    runs-on: ubuntu-latest | 
|  | 93 | +    needs: gen-matrix | 
| 25 | 94 |     strategy: | 
| 26 | 95 |       fail-fast: false | 
| 27 |  | -      matrix: | 
| 28 |  | -        idf_branch: [release/v5.1, release/v4.4] #, release/v3.3] | 
|  | 96 | +      matrix: ${{ fromJson(needs.gen-matrix.outputs.matrix) }} | 
| 29 | 97 |     steps: | 
| 30 | 98 |     - uses: actions/checkout@v4 | 
| 31 | 99 |       with: | 
| 32 | 100 |         fetch-depth: 0 | 
|  | 101 | + | 
|  | 102 | +    - name: Check if result should be deployed | 
|  | 103 | +      id: check | 
|  | 104 | +      env: | 
|  | 105 | +        GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }} | 
|  | 106 | +        IDF_BRANCH: ${{ matrix.idf_branch }} | 
|  | 107 | +      run: | | 
|  | 108 | +        git checkout ${{ env.IDF_BRANCH }} || echo "Using master branch" | 
|  | 109 | +        bash ./tools/check-deploy-needed.sh | 
|  | 110 | +
 | 
| 33 | 111 |     - name: Install dependencies | 
|  | 112 | +      if: env.libs_has_commit == '0' || env.ar_has_commit == '0' | 
| 34 | 113 |       run: bash ./tools/prepare-ci.sh | 
|  | 114 | + | 
| 35 | 115 |     - name: Build | 
| 36 | 116 |       env: | 
| 37 |  | -        GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} | 
|  | 117 | +        GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }} | 
| 38 | 118 |         GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }} | 
| 39 | 119 |         GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }} | 
| 40 | 120 |         IDF_BRANCH: ${{ matrix.idf_branch }} | 
|  | 121 | +        TARGETS: ${{ matrix.target }} | 
|  | 122 | +      if: env.libs_has_commit == '0' || env.ar_has_commit == '0' | 
| 41 | 123 |       run: | | 
| 42 |  | -        git checkout ${{ matrix.idf_branch }} || echo "Using master branch" | 
| 43 | 124 |         bash ./tools/cron.sh | 
|  | 125 | +
 | 
| 44 | 126 |     - name: Upload build | 
| 45 |  | -      if: failure() | 
|  | 127 | +      if: failure() && (env.libs_has_commit == '0' || env.ar_has_commit == '0') | 
| 46 | 128 |       uses: actions/upload-artifact@v4 | 
| 47 | 129 |       with: | 
| 48 |  | -        name: build | 
|  | 130 | +        name: build-${{ env.libs_version }}-${{ matrix.target }} | 
| 49 | 131 |         path: build | 
| 50 |  | -    - name: Upload archive | 
|  | 132 | + | 
|  | 133 | +    - name: Upload library files | 
|  | 134 | +      if: env.libs_has_commit == '0' || env.ar_has_commit == '0' | 
| 51 | 135 |       uses: actions/upload-artifact@v4 | 
| 52 | 136 |       with: | 
| 53 |  | -        name: artifacts | 
|  | 137 | +        name: libs-${{ env.libs_version }}-${{ matrix.target }} | 
| 54 | 138 |         path: dist | 
| 55 | 139 | 
 | 
|  | 140 | +  combine-artifacts: | 
|  | 141 | +    name: Combine artifacts for IDF ${{ matrix.idf_branch }} | 
|  | 142 | +    runs-on: ubuntu-latest | 
|  | 143 | +    needs: [gen-matrix, build-libs] | 
|  | 144 | +    strategy: | 
|  | 145 | +      fail-fast: false | 
|  | 146 | +      matrix: | 
|  | 147 | +        idf_branch: ${{ fromJson(needs.gen-matrix.outputs.branches) }} | 
|  | 148 | +    steps: | 
|  | 149 | +      - uses: actions/checkout@v4 | 
|  | 150 | +        with: | 
|  | 151 | +          fetch-depth: 0 | 
|  | 152 | + | 
|  | 153 | +      - name: Check if result should be deployed | 
|  | 154 | +        id: check | 
|  | 155 | +        env: | 
|  | 156 | +          GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN || secrets.GITHUB_TOKEN }} | 
|  | 157 | +          IDF_BRANCH: ${{ matrix.idf_branch }} | 
|  | 158 | +        run: | | 
|  | 159 | +          git checkout ${{ env.IDF_BRANCH }} || echo "Using master branch" | 
|  | 160 | +          bash ./tools/check-deploy-needed.sh | 
|  | 161 | +
 | 
|  | 162 | +      - name: Download artifacts | 
|  | 163 | +        if: env.libs_has_commit == '0' || env.ar_has_commit == '0' | 
|  | 164 | +        uses: actions/download-artifact@v4 | 
|  | 165 | +        with: | 
|  | 166 | +          path: dist | 
|  | 167 | +          pattern: libs-${{ env.libs_version }}-* | 
|  | 168 | +          merge-multiple: true | 
|  | 169 | + | 
|  | 170 | +      - name: Combine artifacts | 
|  | 171 | +        if: env.libs_has_commit == '0' || env.ar_has_commit == '0' | 
|  | 172 | +        run: | | 
|  | 173 | +          bash ./tools/cron-combine.sh | 
|  | 174 | +
 | 
|  | 175 | +      - name: Upload full esp32-arduino-libs archive | 
|  | 176 | +        if: env.libs_has_commit == '0' || env.ar_has_commit == '0' | 
|  | 177 | +        uses: actions/upload-artifact@v4 | 
|  | 178 | +        with: | 
|  | 179 | +          name: esp32-arduino-libs | 
|  | 180 | +          path: dist/esp32-arduino-libs.tar.gz | 
| 56 | 181 | 
 | 
| 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" | 
|  | 182 | +      - name: Upload package_esp32_index.template.json | 
|  | 183 | +        if: env.libs_has_commit == '0' || env.ar_has_commit == '0' | 
|  | 184 | +        uses: actions/upload-artifact@v4 | 
|  | 185 | +        with: | 
|  | 186 | +          name: package-esp32-index-json | 
|  | 187 | +          path: dist/package_esp32_index.template.json | 
| 144 | 188 | 
 | 
|  | 189 | +      - name: Push changes | 
|  | 190 | +        if: github.repository == 'espressif/esp32-arduino-lib-builder' && (env.libs_has_commit == '0' || env.ar_has_commit == '0') | 
|  | 191 | +        env: | 
|  | 192 | +          GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} | 
|  | 193 | +          GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }} | 
|  | 194 | +          GIT_COMMITTER_EMAIL: ${{ secrets.PUSH_EMAIL }} | 
|  | 195 | +          IDF_BRANCH: ${{ matrix.idf_branch }} | 
|  | 196 | +        run: | | 
|  | 197 | +          bash ./tools/push-to-arduino.sh | 
0 commit comments