diff --git a/gui/scripts/deno.lock b/gui/scripts/deno.lock index e4d7150..810a16a 100644 --- a/gui/scripts/deno.lock +++ b/gui/scripts/deno.lock @@ -118,5 +118,152 @@ "https://deno.land/x/oak@v12.1.0/types.d.ts": "41951a18c3bfdb11e40707cab75da078ba8a4907cd7d4e11d8536bc2db0dde05", "https://deno.land/x/oak@v12.1.0/util.ts": "3af8c4ed04c6cc2bedbe66e562a77fc59c72df31c55a902a63885861ca1639d6", "https://deno.land/x/path_to_regexp@v6.2.1/index.ts": "894060567837bae8fc9c5cbd4d0a05e9024672083d5883b525c031eea940e556" + }, + "npm": { + "specifiers": { + "@octokit/rest@19.0.7": "@octokit/rest@19.0.7_@octokit+core@4.2.0" + }, + "packages": { + "@octokit/auth-token@3.0.3": { + "integrity": "sha512-/aFM2M4HVDBT/jjDBa84sJniv1t9Gm/rLkalaz9htOm+L+8JMj1k9w0CkUdcxNyNxZPlTxKPVko+m1VlM58ZVA==", + "dependencies": { + "@octokit/types": "@octokit/types@9.0.0" + } + }, + "@octokit/core@4.2.0": { + "integrity": "sha512-AgvDRUg3COpR82P7PBdGZF/NNqGmtMq2NiPqeSsDIeCfYFOZ9gddqWNQHnFdEUf+YwOj4aZYmJnlPp7OXmDIDg==", + "dependencies": { + "@octokit/auth-token": "@octokit/auth-token@3.0.3", + "@octokit/graphql": "@octokit/graphql@5.0.5", + "@octokit/request": "@octokit/request@6.2.3", + "@octokit/request-error": "@octokit/request-error@3.0.3", + "@octokit/types": "@octokit/types@9.0.0", + "before-after-hook": "before-after-hook@2.2.3", + "universal-user-agent": "universal-user-agent@6.0.0" + } + }, + "@octokit/endpoint@7.0.5": { + "integrity": "sha512-LG4o4HMY1Xoaec87IqQ41TQ+glvIeTKqfjkCEmt5AIwDZJwQeVZFIEYXrYY6yLwK+pAScb9Gj4q+Nz2qSw1roA==", + "dependencies": { + "@octokit/types": "@octokit/types@9.0.0", + "is-plain-object": "is-plain-object@5.0.0", + "universal-user-agent": "universal-user-agent@6.0.0" + } + }, + "@octokit/graphql@5.0.5": { + "integrity": "sha512-Qwfvh3xdqKtIznjX9lz2D458r7dJPP8l6r4GQkIdWQouZwHQK0mVT88uwiU2bdTU2OtT1uOlKpRciUWldpG0yQ==", + "dependencies": { + "@octokit/request": "@octokit/request@6.2.3", + "@octokit/types": "@octokit/types@9.0.0", + "universal-user-agent": "universal-user-agent@6.0.0" + } + }, + "@octokit/openapi-types@16.0.0": { + "integrity": "sha512-JbFWOqTJVLHZSUUoF4FzAZKYtqdxWu9Z5m2QQnOyEa04fOFljvyh7D3GYKbfuaSWisqehImiVIMG4eyJeP5VEA==", + "dependencies": {} + }, + "@octokit/plugin-paginate-rest@6.0.0_@octokit+core@4.2.0": { + "integrity": "sha512-Sq5VU1PfT6/JyuXPyt04KZNVsFOSBaYOAq2QRZUwzVlI10KFvcbUo8lR258AAQL1Et60b0WuVik+zOWKLuDZxw==", + "dependencies": { + "@octokit/core": "@octokit/core@4.2.0", + "@octokit/types": "@octokit/types@9.0.0" + } + }, + "@octokit/plugin-request-log@1.0.4_@octokit+core@4.2.0": { + "integrity": "sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==", + "dependencies": { + "@octokit/core": "@octokit/core@4.2.0" + } + }, + "@octokit/plugin-rest-endpoint-methods@7.0.1_@octokit+core@4.2.0": { + "integrity": "sha512-pnCaLwZBudK5xCdrR823xHGNgqOzRnJ/mpC/76YPpNP7DybdsJtP7mdOwh+wYZxK5jqeQuhu59ogMI4NRlBUvA==", + "dependencies": { + "@octokit/core": "@octokit/core@4.2.0", + "@octokit/types": "@octokit/types@9.0.0", + "deprecation": "deprecation@2.3.1" + } + }, + "@octokit/request-error@3.0.3": { + "integrity": "sha512-crqw3V5Iy2uOU5Np+8M/YexTlT8zxCfI+qu+LxUB7SZpje4Qmx3mub5DfEKSO8Ylyk0aogi6TYdf6kxzh2BguQ==", + "dependencies": { + "@octokit/types": "@octokit/types@9.0.0", + "deprecation": "deprecation@2.3.1", + "once": "once@1.4.0" + } + }, + "@octokit/request@6.2.3": { + "integrity": "sha512-TNAodj5yNzrrZ/VxP+H5HiYaZep0H3GU0O7PaF+fhDrt8FPrnkei9Aal/txsN/1P7V3CPiThG0tIvpPDYUsyAA==", + "dependencies": { + "@octokit/endpoint": "@octokit/endpoint@7.0.5", + "@octokit/request-error": "@octokit/request-error@3.0.3", + "@octokit/types": "@octokit/types@9.0.0", + "is-plain-object": "is-plain-object@5.0.0", + "node-fetch": "node-fetch@2.6.9", + "universal-user-agent": "universal-user-agent@6.0.0" + } + }, + "@octokit/rest@19.0.7_@octokit+core@4.2.0": { + "integrity": "sha512-HRtSfjrWmWVNp2uAkEpQnuGMJsu/+dBr47dRc5QVgsCbnIc1+GFEaoKBWkYG+zjrsHpSqcAElMio+n10c0b5JA==", + "dependencies": { + "@octokit/core": "@octokit/core@4.2.0", + "@octokit/plugin-paginate-rest": "@octokit/plugin-paginate-rest@6.0.0_@octokit+core@4.2.0", + "@octokit/plugin-request-log": "@octokit/plugin-request-log@1.0.4_@octokit+core@4.2.0", + "@octokit/plugin-rest-endpoint-methods": "@octokit/plugin-rest-endpoint-methods@7.0.1_@octokit+core@4.2.0" + } + }, + "@octokit/types@9.0.0": { + "integrity": "sha512-LUewfj94xCMH2rbD5YJ+6AQ4AVjFYTgpp6rboWM5T7N3IsIF65SBEOVcYMGAEzO/kKNiNaW4LoWtoThOhH06gw==", + "dependencies": { + "@octokit/openapi-types": "@octokit/openapi-types@16.0.0" + } + }, + "before-after-hook@2.2.3": { + "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==", + "dependencies": {} + }, + "deprecation@2.3.1": { + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", + "dependencies": {} + }, + "is-plain-object@5.0.0": { + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "dependencies": {} + }, + "node-fetch@2.6.9": { + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "dependencies": { + "whatwg-url": "whatwg-url@5.0.0" + } + }, + "once@1.4.0": { + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "wrappy@1.0.2" + } + }, + "tr46@0.0.3": { + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dependencies": {} + }, + "universal-user-agent@6.0.0": { + "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==", + "dependencies": {} + }, + "webidl-conversions@3.0.1": { + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dependencies": {} + }, + "whatwg-url@5.0.0": { + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "tr46@0.0.3", + "webidl-conversions": "webidl-conversions@3.0.1" + } + }, + "wrappy@1.0.2": { + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dependencies": {} + } + } } } diff --git a/gui/scripts/make-update.ts b/gui/scripts/make-update.ts new file mode 100644 index 0000000..262f8b2 --- /dev/null +++ b/gui/scripts/make-update.ts @@ -0,0 +1,97 @@ +import { Octokit } from 'npm:@octokit/rest@19.0.7'; + +const TAG_PREFIX = 'gui-' + +type Platform = 'darwin-x86_64' | 'darwin-aarch64' | 'linux-x86_64' | 'windows-x86_64' +const PLATFORMS: Platform[] = ['darwin-x86_64', 'darwin-aarch64', 'linux-x86_64', 'windows-x86_64'] + +const PlatformSuffix: Record = { + 'darwin-x86_64': '.app.tar.gz', + 'darwin-aarch64': '.app.tar.gz', + 'linux-x86_64': '.AppImage.tar.gz', + 'windows-x86_64': '.msi.zip', +} + +type File = { + signature: string + url: string +} + +type UpdateJson = { + version: string + notes: string + pub_date: string + platforms: Record +} + +const REPO = { + owner: 'spacemeowx2', + repo: 's3si.ts', +} + +const octokit = new Octokit({ + auth: Deno.env.get('GITHUB_TOKEN'), +}); + +async function findFirstGuiRelease() { + let page = 1; + while (true) { + const { data: list } = await octokit.repos.listReleases({ + ...REPO, + page, + }) + + if (list.length === 0) { + return undefined + } + + for (const release of list) { + if (release.tag_name.startsWith(TAG_PREFIX)) { + return release + } + } + + page += 1; + } +} + +const release = await findFirstGuiRelease(); + +const version = release?.tag_name.slice(TAG_PREFIX.length) ?? 'unknown'; +const notes = release?.body ?? 'unknown'; +const pub_date = release?.published_at ?? 'unknown'; + +async function makePlatforms(r: typeof release) { + const assets = r?.assets ?? []; + const platforms = Object.fromEntries(PLATFORMS.map(p => { + const asset = assets.find(i => i.name.endsWith(PlatformSuffix[p])); + + if (!asset) { + throw new Error(`Asset not found for ${p}`) + } + + return [p, { + signature: asset.browser_download_url + '.sig', + url: asset.browser_download_url, + }] + })) as Record; + + + return platforms +} + +const updateJson: UpdateJson = { + version, + notes, + pub_date, + platforms: await makePlatforms(release), +} + +// fetch signatures +for (const platform of PLATFORMS) { + const file = updateJson.platforms[platform]; + const res = await fetch(file.signature); + file.signature = await res.text(); +} + +console.log(JSON.stringify(updateJson, null, 2));