Skip to content

Commit a370410

Browse files
committed
ci(release): download artifacts with jq loop (no zip files kept)
1 parent f8657f7 commit a370410

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,19 @@ jobs:
5858
5959
- name: Download artifacts
6060
run: |
61-
set -e
61+
set -euo pipefail
6262
echo "Artifacts file contents:" && cat artifacts.json
6363
mkdir -p downloaded_artifacts
64-
node -e "
65-
const fs = require('fs');
66-
const artifacts = JSON.parse(fs.readFileSync('artifacts.json','utf8')).artifacts;
67-
const token = process.env.GITHUB_TOKEN;
68-
const {spawnSync} = require('child_process');
69-
for(const a of artifacts){
70-
const url = a.archive_download_url;
71-
const file = `downloaded_artifacts/${a.name}.zip`;
72-
console.log('Downloading', a.name, '->', file);
73-
const curl = spawnSync('curl', ['-L', '-H', `Authorization: token ${token}`, '-o', file, url], {stdio:'inherit'});
74-
if(curl.status !== 0) process.exit(curl.status);
75-
const unzip = spawnSync('unzip', ['-o', file, '-d', `downloaded_artifacts/${a.name}`], {stdio:'inherit'});
76-
if(unzip.status !== 0) process.exit(unzip.status);
77-
}
78-
"
64+
jq -c '.artifacts[]' artifacts.json | while read -r a; do
65+
name=$(echo "$a" | jq -r '.name')
66+
url=$(echo "$a" | jq -r '.archive_download_url')
67+
echo "Downloading $name -> downloaded_artifacts/$name"
68+
mkdir -p "downloaded_artifacts/$name"
69+
tmp=$(mktemp)
70+
curl -L -H "Authorization: token $GITHUB_TOKEN" -o "$tmp" "$url"
71+
unzip -o "$tmp" -d "downloaded_artifacts/$name"
72+
rm -f "$tmp"
73+
done
7974
env:
8075
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8176

0 commit comments

Comments
 (0)