// scripts/ci/upload-asset-to-forgejo-release.mjs // Uploads D3RO-Voice-Setup-1.0.0-x64.exe directly to Forgejo Release v1.0.0 import { readFileSync, existsSync } from 'node:fs'; import path from 'node:path'; const auth = Buffer.from('yunchan:ONVI2v4J#y').toString('base64'); const EXE_PATH = 'apps/desktop/release/1.0.0/D3RO-Voice-Setup-1.0.0-x64.exe'; async function uploadAsset() { console.log('--- Fetching release ID for v1.0.0 ---'); const relRes = await fetch('https://git.chanpaca.net/api/v1/repos/yunchan/d3ro-voice/releases/tags/v1.0.0', { headers: { 'Authorization': 'Basic ' + auth } }); const relData = await relRes.json(); console.log('Release ID:', relData.id, relData.name); if (!relData.id) { console.error('Release not found'); return; } const fileBuffer = readFileSync(EXE_PATH); console.log(`Uploading ${EXE_PATH} (${(fileBuffer.length / (1024*1024)).toFixed(1)} MB)...`); const formData = new FormData(); formData.append('attachment', new Blob([fileBuffer]), 'D3RO-Voice-Setup-1.0.0-x64.exe'); const uploadRes = await fetch(`https://git.chanpaca.net/api/v1/repos/yunchan/d3ro-voice/releases/${relData.id}/assets?name=D3RO-Voice-Setup-1.0.0-x64.exe`, { method: 'POST', headers: { 'Authorization': 'Basic ' + auth, }, body: formData }); console.log('Upload HTTP Status:', uploadRes.status); const uploadData = await uploadRes.json(); console.log('Upload Result:', uploadData); } uploadAsset().catch(console.error);