ci: upload aml zips from build job and download+reupload per-platform… #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and upload AML artifacts | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Configure, build and prepare artifacts | |
| runs-on: ubuntu-latest | |
| outputs: | |
| platforms: ${{ steps.prepare.outputs.platforms }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential cmake ninja-build zip python3 python3-pip jq | |
| - name: Configure CMake | |
| run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release | |
| - name: Build | |
| run: cmake --build build -- -j$(nproc) | |
| - name: Collect AMLs and create per-platform zips | |
| id: prepare | |
| run: | | |
| set -euo pipefail | |
| mkdir -p artifacts | |
| platforms=() | |
| for dir in build/*/builtin; do | |
| if [ -d "$dir" ]; then | |
| shopt -s nullglob | |
| aml_files=("$dir"/*.aml) | |
| if [ ${#aml_files[@]} -gt 0 ]; then | |
| platform=$(basename "$(dirname "$dir")") | |
| echo "Packaging $platform..." | |
| zip -j "artifacts/${platform}.zip" "$dir"/*.aml || true | |
| platforms+=("$platform") | |
| fi | |
| shopt -u nullglob | |
| fi | |
| done | |
| # Convert platforms array to JSON using jq | |
| if [ ${#platforms[@]} -gt 0 ]; then | |
| PLATFORMS_JSON=$(printf '%s\n' "${platforms[@]}" | jq -R -s -c 'split("\n")[:-1]') | |
| else | |
| PLATFORMS_JSON='[]' | |
| fi | |
| echo "Found platforms: $PLATFORMS_JSON" | |
| echo "platforms=$PLATFORMS_JSON" >> $GITHUB_OUTPUT | |
| - name: Upload all platform zips as a single artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: aml-zips | |
| path: artifacts/*.zip | |
| upload: | |
| name: Upload platform artifacts | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: ${{ fromJson(needs.build.outputs.platforms) }} | |
| steps: | |
| - name: Download zips artifact from build job | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: aml-zips | |
| path: downloaded_artifacts | |
| - name: Ensure platform zip exists | |
| run: | | |
| ls -al downloaded_artifacts || true | |
| if [ ! -f "downloaded_artifacts/${{ matrix.platform }}.zip" ]; then | |
| echo "Platform zip not found: downloaded_artifacts/${{ matrix.platform }}.zip" | |
| false | |
| fi | |
| - name: Upload artifact for platform | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform }} | |
| path: downloaded_artifacts/${{ matrix.platform }}.zip |