Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
dmca-glasgow committed Aug 15, 2024
1 parent 3a9cc22 commit 726d6ee
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .github/actions/post-release/lib/index.js

Large diffs are not rendered by default.

62 changes: 47 additions & 15 deletions .github/actions/post-release/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function run() {
const releaseId = Number(process.env.RELEASE_ID);

const octokit = getOctokit(token);
// const version = await getVersion();
const version = await getVersion();

const release = await octokit.request(
`GET /repos/${owner}/${repo}/releases/${releaseId}`,
Expand All @@ -47,9 +47,42 @@ async function run() {
);
const assets = releaseAssets.data as Asset[];

const latestJsonContent = await getLatestJson(assets);
console.log('removing latest.json...');
const latestJsonAsset = assets.find(
(o) => o.name === 'latest.json',
) as Asset;
await octokit.rest.repos.deleteReleaseAsset({
owner,
repo,
asset_id: latestJsonAsset.id,
});

latestJsonContent.notes = String(release.data.body);
console.log('removing .sig assets...');
await Promise.all(
assets
.filter((asset) => asset.name.endsWith('.sig'))
.map((asset) =>
octokit.rest.repos.deleteReleaseAsset({
owner,
repo,
asset_id: asset.id,
}),
),
);

console.log('adding version to macOS assets...');
await Promise.all(
assets
.filter((asset) => asset.name.includes('.app'))
.map((asset) =>
octokit.rest.repos.updateReleaseAsset({
owner,
repo,
asset_id: asset.id,
name: `${asset.name.slice(0, 4)}_${version}_${asset.name.slice(5)}`,
}),
),
);

// const platformFiles = Object.entries(latestJsonContent.platforms).map(
// ([platform, o]) => ({
Expand Down Expand Up @@ -110,6 +143,9 @@ async function run() {
});

// Edit updater gist file
const latestJsonContent = await getAssetTextContent(latestJsonAsset);
latestJsonContent.notes = String(release.data.body);

await octokit.rest.gists.update({
gist_id: gistId,
files: {
Expand All @@ -119,20 +155,16 @@ async function run() {
},
});

// async function getVersion(): Promise<string> {
// const filePath = `src-tauri/tauri.conf.json`;
// const contents = await readFile(filePath, 'utf-8');
// const json = JSON.parse(contents);
// return json.package.version;
// }

async function getLatestJson(assets: Asset[]) {
const latestAsset = assets.find(
(o) => o.name === 'latest.json',
) as Asset;
async function getVersion(): Promise<string> {
const filePath = `src-tauri/tauri.conf.json`;
const contents = await readFile(filePath, 'utf-8');
const json = JSON.parse(contents);
return json.package.version;
}

async function getAssetTextContent(asset: Asset) {
const res = await octokit.request(
`GET /repos/${owner}/${repo}/releases/assets/${latestAsset.id}`,
`GET /repos/${owner}/${repo}/releases/assets/${asset.id}`,
{
headers: {
Accept: 'application/octet-stream',
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
repo: context.repo.repo,
tag_name: `v${{ needs.version-check.outputs.version }}`,
name: `ISOS v${{ needs.version-check.outputs.version }}`,
body: 'Take a look at the assets to download and install this app.',
draft: true,
prerelease: false,
generate_release_notes: true
Expand Down
12 changes: 9 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Preact + TS</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>ISOS</title>
<script>
window.__ENV__ = {
VITE_ISOS_VERSION: '%VITE_ISOS_VERSION%',
};
</script>
</head>
<body>
<div id="app"></div>
Expand Down
1 change: 0 additions & 1 deletion docs/public/vite.svg

This file was deleted.

6 changes: 3 additions & 3 deletions docs/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './app.css';
// https://github.com/dmca-glasgow/isos/releases/download/v0.0.17/isos_0.0.17_x64-setup.nsis.zip
// https://github.com/dmca-glasgow/isos/releases/download/v0.0.17/isos_0.0.17_amd64.AppImage.tar.gz

const version = import.meta.env.VITE_ISOS_VERSION;
const version = window.__ENV__.VITE_ISOS_VERSION;

export function App() {
return (
Expand Down Expand Up @@ -47,9 +47,9 @@ type LinkProps = {
};

function DownloadLink({ label, fileName }: LinkProps) {
return <a href={createHref(fileName)}>{label}</a>;
return <a href={createHref(fileName, version)}>{label}</a>;
}

function createHref(fileName: string) {
function createHref(fileName: string, version: string) {
return `https://github.com/dmca-glasgow/isos/releases/download/v${version}/${fileName}`;
}
4 changes: 4 additions & 0 deletions docs/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/// <reference types="vite/client" />

interface Window {
__ENV__: Record<string, string>;
}
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "isos",
"version": "0.0.26"
"version": "0.0.27"
},
"tauri": {
"cli": {
Expand Down

0 comments on commit 726d6ee

Please sign in to comment.