Skip to content

Commit 33b0dad

Browse files
committed
ci: upload build snippets to ci-builds
Add logic to upload the generated snippets to ci-builds, so that they can be used to populate the boards manager index and tool index in the Arduino IDE.
1 parent 837c45a commit 33b0dad

2 files changed

Lines changed: 108 additions & 0 deletions

File tree

.github/workflows/package_core.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,14 @@ jobs:
469469
# errors due to race conditions with parallel branch runs should not fail the job
470470
extra/ci_calc_size_reports.py ${GITHUB_BASE_SHA} sketches-reports/ || true
471471
472+
# upload build metadata artifact, for upload to ci-builds
473+
- name: Archive build metadata information
474+
uses: actions/upload-artifact@v7
475+
with:
476+
name: build-metadata
477+
path: ${{ env.CORE_VER }}.json
478+
retention-days: 1
479+
472480
# upload comment request artifact (will be retrieved by leave_pr_comment.yml)
473481
- name: Archive comment information
474482
uses: actions/upload-artifact@v7
@@ -619,3 +627,56 @@ jobs:
619627
with:
620628
name: ArduinoCore-zephyr-${{ env.CORE_TAG }}-jsons
621629
path: ArduinoCore-*-${{ env.CORE_TAG }}.json
630+
631+
ci-builds-upload:
632+
runs-on: ubuntu-latest
633+
needs:
634+
- build-env
635+
- verify-core
636+
- prepare-json
637+
permissions:
638+
id-token: write # required to obtain the OIDC token
639+
env:
640+
CORE_TAG: ${{ needs.build-env.outputs.CORE_TAG }}
641+
CORE_VER: ${{ needs.build-env.outputs.CORE_VER }}
642+
steps:
643+
- uses: actions/download-artifact@v8
644+
with:
645+
path: platforms/
646+
name: ArduinoCore-zephyr-${{ env.CORE_TAG }}-jsons
647+
648+
- uses: actions/download-artifact@v8
649+
with:
650+
path: metadata/
651+
name: build-metadata
652+
653+
- run: |
654+
echo "SNIPPETS<<EOF" >> $GITHUB_ENV
655+
jq -cn 'reduce inputs as $i ({}; .[input_filename] = $i)' platforms/*.json metadata/*.json >> $GITHUB_ENV
656+
echo "EOF" >> $GITHUB_ENV
657+
658+
- name: Get OIDC identity token
659+
id: oidc
660+
uses: actions/github-script@v9
661+
with:
662+
script: |
663+
const token = await core.getIDToken('arduino/ci-builds');
664+
core.setOutput('token', token)
665+
666+
- name: Store snippets in ci-builds
667+
uses: actions/github-script@v9
668+
with:
669+
github-token: ${{ secrets.CI_BUILDS_TOKEN }}
670+
script: |
671+
await github.rest.actions.createWorkflowDispatch({
672+
owner: 'pillo79',
673+
repo: 'ci-builds',
674+
workflow_id: 'store-snippets.yml',
675+
ref: 'main',
676+
inputs: {
677+
oidc_token: '${{ steps.oidc.outputs.token }}',
678+
base_branch: '${{ needs.build-env.outputs.CORE_BRANCH }}',
679+
version: '${{ env.CORE_VER }}',
680+
snippets: '${{ env.SNIPPETS }}',
681+
},
682+
});

.github/workflows/package_tool.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,50 @@ jobs:
167167
# A failure here means either the build or publish step failed when it was expected to run.
168168
[ ${{ needs.build-tool.result }} == "success" ] && \
169169
( [ ${{ needs.publish-tool.result }} == "success" ] || [ ${{ needs.publish-tool.result }} == "skipped" ] )
170+
171+
ci-builds-upload:
172+
runs-on: ubuntu-latest
173+
needs:
174+
- setup
175+
- build-tool
176+
- publish-tool
177+
- verify-tool
178+
permissions:
179+
id-token: write # required to obtain the OIDC token
180+
steps:
181+
- uses: actions/download-artifact@v8
182+
with:
183+
path: tools/
184+
pattern: '*.json'
185+
merge-multiple: true
186+
187+
- run: |
188+
echo "SNIPPETS<<EOF" >> $GITHUB_ENV
189+
jq -cn 'reduce inputs as $i ({}; .[input_filename] = $i)' tools/*.json >> $GITHUB_ENV
190+
echo "EOF" >> $GITHUB_ENV
191+
192+
- name: Get OIDC identity token
193+
id: oidc
194+
uses: actions/github-script@v9
195+
with:
196+
script: |
197+
const token = await core.getIDToken('arduino/ci-builds');
198+
core.setOutput('token', token)
199+
200+
- name: Store snippets in ci-builds
201+
uses: actions/github-script@v9
202+
with:
203+
github-token: ${{ secrets.CI_BUILDS_TOKEN }}
204+
script: |
205+
await github.rest.actions.createWorkflowDispatch({
206+
owner: 'pillo79',
207+
repo: 'ci-builds',
208+
workflow_id: 'store-snippets.yml',
209+
ref: 'main',
210+
inputs: {
211+
oidc_token: '${{ steps.oidc.outputs.token }}',
212+
base_branch: '${{ needs.setup.outputs.CORE_BRANCH }}',
213+
version: '${{ needs.setup.outputs.CORE_VER }}',
214+
snippets: '${{ env.SNIPPETS }}',
215+
},
216+
});

0 commit comments

Comments
 (0)