Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15,713 changes: 3,798 additions & 11,915 deletions package-lock.json
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regenerated to version 3

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.3.1",
"type": "module",
"scripts": {
"generate-data": "node scripts/generate-release-data.js",
"generate-data": "node scripts/generate-release-data.js $npm_package_version",
"dev": "npm run generate-data && vite",
"build": "npm run generate-data && tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
Expand Down Expand Up @@ -64,4 +64,4 @@
"@esbuild/darwin-arm64": "0.23.0",
"@rollup/rollup-darwin-arm64": "^4.18.1"
}
}
}
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.91.1"
36 changes: 20 additions & 16 deletions scripts/generate-release-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@ import url from "url";
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.resolve(__filename, "../..");

async function generateReleaseData() {
async function generateReleaseData(version) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing HTTP call (every time) just to build the binary every time is quite painful for any distribution (since builds may only pre-fetch locked libraries and then perform the build in isolation) thus switched to explicitly passing the version here and statically generating metadata.

This also provides determinism (builds should not differ on the time of the build, which currently is possible since to latest being volatile) and lets the specific branch/tag be built with the correct version in generated file.

try {
const response = await fetch(
"https://api.github.com/repos/zmkfirmware/zmk-studio/releases/latest",
{
headers: process.env.GITHUB_TOKEN
? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` }
: {},
},
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

const data = await response.json();
const dataFilePath = path.resolve(
__dirname,
"src",
"data",
"release-data.json",
);
await fs.mkdir(path.dirname(dataFilePath), { recursive: true });
await fs.writeFile(dataFilePath, JSON.stringify(data));

await fs.writeFile(dataFilePath, JSON.stringify({
version: `v${version}`,
assets: [
`https://github.com/zmkfirmware/zmk-studio/releases/download/v${version}/ZMK.Studio-${version}-1.x86_64.rpm`,
`https://github.com/zmkfirmware/zmk-studio/releases/download/v${version}/ZMK.Studio_${version}_amd64.AppImage`,
`https://github.com/zmkfirmware/zmk-studio/releases/download/v${version}/ZMK.Studio_${version}_amd64.deb`,
`https://github.com/zmkfirmware/zmk-studio/releases/download/v${version}/ZMK.Studio_${version}_universal.dmg`,
`https://github.com/zmkfirmware/zmk-studio/releases/download/v${version}/ZMK.Studio_${version}_x64-setup.exe`,
`https://github.com/zmkfirmware/zmk-studio/releases/download/v${version}/ZMK.Studio_${version}_x64_en-US.msi`,
`https://github.com/zmkfirmware/zmk-studio/releases/download/v${version}/ZMK.Studio_universal.app.tar.gz`,
]
}));

console.log("Release data generated successfully!");
} catch (error) {
Expand All @@ -36,4 +35,9 @@ async function generateReleaseData() {
}
}

generateReleaseData();
const argv = process.argv.slice(2)
if (argv.length < 1) {
console.error("No version wasd specified for version data generation");
process.exit(1);
}
generateReleaseData(argv[0]);
Loading