|
6 | 6 | workflow_dispatch: |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - build: |
10 | | - name: Configure, build and prepare artifacts |
11 | | - runs-on: ubuntu-latest |
12 | | - outputs: |
13 | | - platforms: ${{ steps.prepare.outputs.platforms }} |
14 | | - steps: |
15 | | - - name: Checkout repository |
16 | | - uses: actions/checkout@v4 |
| 9 | + build: |
| 10 | + name: Configure, build and upload per-platform artifacts |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + platforms: ${{ steps.prepare.outputs.platforms }} |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
17 | 17 |
|
18 | | - - name: Install build dependencies |
19 | | - run: | |
20 | | - sudo apt-get update |
21 | | - sudo apt-get install -y build-essential cmake ninja-build zip python3 python3-pip jq |
| 18 | + - name: Install build dependencies |
| 19 | + run: | |
| 20 | + sudo apt-get update |
| 21 | + sudo apt-get install -y build-essential cmake ninja-build zip python3 python3-pip jq nodejs npm unzip |
22 | 22 |
|
23 | | - - name: Configure CMake |
24 | | - run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release |
| 23 | + - name: Configure CMake |
| 24 | + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release |
25 | 25 |
|
26 | | - - name: Build |
27 | | - run: cmake --build build -- -j$(nproc) |
| 26 | + - name: Build |
| 27 | + run: cmake --build build -- -j$(nproc) |
28 | 28 |
|
29 | | - - name: Collect AMLs and create per-platform zips |
30 | | - id: prepare |
31 | | - run: | |
32 | | - set -euo pipefail |
33 | | - mkdir -p artifacts |
34 | | - platforms=() |
| 29 | + - name: Collect AMLs into per-platform directories |
| 30 | + id: prepare |
| 31 | + run: | |
| 32 | + set -euo pipefail |
| 33 | + mkdir -p artifacts |
| 34 | + platforms=() |
35 | 35 |
|
36 | | - for dir in build/*/builtin; do |
37 | | - if [ -d "$dir" ]; then |
38 | | - shopt -s nullglob |
39 | | - aml_files=("$dir"/*.aml) |
40 | | - if [ ${#aml_files[@]} -gt 0 ]; then |
41 | | - platform=$(basename "$(dirname "$dir")") |
42 | | - echo "Packaging $platform..." |
43 | | - zip -j "artifacts/${platform}.zip" "$dir"/*.aml || true |
44 | | - platforms+=("$platform") |
| 36 | + for dir in build/*/builtin; do |
| 37 | + if [ -d "$dir" ]; then |
| 38 | + shopt -s nullglob |
| 39 | + aml_files=("$dir"/*.aml) |
| 40 | + if [ ${#aml_files[@]} -gt 0 ]; then |
| 41 | + platform=$(basename "$(dirname "$dir")") |
| 42 | + echo "Packaging $platform into directory..." |
| 43 | + mkdir -p "artifacts/${platform}" |
| 44 | + cp -f "$dir"/*.aml "artifacts/${platform}/" || true |
| 45 | + platforms+=("$platform") |
| 46 | + fi |
| 47 | + shopt -u nullglob |
45 | 48 | fi |
46 | | - shopt -u nullglob |
| 49 | + done |
| 50 | +
|
| 51 | + # Convert platforms array to JSON using jq |
| 52 | + if [ ${#platforms[@]} -gt 0 ]; then |
| 53 | + PLATFORMS_JSON=$(printf '%s\n' "${platforms[@]}" | jq -R -s -c 'split("\n")[:-1]') |
| 54 | + else |
| 55 | + PLATFORMS_JSON='[]' |
47 | 56 | fi |
48 | | - done |
49 | 57 |
|
50 | | - # Convert platforms array to JSON using jq |
51 | | - if [ ${#platforms[@]} -gt 0 ]; then |
52 | | - PLATFORMS_JSON=$(printf '%s\n' "${platforms[@]}" | jq -R -s -c 'split("\n")[:-1]') |
53 | | - else |
54 | | - PLATFORMS_JSON='[]' |
55 | | - fi |
| 58 | + echo "Found platforms: $PLATFORMS_JSON" |
| 59 | + echo "platforms=$PLATFORMS_JSON" >> $GITHUB_OUTPUT |
| 60 | +
|
| 61 | + - name: Prepare Node uploader |
| 62 | + run: | |
| 63 | + npm init -y |
| 64 | + npm install @actions/[email protected] |
56 | 65 |
|
57 | | - echo "Found platforms: $PLATFORMS_JSON" |
58 | | - echo "platforms=$PLATFORMS_JSON" >> $GITHUB_OUTPUT |
| 66 | + - name: Write uploader script |
| 67 | + run: | |
| 68 | + cat > upload_artifacts.js <<'JS' |
| 69 | +const fs = require('fs'); |
| 70 | +const path = require('path'); |
| 71 | +const artifact = require('@actions/artifact'); |
59 | 72 |
|
60 | | - - name: Upload all platform zips as a single artifact |
61 | | - if: always() |
62 | | - uses: actions/upload-artifact@v4 |
63 | | - with: |
64 | | - name: aml-zips |
65 | | - path: artifacts/*.zip |
66 | | - upload: |
67 | | - name: Upload platform artifacts |
68 | | - needs: build |
69 | | - runs-on: ubuntu-latest |
70 | | - strategy: |
71 | | - fail-fast: false |
72 | | - matrix: |
73 | | - platform: ${{ fromJson(needs.build.outputs.platforms) }} |
74 | | - steps: |
75 | | - - name: Download zips artifact from build job |
76 | | - uses: actions/download-artifact@v4 |
77 | | - with: |
78 | | - name: aml-zips |
79 | | - path: downloaded_artifacts |
| 73 | +async function main() { |
| 74 | + const client = artifact.create(); |
| 75 | + const platforms = JSON.parse(process.env.PLATFORMS_JSON || '[]'); |
| 76 | + if (!platforms.length) { |
| 77 | + console.log('No platforms to upload'); |
| 78 | + return; |
| 79 | + } |
| 80 | + for (const p of platforms) { |
| 81 | + const dir = path.join('artifacts', p); |
| 82 | + if (!fs.existsSync(dir)) { |
| 83 | + console.log(`Skipping ${p}, directory not found: ${dir}`); |
| 84 | + continue; |
| 85 | + } |
| 86 | + const files = fs.readdirSync(dir).map(f => path.join(dir, f)); |
| 87 | + console.log(`Uploading artifact ${p} with files:`, files); |
| 88 | + // uploadArtifact(name, files, rootDirectory) |
| 89 | + await client.uploadArtifact(p, files, dir); |
| 90 | + } |
| 91 | +} |
80 | 92 |
|
81 | | - - name: Ensure platform zip exists |
82 | | - run: | |
83 | | - ls -al downloaded_artifacts || true |
84 | | - if [ ! -f "downloaded_artifacts/${{ matrix.platform }}.zip" ]; then |
85 | | - echo "Platform zip not found: downloaded_artifacts/${{ matrix.platform }}.zip" |
86 | | - false |
87 | | - fi |
| 93 | +main().catch(err => { console.error(err); process.exit(1); }); |
| 94 | +JS |
88 | 95 |
|
89 | | - - name: Upload artifact for platform |
90 | | - uses: actions/upload-artifact@v4 |
91 | | - with: |
92 | | - name: ${{ matrix.platform }} |
93 | | - path: downloaded_artifacts/${{ matrix.platform }}.zip |
| 96 | + - name: Upload per-platform artifacts (single job, sequential) |
| 97 | + env: |
| 98 | + PLATFORMS_JSON: ${{ steps.prepare.outputs.platforms }} |
| 99 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + run: | |
| 101 | + node upload_artifacts.js |
0 commit comments