55
66name : Package and upload tool
77
8- # Trigger on any push or pull request that modifies files in the tools/
9- # directory or the packaging script, or on any tag that starts with tool/.
8+ # Trigger on any pull request that modifies files in the tools/ directory or
9+ # the packaging script, or on any tag that starts with tools/ and has the
10+ # format tools/<tool>/<version>, e.g. tools/gen-rodata-ld/0.1.0.
1011#
1112# For tag pushes, only build the specific tool and version indicated by the
12- # tag, and only publish if the repository is the main one
13- # (arduino/ArduinoCore-zephyr).
13+ # tag, and only publish if the repository is the official Arduino one.
1414
1515on :
1616 push :
17- branches :
18- - ' **'
1917 tags :
20- - ' tool/**'
21- paths :
2218 - ' tools/**'
23- - ' extra/package_tool.sh'
2419 pull_request :
2520 paths :
2621 - ' tools/**'
@@ -32,6 +27,12 @@ concurrency:
3227
3328jobs :
3429
30+ # Set up the build matrix based on the event type. For tag pushes, the matrix
31+ # will contain only the tool and version specified by the tag. For pull
32+ # requests, the matrix will include all tools with the version set to the
33+ # commit SHA. Also determine if this is a release build on the main
34+ # repository, and if so, set the tool artifact name for later use.
35+
3536 setup :
3637 name : Set up build matrix
3738 runs-on : ubuntu-latest
4950 - name : Set build matrix
5051 id : set-matrix
5152 run : |
52- if [[ "$GITHUB_REF" == refs/tags/tool /* ]]; then
53+ if [[ "$GITHUB_REF" == refs/tags/tools /* ]]; then
5354 # single tool, release build on main repo
54- TAG="${GITHUB_REF#refs/tags/tool /}"
55+ TAG="${GITHUB_REF#refs/tags/tools /}"
5556 TOOL="${TAG%%/*}"
5657 VERSION="${TAG#*/}"
5758 MATRIX=$(jq -cn --arg tool "$TOOL" --arg version "$VERSION" \
6869 fi
6970 echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
7071
72+ # Build and package the tools in parallel according to the matrix, uploading
73+ # the resulting packages and metadata as artifacts for later use.
74+
7175 build-tool :
7276 name : Build ${{ matrix.tool }} ${{ matrix.version }}
7377 needs : setup
@@ -86,10 +90,10 @@ jobs:
8690 go-version : stable
8791 cache : false
8892
89- - name : Build and package ${{ matrix. tool }}
93+ - name : Build and package tool
9094 run : extra/package_tool.sh tools/${{ matrix.tool }} ${{ matrix.version }}
9195
92- - name : Upload ${{ matrix. tool }} ${{ matrix.version }}
96+ - name : Upload tool artifact
9397 uses : actions/upload-artifact@v7
9498 with :
9599 name : ${{ matrix.tool }}-${{ matrix.version }}
@@ -98,23 +102,13 @@ jobs:
98102 distrib/*.zip
99103 retention-days : 7
100104
101- - name : Upload JSON ${{ matrix.tool }} ${{ matrix.version }}
105+ - name : Upload JSON artifact
102106 uses : actions/upload-artifact@v7
103107 with :
104108 name : ${{ matrix.tool }}-${{ matrix.version }}.json
105109 path : distrib/*.json
106110 archive : false
107111 retention-days : 7
108- if-no-files-found : ignore
109-
110- verify-tool :
111- runs-on : ubuntu-latest
112- if : always()
113- needs : build-tool
114- steps :
115- - name : Check build result
116- run : |
117- [ "${{ needs.build-tool.result }}" == "success" ]
118112
119113 # Upload the built tool packages to the S3 bucket for public distribution.
120114
@@ -142,10 +136,24 @@ jobs:
142136 role-to-assume : ${{ secrets.IAM_ROLE }}
143137 aws-region : ${{ secrets.AWS_REGION }}
144138
145- - name : Upload tools to S3
139+ - name : Upload tool files to S3
146140 run : |
147141 for f in *.tar.gz *.zip ; do
148142 [ -f "$f" ] || continue
149143 aws s3 cp "$f" s3://${{ secrets.S3_TOOLS_BUCKET }}/
150144 done
151145
146+ # The final verification step always runs to properly get the overall job status.
147+
148+ verify-tool :
149+ runs-on : ubuntu-latest
150+ if : always()
151+ needs :
152+ - build-tool
153+ - publish-tool
154+ steps :
155+ - name : Check build result
156+ run : |
157+ # A failure here means either the build or publish step failed when it was expected to run.
158+ [ ${{ needs.build-tool.result }} == "success" ] && \
159+ ( [ ${{ needs.publish-tool.result }} == "success" ] || [ ${{ needs.publish-tool.result }} == "skipped" ] )
0 commit comments