mirror of
https://github.com/felixrieseberg/windows95.git
synced 2026-05-09 00:24:09 +00:00
Fetch disk image from private GitHub release; harden download scripts
OneDrive 1drv.ms links no longer serve raw bytes to headless clients after the SPO migration. The disk image now lives as a release asset on a private repo and is fetched via 'gh release download' using DISK_REPO + DISK_TAG vars and an IMAGES_REPO_TOKEN secret. Scripts fail fast on missing env, bad zip, or missing windows95.img.
This commit is contained in:
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@@ -71,12 +71,16 @@ jobs:
|
|||||||
run: tools/download-disk.ps1
|
run: tools/download-disk.ps1
|
||||||
if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/')
|
if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/')
|
||||||
env:
|
env:
|
||||||
DISK_URL: ${{ secrets.DISK_URL }}
|
DISK_REPO: ${{ vars.DISK_REPO }}
|
||||||
|
DISK_TAG: ${{ vars.DISK_TAG }}
|
||||||
|
GH_TOKEN: ${{ secrets.IMAGES_REPO_TOKEN }}
|
||||||
- name: Download disk image (sh)
|
- name: Download disk image (sh)
|
||||||
run: chmod +x tools/download-disk.sh && ./tools/download-disk.sh
|
run: chmod +x tools/download-disk.sh && ./tools/download-disk.sh
|
||||||
if: matrix.os != 'windows-latest' && startsWith(github.ref, 'refs/tags/')
|
if: matrix.os != 'windows-latest' && startsWith(github.ref, 'refs/tags/')
|
||||||
env:
|
env:
|
||||||
DISK_URL: ${{ secrets.DISK_URL }}
|
DISK_REPO: ${{ vars.DISK_REPO }}
|
||||||
|
DISK_TAG: ${{ vars.DISK_TAG }}
|
||||||
|
GH_TOKEN: ${{ secrets.IMAGES_REPO_TOKEN }}
|
||||||
- name: Install
|
- name: Install
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Make
|
- name: Make
|
||||||
|
|||||||
@@ -1,11 +1,36 @@
|
|||||||
mkdir images
|
$ErrorActionPreference = "Stop"
|
||||||
cd images
|
|
||||||
|
|
||||||
$wc = New-Object System.Net.WebClient
|
# Pulls the disk image from a private GitHub release.
|
||||||
$wc.DownloadFile($env:DISK_URL, "$(Resolve-Path .)\images.zip")
|
# Requires DISK_REPO, DISK_TAG, GH_TOKEN.
|
||||||
|
|
||||||
|
if (-not $env:DISK_REPO) { Write-Host "::error::DISK_REPO not set"; exit 1 }
|
||||||
|
if (-not $env:DISK_TAG) { Write-Host "::error::DISK_TAG not set"; exit 1 }
|
||||||
|
if (-not $env:GH_TOKEN) { Write-Host "::error::GH_TOKEN not set"; exit 1 }
|
||||||
|
|
||||||
|
New-Item -ItemType Directory -Force -Path images | Out-Null
|
||||||
|
Set-Location images
|
||||||
|
|
||||||
|
gh release download $env:DISK_TAG -R $env:DISK_REPO -p '*.zip' -O images.zip --clobber
|
||||||
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||||
|
|
||||||
|
7z t images.zip | Out-Null
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
$size = (Get-Item images.zip).Length
|
||||||
|
Write-Host "::error::Downloaded file is not a valid zip (size: $size bytes)."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
7z x images.zip -y -aoa
|
7z x images.zip -y -aoa
|
||||||
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||||
|
|
||||||
Remove-Item images.zip
|
Remove-Item images.zip
|
||||||
Remove-Item __MACOSX -Recurse -ErrorAction Ignore
|
Remove-Item __MACOSX -Recurse -ErrorAction Ignore
|
||||||
cd ..
|
Set-Location ..
|
||||||
Tree ./ /F
|
|
||||||
|
if (-not (Test-Path images/windows95.img)) {
|
||||||
|
Write-Host "::error::images/windows95.img not found after extraction"
|
||||||
|
Get-ChildItem images
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Get-ChildItem images
|
||||||
|
|||||||
35
tools/download-disk.sh
Normal file → Executable file
35
tools/download-disk.sh
Normal file → Executable file
@@ -1,10 +1,35 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Pulls the disk image from a private GitHub release.
|
||||||
|
# Requires:
|
||||||
|
# DISK_REPO - e.g. felixrieseberg/windows95-images
|
||||||
|
# DISK_TAG - e.g. v5
|
||||||
|
# GH_TOKEN - a token with read access to DISK_REPO (set by the workflow)
|
||||||
|
|
||||||
|
: "${DISK_REPO:?DISK_REPO not set}"
|
||||||
|
: "${DISK_TAG:?DISK_TAG not set}"
|
||||||
|
: "${GH_TOKEN:?GH_TOKEN not set}"
|
||||||
|
|
||||||
mkdir -p ./images
|
mkdir -p ./images
|
||||||
cd ./images
|
cd ./images
|
||||||
wget -O images.zip $DISK_URL
|
|
||||||
|
gh release download "$DISK_TAG" -R "$DISK_REPO" -p '*.zip' -O images.zip --clobber
|
||||||
|
|
||||||
|
if ! unzip -tq images.zip > /dev/null; then
|
||||||
|
echo "::error::Downloaded file is not a valid zip (size: $(wc -c < images.zip) bytes)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
unzip -o images.zip
|
unzip -o images.zip
|
||||||
rm images.zip
|
rm -f images.zip
|
||||||
rm -r __MACOSX
|
rm -rf __MACOSX
|
||||||
cd -
|
cd -
|
||||||
ls images
|
|
||||||
|
if [ ! -f images/windows95.img ]; then
|
||||||
|
echo "::error::images/windows95.img not found after extraction"
|
||||||
|
ls -la images/
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ls -la images/
|
||||||
|
|||||||
Reference in New Issue
Block a user