chore: updater json supports arch field
This commit is contained in:
parent
cb9d3098de
commit
ab82db9e22
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -106,7 +106,7 @@ jobs:
|
|||||||
- name: Yarn install
|
- name: Yarn install
|
||||||
run: yarn install
|
run: yarn install
|
||||||
|
|
||||||
- name: Release update.json
|
- name: Release updater file
|
||||||
run: yarn run release
|
run: yarn run updater
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
4
.github/workflows/updater.yml
vendored
4
.github/workflows/updater.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
- name: Yarn install
|
- name: Yarn install
|
||||||
run: yarn install
|
run: yarn install
|
||||||
|
|
||||||
- name: Release update.json
|
- name: Release updater file
|
||||||
run: yarn run release
|
run: yarn run updater
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
@ -8,7 +8,7 @@ const UPDATE_JSON_PROXY = "update-proxy.json";
|
|||||||
|
|
||||||
/// generate update.json
|
/// generate update.json
|
||||||
/// upload to update tag's release asset
|
/// upload to update tag's release asset
|
||||||
async function resolveRelease() {
|
async function resolveUpdater() {
|
||||||
if (process.env.GITHUB_TOKEN === undefined) {
|
if (process.env.GITHUB_TOKEN === undefined) {
|
||||||
throw new Error("GITHUB_TOKEN is required");
|
throw new Error("GITHUB_TOKEN is required");
|
||||||
}
|
}
|
||||||
@ -38,9 +38,14 @@ async function resolveRelease() {
|
|||||||
notes: await resolveUpdateLog(tag.name), // use updatelog.md
|
notes: await resolveUpdateLog(tag.name), // use updatelog.md
|
||||||
pub_date: new Date().toISOString(),
|
pub_date: new Date().toISOString(),
|
||||||
platforms: {
|
platforms: {
|
||||||
win64: { signature: "", url: "" },
|
win64: { signature: "", url: "" }, // compatible with older formats
|
||||||
linux: { signature: "", url: "" },
|
linux: { signature: "", url: "" }, // compatible with older formats
|
||||||
darwin: { signature: "", url: "" },
|
darwin: { signature: "", url: "" }, // compatible with older formats
|
||||||
|
"darwin-aarch64": { signature: "", url: "" },
|
||||||
|
"darwin-intel": { signature: "", url: "" },
|
||||||
|
"linux-x86_64": { signature: "", url: "" },
|
||||||
|
"windows-x86_64": { signature: "", url: "" },
|
||||||
|
"windows-i686": { signature: "", url: "" }, // no supported
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,36 +53,49 @@ async function resolveRelease() {
|
|||||||
const { name, browser_download_url } = asset;
|
const { name, browser_download_url } = asset;
|
||||||
|
|
||||||
// win64 url
|
// win64 url
|
||||||
if (/\.msi\.zip$/.test(name)) {
|
if (name.endsWith(".msi.zip")) {
|
||||||
updateData.platforms.win64.url = browser_download_url;
|
updateData.platforms.win64.url = browser_download_url;
|
||||||
|
updateData.platforms["windows-x86_64"].url = browser_download_url;
|
||||||
}
|
}
|
||||||
// win64 signature
|
// win64 signature
|
||||||
if (/\.msi\.zip\.sig$/.test(name)) {
|
if (name.endsWith(".msi.zip.sig")) {
|
||||||
updateData.platforms.win64.signature = await getSignature(
|
const sig = await getSignature(browser_download_url);
|
||||||
browser_download_url
|
updateData.platforms.win64.signature = sig;
|
||||||
);
|
updateData.platforms["windows-x86_64"].signature = sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// darwin url
|
// darwin url (intel)
|
||||||
if (/\.app\.tar\.gz$/.test(name)) {
|
if (name.endsWith(".app.tar.gz") && !name.includes("aarch")) {
|
||||||
updateData.platforms.darwin.url = browser_download_url;
|
updateData.platforms.darwin.url = browser_download_url;
|
||||||
|
updateData.platforms["darwin-intel"].url = browser_download_url;
|
||||||
}
|
}
|
||||||
// darwin signature
|
// darwin signature (intel)
|
||||||
if (/\.app\.tar\.gz\.sig$/.test(name)) {
|
if (name.endsWith(".app.tar.gz.sig") && !name.includes("aarch")) {
|
||||||
updateData.platforms.darwin.signature = await getSignature(
|
const sig = await getSignature(browser_download_url);
|
||||||
browser_download_url
|
updateData.platforms.darwin.signature = sig;
|
||||||
);
|
updateData.platforms["darwin-intel"].signature = sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
// darwin url (aarch)
|
||||||
|
if (name.endsWith("aarch.app.tar.gz")) {
|
||||||
|
updateData.platforms["darwin-aarch64"].url = browser_download_url;
|
||||||
|
}
|
||||||
|
// darwin signature (aarch)
|
||||||
|
if (name.endsWith("aarch.app.tar.gz.sig")) {
|
||||||
|
const sig = await getSignature(browser_download_url);
|
||||||
|
updateData.platforms["darwin-aarch64"].signature = sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// linux url
|
// linux url
|
||||||
if (/\.AppImage\.tar\.gz$/.test(name)) {
|
if (name.endsWith(".AppImage.tar.gz")) {
|
||||||
updateData.platforms.linux.url = browser_download_url;
|
updateData.platforms.linux.url = browser_download_url;
|
||||||
|
updateData.platforms["linux-x86_64"].url = browser_download_url;
|
||||||
}
|
}
|
||||||
// linux signature
|
// linux signature
|
||||||
if (/\.AppImage\.tar\.gz\.sig$/.test(name)) {
|
if (name.endsWith(".AppImage.tar.gz.sig")) {
|
||||||
updateData.platforms.linux.signature = await getSignature(
|
const sig = await getSignature(browser_download_url);
|
||||||
browser_download_url
|
updateData.platforms.linux.signature = sig;
|
||||||
);
|
updateData.platforms["linux-x86_64"].signature = sig;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -85,29 +103,24 @@ async function resolveRelease() {
|
|||||||
console.log(updateData);
|
console.log(updateData);
|
||||||
|
|
||||||
// maybe should test the signature as well
|
// maybe should test the signature as well
|
||||||
const { darwin, win64, linux } = updateData.platforms;
|
// delete the null field
|
||||||
if (!darwin.url) {
|
Object.entries(updateData.platforms).forEach(([key, value]) => {
|
||||||
console.log(`[Error]: failed to parse release for darwin`);
|
if (!value.url) {
|
||||||
delete updateData.platforms.darwin;
|
console.log(`[Error]: failed to parse release for "${key}"`);
|
||||||
}
|
delete updateData.platforms[key];
|
||||||
if (!win64.url) {
|
|
||||||
console.log(`[Error]: failed to parse release for win64`);
|
|
||||||
delete updateData.platforms.win64;
|
|
||||||
}
|
|
||||||
if (!linux.url) {
|
|
||||||
console.log(`[Error]: failed to parse release for linux`);
|
|
||||||
delete updateData.platforms.linux;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 生成一个代理github的更新文件
|
// 生成一个代理github的更新文件
|
||||||
// 使用 https://hub.fastgit.xyz/ 做github资源的加速
|
// 使用 https://hub.fastgit.xyz/ 做github资源的加速
|
||||||
const updateDataNew = JSON.parse(JSON.stringify(updateData));
|
const updateDataNew = JSON.parse(JSON.stringify(updateData));
|
||||||
|
|
||||||
Object.keys(updateDataNew.platforms).forEach((key) => {
|
Object.entries(updateDataNew.platforms).forEach(([key, value]) => {
|
||||||
if (updateDataNew.platforms[key]) {
|
if (value.url) {
|
||||||
updateDataNew.platforms[key].url = updateDataNew.platforms[
|
updateDataNew.platforms[key].url = value.url.replace(
|
||||||
key
|
"https://github.com/",
|
||||||
].url.replace("https://github.com/", "https://hub.fastgit.xyz/");
|
"https://hub.fastgit.xyz/"
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log(`[Error]: updateDataNew.platforms.${key} is null`);
|
console.log(`[Error]: updateDataNew.platforms.${key} is null`);
|
||||||
}
|
}
|
||||||
@ -135,7 +148,7 @@ async function resolveRelease() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// upload assets
|
// upload new assets
|
||||||
await github.rest.repos.uploadReleaseAsset({
|
await github.rest.repos.uploadReleaseAsset({
|
||||||
...options,
|
...options,
|
||||||
release_id: updateRelease.id,
|
release_id: updateRelease.id,
|
||||||
@ -161,4 +174,4 @@ async function getSignature(url) {
|
|||||||
return response.text();
|
return response.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveRelease().catch(console.error);
|
resolveUpdater().catch(console.error);
|
Loading…
Reference in New Issue
Block a user