Skip to content

Commit

Permalink
use download artifacts action
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Jan 5, 2025
1 parent c7fc610 commit 13378ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
if: startsWith(matrix.config.os, 'windows')
uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 26100
s dk-version: 26100

- name: Install dependencies on ubuntu
if: startsWith(matrix.config.name, 'Ubuntu')
Expand Down Expand Up @@ -133,8 +133,13 @@ jobs:
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist

- name: Build
shell: bash
run: |
ls -R
npm ci
node build/download-run-artifacts.js "--repo=${{ github.repository }}" "--run_id=${{ github.run_id }}"
15 changes: 13 additions & 2 deletions build/download-run-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ import {
} from './utils.js'

async function downloadFileFromZip(url, filepath) {
console.log('downloading:', url);
const res = await fetch(url);
if (res.status !== 200) {
const text = await res.text();
throw new Error(`url: ${url}\n${text}`);
}
console.log(res.status, res.bytes);
const zipData = await res.arrayBuffer();
const {entries} = await unzip(zipData);
return Promise.all(Object.entries(entries).map(async ([name, entry]) => {
const data = await entry.arrayBuffer();
const filename = path.join(filepath, name);
console.log('downloaded:', filename);
console.log('extracted:', filename);
fs.mkdirSync(filepath, {recursive: true});
fs.writeFileSync(filename, new Uint8Array(data));
return filename;
Expand Down Expand Up @@ -90,6 +96,8 @@ const data = {
}
]
}
https://github.com/greggman/node-webgpu/actions/runs/12618872732/artifacts/2387232364
*/

const [owner, repo] = args.repo.split('/');
Expand All @@ -101,5 +109,8 @@ const data = await github.getRunArtifacts({
const filenames = await Promise.all(
data.artifacts
.filter(({name}) => name?.endsWith('.node'))
.map(({archive_download_url}) => downloadFileFromZip(archive_download_url, 'dist'))
.map(({id}) => {
const url = `https://github.com/${owner}/${repo}/actions/runs/${args.run_id}/artifacts/${id}`;
return downloadFileFromZip(url, 'dist');
})
);

0 comments on commit 13378ba

Please sign in to comment.