Skip to content

ci: single-job sequential per-platform artifact upload using @actions… #4

ci: single-job sequential per-platform artifact upload using @actions…

ci: single-job sequential per-platform artifact upload using @actions… #4

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: Prepare Node uploader
run: |
npm init -y
npm install @actions/artifact@2.4.2
- name: Write uploader script
run: |
cat > upload_artifacts.js <<'JS'
const fs = require('fs');

Check failure on line 69 in .github/workflows/build-and-upload-aml.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-and-upload-aml.yml

Invalid workflow file

You have an error in your yaml syntax on line 69
const path = require('path');
const artifact = require('@actions/artifact');
async function main() {
const client = artifact.create();
const platforms = JSON.parse(process.env.PLATFORMS_JSON || '[]');
if (!platforms.length) {
console.log('No platforms to upload');
return;
}
for (const p of platforms) {
const dir = path.join('artifacts', p);
if (!fs.existsSync(dir)) {
console.log(`Skipping ${p}, directory not found: ${dir}`);
continue;
}
const files = fs.readdirSync(dir).map(f => path.join(dir, f));
console.log(`Uploading artifact ${p} with files:`, files);
// uploadArtifact(name, files, rootDirectory)
await client.uploadArtifact(p, files, dir);
}
}
main().catch(err => { console.error(err); process.exit(1); });
JS
- name: Upload per-platform artifacts (single job, sequential)
env:
PLATFORMS_JSON: ${{ steps.prepare.outputs.platforms }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
node upload_artifacts.js