|
12 | 12 | description: "IDF Targets"
|
13 | 13 | default: "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4"
|
14 | 14 | type: "string"
|
15 | | - required: true |
| 15 | + required: false |
16 | 16 | push:
|
17 | 17 | branches:
|
18 | 18 | - master
|
@@ -66,49 +66,88 @@ jobs:
|
66 | 66 | runs-on: ubuntu-latest
|
67 | 67 | if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'release/')) }}
|
68 | 68 | outputs:
|
69 | | - idf_ver: ${{ steps.set-matrix.outputs.idf_ver }} |
70 | | - idf_target: ${{ steps.set-matrix.outputs.idf_target }} |
| 69 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
71 | 70 | steps:
|
72 | | - - name: Get IDF Version and Targets |
| 71 | + - name: Get Matrix Combinations |
73 | 72 | id: set-matrix
|
74 | 73 | run: |
|
75 | | - # Default values |
76 | | - idf_ver="release-v5.3,release-v5.4,release-v5.5" |
77 | | - idf_targets="esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4" |
| 74 | + # Define version-specific target configurations |
| 75 | + get_targets_for_version() { |
| 76 | + case "1ドル" in |
| 77 | + "release-v5.3") |
| 78 | + echo "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4" |
| 79 | + ;; |
| 80 | + "release-v5.4") |
| 81 | + echo "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c6,esp32h2,esp32p4" |
| 82 | + ;; |
| 83 | + "release-v5.5") |
| 84 | + echo "esp32,esp32s2,esp32s3,esp32c2,esp32c3,esp32c5,esp32c6,esp32h2,esp32p4" |
| 85 | + ;; |
| 86 | + *) |
| 87 | + echo "" |
| 88 | + ;; |
| 89 | + esac |
| 90 | + } |
| 91 | + |
| 92 | + # Default versions if not provided via inputs |
| 93 | + DEFAULT_VERSIONS="release-v5.3,release-v5.4,release-v5.5" |
78 | 94 |
|
79 | | - # Override with inputs if provided |
| 95 | + # Use inputs if provided, otherwise use defaults |
80 | 96 | if [[ -n "${{ inputs.idf_ver }}" ]]; then
|
81 | | - idf_ver="${{ inputs.idf_ver }}" |
82 | | - fi |
83 | | - if [[ -n "${{ inputs.idf_targets }}" ]]; then |
84 | | - idf_targets="${{ inputs.idf_targets }}" |
| 97 | + VERSIONS="${{ inputs.idf_ver }}" |
| 98 | + else |
| 99 | + VERSIONS="$DEFAULT_VERSIONS" |
85 | 100 | fi
|
86 | 101 |
|
87 | | - # Convert comma-separated strings to JSON arrays using a more robust method |
88 | | - idf_ver_json=$(printf '%s\n' "$idf_ver" | tr ',' '\n' | jq -R . | jq -s . | jq -c .) |
89 | | - idf_targets_json=$(printf '%s\n' "$idf_targets" | tr ',' '\n' | jq -R . | jq -s . | jq -c .) |
| 102 | + # Generate matrix combinations |
| 103 | + echo '{"include": [' > matrix.json |
| 104 | + first=true |
| 105 | + IFS=',' read -ra VERSION_ARRAY <<< "$VERSIONS" |
| 106 | + |
| 107 | + for version in "${VERSION_ARRAY[@]}"; do |
| 108 | + # Trim whitespace |
| 109 | + version=$(echo "$version" | xargs) |
| 110 | + |
| 111 | + # Get targets for this version |
| 112 | + if [[ -n "${{ inputs.idf_targets }}" ]]; then |
| 113 | + # Use provided targets for all versions |
| 114 | + targets="${{ inputs.idf_targets }}" |
| 115 | + else |
| 116 | + # Use version-specific targets |
| 117 | + targets=$(get_targets_for_version "$version") |
| 118 | + fi |
| 119 | + |
| 120 | + if [[ -n "$targets" ]]; then |
| 121 | + IFS=',' read -ra TARGET_ARRAY <<< "$targets" |
| 122 | + for target in "${TARGET_ARRAY[@]}"; do |
| 123 | + # Trim whitespace |
| 124 | + target=$(echo "$target" | xargs) |
| 125 | + |
| 126 | + if [ "$first" = true ]; then |
| 127 | + first=false |
| 128 | + else |
| 129 | + echo ',' >> matrix.json |
| 130 | + fi |
| 131 | + echo "{\"idf_ver\": \"$version\", \"idf_target\": \"$target\"}" >> matrix.json |
| 132 | + done |
| 133 | + fi |
| 134 | + done |
| 135 | + echo ']}' >> matrix.json |
90 | 136 |
|
91 | | - # Debug: Print the JSON for verification |
92 | | - echo "Debug - idf_ver_json: $idf_ver_json" |
93 | | - echo "Debug - idf_targets_json: $idf_targets_json" |
| 137 | + # Debug: Print the matrix for verification |
| 138 | + echo "Debug - Generated matrix:" |
| 139 | + cat matrix.json | jq . |
94 | 140 |
|
95 | | - # Set outputs - ensure no extra whitespace |
96 | | - printf "idf_ver=%s\n" "$idf_ver_json" >> $GITHUB_OUTPUT |
97 | | - printf "idf_target=%s\n" "$idf_targets_json" >> $GITHUB_OUTPUT |
| 141 | + # Set output |
| 142 | + printf "matrix=%s\n" "$(cat matrix.json | jq -c .)" >> $GITHUB_OUTPUT |
98 | 143 |
|
99 | 144 | build-esp-idf-component:
|
100 | 145 | name: Build IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
|
101 | 146 | runs-on: ubuntu-latest
|
102 | 147 | needs: set-matrix
|
103 | 148 | strategy:
|
104 | 149 | fail-fast: false
|
105 | | - matrix: |
106 | | - # The version names here correspond to the versions of espressif/idf Docker image. |
107 | | - # See https://hub.docker.com/r/espressif/idf/tags and |
108 | | - # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html |
109 | | - # for details. |
110 | | - idf_ver: ${{ fromJson(needs.set-matrix.outputs.idf_ver) }} |
111 | | - idf_target: ${{ fromJson(needs.set-matrix.outputs.idf_target) }} |
| 150 | + matrix: ${{ fromJson(needs.set-matrix.outputs.matrix) }} |
112 | 151 | container: espressif/idf:${{ matrix.idf_ver }}
|
113 | 152 | steps:
|
114 | 153 | - name: Check out arduino-esp32 as a component
|
|
0 commit comments