ci: fix double compression issue #5
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 upload per-platform 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 nodejs npm unzip | |
| - name: Configure CMake | |
| run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release | |
| - name: Build | |
| run: cmake --build build -- -j$(nproc) | |
| - name: Collect AMLs into per-platform directories | |
| 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 into directory..." | |
| mkdir -p "artifacts/${platform}" | |
| cp -f "$dir"/*.aml "artifacts/${platform}/" || 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 directories as a single artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: aml-all | |
| path: artifacts | |
| upload: | |
| name: Upload platform artifacts | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: ${{ fromJson(needs.build.outputs.platforms) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download aml-all artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: aml-all | |
| path: ./ | |
| - name: Upload per-platform artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform }} | |
| path: artifacts/${{ matrix.platform }} |