2022-02-22 01:56:06 +08:00
|
|
|
|
import fetch from "node-fetch";
|
2022-01-19 00:37:59 +08:00
|
|
|
|
import { getOctokit, context } from "@actions/github";
|
2022-03-19 14:04:58 +08:00
|
|
|
|
import { resolveUpdateLog } from "./updatelog.mjs";
|
2022-01-19 00:37:59 +08:00
|
|
|
|
|
2022-02-22 01:56:06 +08:00
|
|
|
|
const UPDATE_TAG_NAME = "updater";
|
|
|
|
|
|
const UPDATE_JSON_FILE = "update.json";
|
2022-03-19 11:14:12 +08:00
|
|
|
|
const UPDATE_JSON_PROXY = "update-proxy.json";
|
2022-01-19 00:37:59 +08:00
|
|
|
|
|
|
|
|
|
|
/// generate update.json
|
|
|
|
|
|
/// upload to update tag's release asset
|
2022-04-05 23:19:54 +08:00
|
|
|
|
async function resolveUpdater() {
|
2022-01-19 00:37:59 +08:00
|
|
|
|
if (process.env.GITHUB_TOKEN === undefined) {
|
|
|
|
|
|
throw new Error("GITHUB_TOKEN is required");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-22 01:56:06 +08:00
|
|
|
|
const options = { owner: context.repo.owner, repo: context.repo.repo };
|
|
|
|
|
|
const github = getOctokit(process.env.GITHUB_TOKEN);
|
|
|
|
|
|
|
|
|
|
|
|
const { data: tags } = await github.rest.repos.listTags({
|
|
|
|
|
|
...options,
|
|
|
|
|
|
per_page: 10,
|
|
|
|
|
|
page: 1,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// get the latest publish tag
|
|
|
|
|
|
const tag = tags.find((t) => t.name.startsWith("v"));
|
|
|
|
|
|
|
2025-02-27 17:19:04 +08:00
|
|
|
|
console.log(`找到最新发布标签: ${tag.name}`);
|
2022-02-22 01:56:06 +08:00
|
|
|
|
console.log();
|
|
|
|
|
|
|
|
|
|
|
|
const { data: latestRelease } = await github.rest.repos.getReleaseByTag({
|
|
|
|
|
|
...options,
|
|
|
|
|
|
tag: tag.name,
|
|
|
|
|
|
});
|
2022-01-19 00:37:59 +08:00
|
|
|
|
|
2025-02-27 17:19:04 +08:00
|
|
|
|
console.log(`发布资产数量: ${latestRelease.assets.length}`);
|
|
|
|
|
|
console.log("资产列表:");
|
|
|
|
|
|
latestRelease.assets.forEach((asset) => {
|
|
|
|
|
|
console.log(`- ${asset.name}`);
|
|
|
|
|
|
});
|
|
|
|
|
|
console.log();
|
|
|
|
|
|
|
2022-01-19 00:37:59 +08:00
|
|
|
|
const updateData = {
|
2022-02-22 01:56:06 +08:00
|
|
|
|
name: tag.name,
|
2022-03-19 14:04:58 +08:00
|
|
|
|
notes: await resolveUpdateLog(tag.name), // use updatelog.md
|
2022-01-19 00:37:59 +08:00
|
|
|
|
pub_date: new Date().toISOString(),
|
|
|
|
|
|
platforms: {
|
2022-04-05 23:19:54 +08:00
|
|
|
|
win64: { signature: "", url: "" }, // compatible with older formats
|
|
|
|
|
|
linux: { signature: "", url: "" }, // compatible with older formats
|
|
|
|
|
|
darwin: { signature: "", url: "" }, // compatible with older formats
|
2023-11-22 14:52:14 +08:00
|
|
|
|
"darwin-aarch64": { signature: "", url: "" },
|
2022-04-05 23:19:54 +08:00
|
|
|
|
"darwin-intel": { signature: "", url: "" },
|
2023-09-11 10:16:54 +08:00
|
|
|
|
"darwin-x86_64": { signature: "", url: "" },
|
2022-04-05 23:19:54 +08:00
|
|
|
|
"linux-x86_64": { signature: "", url: "" },
|
2024-05-06 13:03:52 +08:00
|
|
|
|
"linux-x86": { signature: "", url: "" },
|
2024-06-08 19:36:58 +08:00
|
|
|
|
"linux-i686": { signature: "", url: "" },
|
2023-11-30 22:46:09 +08:00
|
|
|
|
"linux-aarch64": { signature: "", url: "" },
|
2023-12-10 17:14:48 +08:00
|
|
|
|
"linux-armv7": { signature: "", url: "" },
|
2022-04-05 23:19:54 +08:00
|
|
|
|
"windows-x86_64": { signature: "", url: "" },
|
2023-12-10 17:14:48 +08:00
|
|
|
|
"windows-aarch64": { signature: "", url: "" },
|
2024-05-06 13:03:52 +08:00
|
|
|
|
"windows-x86": { signature: "", url: "" },
|
2024-06-08 19:36:58 +08:00
|
|
|
|
"windows-i686": { signature: "", url: "" },
|
2022-01-19 00:37:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2022-02-22 01:56:06 +08:00
|
|
|
|
const promises = latestRelease.assets.map(async (asset) => {
|
|
|
|
|
|
const { name, browser_download_url } = asset;
|
2025-02-27 17:19:04 +08:00
|
|
|
|
console.log(`处理资产: ${name}`);
|
2022-01-19 00:37:59 +08:00
|
|
|
|
|
2025-02-27 17:19:04 +08:00
|
|
|
|
// Windows 资产处理 (v2 格式: 从 -setup.nsis.zip 改为 -setup.exe)
|
2022-02-22 01:56:06 +08:00
|
|
|
|
// win64 url
|
2025-02-27 17:19:04 +08:00
|
|
|
|
if (name.endsWith("x64-setup.exe")) {
|
2022-02-22 01:56:06 +08:00
|
|
|
|
updateData.platforms.win64.url = browser_download_url;
|
2022-04-05 23:19:54 +08:00
|
|
|
|
updateData.platforms["windows-x86_64"].url = browser_download_url;
|
2022-02-22 01:56:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
// win64 signature
|
2025-02-27 17:19:04 +08:00
|
|
|
|
if (name.endsWith("x64-setup.exe.sig")) {
|
2022-04-05 23:19:54 +08:00
|
|
|
|
const sig = await getSignature(browser_download_url);
|
|
|
|
|
|
updateData.platforms.win64.signature = sig;
|
|
|
|
|
|
updateData.platforms["windows-x86_64"].signature = sig;
|
2022-02-22 01:56:06 +08:00
|
|
|
|
}
|
2022-03-19 10:50:44 +08:00
|
|
|
|
|
2024-05-06 13:03:52 +08:00
|
|
|
|
// win32 url
|
2025-02-27 17:19:04 +08:00
|
|
|
|
if (name.endsWith("x86-setup.exe")) {
|
2024-05-06 13:03:52 +08:00
|
|
|
|
updateData.platforms["windows-x86"].url = browser_download_url;
|
2024-06-08 19:36:58 +08:00
|
|
|
|
updateData.platforms["windows-i686"].url = browser_download_url;
|
2024-05-06 13:03:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
// win32 signature
|
2025-02-27 17:19:04 +08:00
|
|
|
|
if (name.endsWith("x86-setup.exe.sig")) {
|
2024-05-06 13:03:52 +08:00
|
|
|
|
const sig = await getSignature(browser_download_url);
|
|
|
|
|
|
updateData.platforms["windows-x86"].signature = sig;
|
2024-06-08 19:36:58 +08:00
|
|
|
|
updateData.platforms["windows-i686"].signature = sig;
|
2024-05-06 13:03:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-10 17:14:48 +08:00
|
|
|
|
// win arm url
|
2025-02-27 17:19:04 +08:00
|
|
|
|
if (name.endsWith("arm64-setup.exe")) {
|
2023-12-10 17:14:48 +08:00
|
|
|
|
updateData.platforms["windows-aarch64"].url = browser_download_url;
|
|
|
|
|
|
}
|
|
|
|
|
|
// win arm signature
|
2025-02-27 17:19:04 +08:00
|
|
|
|
if (name.endsWith("arm64-setup.exe.sig")) {
|
2023-12-10 17:14:48 +08:00
|
|
|
|
const sig = await getSignature(browser_download_url);
|
|
|
|
|
|
updateData.platforms["windows-aarch64"].signature = sig;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-27 17:19:04 +08:00
|
|
|
|
// macOS 资产处理 (v1和v2格式相同)
|
2022-04-05 23:19:54 +08:00
|
|
|
|
// darwin url (intel)
|
|
|
|
|
|
if (name.endsWith(".app.tar.gz") && !name.includes("aarch")) {
|
2022-03-19 10:50:44 +08:00
|
|
|
|
updateData.platforms.darwin.url = browser_download_url;
|
2022-04-05 23:19:54 +08:00
|
|
|
|
updateData.platforms["darwin-intel"].url = browser_download_url;
|
2023-09-11 10:12:40 +08:00
|
|
|
|
updateData.platforms["darwin-x86_64"].url = browser_download_url;
|
2022-03-19 10:50:44 +08:00
|
|
|
|
}
|
2022-04-05 23:19:54 +08:00
|
|
|
|
// darwin signature (intel)
|
|
|
|
|
|
if (name.endsWith(".app.tar.gz.sig") && !name.includes("aarch")) {
|
|
|
|
|
|
const sig = await getSignature(browser_download_url);
|
|
|
|
|
|
updateData.platforms.darwin.signature = sig;
|
|
|
|
|
|
updateData.platforms["darwin-intel"].signature = sig;
|
2023-09-11 10:12:40 +08:00
|
|
|
|
updateData.platforms["darwin-x86_64"].signature = sig;
|
2022-04-05 23:19:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-11-22 14:52:14 +08:00
|
|
|
|
// darwin url (aarch)
|
2025-02-27 17:19:04 +08:00
|
|
|
|
if (
|
|
|
|
|
|
name.endsWith("aarch64.app.tar.gz") ||
|
|
|
|
|
|
(name.endsWith(".dmg") && name.includes("aarch64"))
|
|
|
|
|
|
) {
|
2023-11-22 14:52:14 +08:00
|
|
|
|
updateData.platforms["darwin-aarch64"].url = browser_download_url;
|
2022-03-19 10:50:44 +08:00
|
|
|
|
}
|
2024-06-08 19:36:58 +08:00
|
|
|
|
// darwin signature (aarch)
|
2025-02-27 17:19:04 +08:00
|
|
|
|
if (
|
|
|
|
|
|
name.endsWith("aarch64.app.tar.gz.sig") ||
|
|
|
|
|
|
(name.endsWith(".dmg.sig") && name.includes("aarch64"))
|
|
|
|
|
|
) {
|
2022-04-05 23:19:54 +08:00
|
|
|
|
const sig = await getSignature(browser_download_url);
|
2024-06-08 19:36:58 +08:00
|
|
|
|
updateData.platforms["darwin-aarch64"].signature = sig;
|
2025-02-27 17:19:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Linux 资产处理 (支持 .rpm 和 .deb 包)
|
|
|
|
|
|
// Linux .rpm 包
|
|
|
|
|
|
if (name.endsWith(".rpm")) {
|
|
|
|
|
|
// 根据文件名确定架构
|
|
|
|
|
|
if (name.includes("x86_64")) {
|
|
|
|
|
|
updateData.platforms.linux.url = browser_download_url;
|
|
|
|
|
|
updateData.platforms["linux-x86_64"].url = browser_download_url;
|
|
|
|
|
|
} else if (name.includes("aarch64")) {
|
|
|
|
|
|
updateData.platforms["linux-aarch64"].url = browser_download_url;
|
|
|
|
|
|
} else if (name.includes("armhfp") || name.includes("armhf")) {
|
|
|
|
|
|
updateData.platforms["linux-armv7"].url = browser_download_url;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Linux .rpm 签名
|
|
|
|
|
|
if (name.endsWith(".rpm.sig")) {
|
|
|
|
|
|
const sig = await getSignature(browser_download_url);
|
|
|
|
|
|
|
|
|
|
|
|
// 根据文件名确定架构
|
|
|
|
|
|
if (name.includes("x86_64")) {
|
|
|
|
|
|
updateData.platforms.linux.signature = sig;
|
|
|
|
|
|
updateData.platforms["linux-x86_64"].signature = sig;
|
|
|
|
|
|
} else if (name.includes("aarch64")) {
|
|
|
|
|
|
updateData.platforms["linux-aarch64"].signature = sig;
|
|
|
|
|
|
} else if (name.includes("armhfp") || name.includes("armhf")) {
|
|
|
|
|
|
updateData.platforms["linux-armv7"].signature = sig;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Linux .deb 包
|
|
|
|
|
|
if (name.endsWith(".deb")) {
|
|
|
|
|
|
// 根据文件名确定架构
|
|
|
|
|
|
if (name.includes("amd64")) {
|
|
|
|
|
|
updateData.platforms.linux.url = browser_download_url;
|
|
|
|
|
|
updateData.platforms["linux-x86_64"].url = browser_download_url;
|
|
|
|
|
|
} else if (name.includes("arm64")) {
|
|
|
|
|
|
updateData.platforms["linux-aarch64"].url = browser_download_url;
|
|
|
|
|
|
} else if (name.includes("armhf")) {
|
|
|
|
|
|
updateData.platforms["linux-armv7"].url = browser_download_url;
|
|
|
|
|
|
} else if (name.includes("i386")) {
|
|
|
|
|
|
updateData.platforms["linux-x86"].url = browser_download_url;
|
|
|
|
|
|
updateData.platforms["linux-i686"].url = browser_download_url;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Linux .deb 签名
|
|
|
|
|
|
if (name.endsWith(".deb.sig")) {
|
|
|
|
|
|
const sig = await getSignature(browser_download_url);
|
|
|
|
|
|
|
|
|
|
|
|
// 根据文件名确定架构
|
|
|
|
|
|
if (name.includes("amd64")) {
|
|
|
|
|
|
updateData.platforms.linux.signature = sig;
|
|
|
|
|
|
updateData.platforms["linux-x86_64"].signature = sig;
|
|
|
|
|
|
} else if (name.includes("arm64")) {
|
|
|
|
|
|
updateData.platforms["linux-aarch64"].signature = sig;
|
|
|
|
|
|
} else if (name.includes("armhf")) {
|
|
|
|
|
|
updateData.platforms["linux-armv7"].signature = sig;
|
|
|
|
|
|
} else if (name.includes("i386")) {
|
|
|
|
|
|
updateData.platforms["linux-x86"].signature = sig;
|
|
|
|
|
|
updateData.platforms["linux-i686"].signature = sig;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// macOS .dmg 包处理 - 专门处理macOS ARM包
|
|
|
|
|
|
if (name.endsWith(".dmg")) {
|
|
|
|
|
|
if (name.includes("aarch64") || name.includes("arm64")) {
|
|
|
|
|
|
updateData.platforms["darwin-aarch64"].url = browser_download_url;
|
|
|
|
|
|
} else if (name.includes("x86_64") || name.includes("intel")) {
|
|
|
|
|
|
updateData.platforms.darwin.url = browser_download_url;
|
|
|
|
|
|
updateData.platforms["darwin-intel"].url = browser_download_url;
|
|
|
|
|
|
updateData.platforms["darwin-x86_64"].url = browser_download_url;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// macOS .dmg 签名
|
|
|
|
|
|
if (name.endsWith(".dmg.sig")) {
|
|
|
|
|
|
const sig = await getSignature(browser_download_url);
|
|
|
|
|
|
if (name.includes("aarch64") || name.includes("arm64")) {
|
|
|
|
|
|
updateData.platforms["darwin-aarch64"].signature = sig;
|
|
|
|
|
|
} else if (name.includes("x86_64") || name.includes("intel")) {
|
|
|
|
|
|
updateData.platforms.darwin.signature = sig;
|
|
|
|
|
|
updateData.platforms["darwin-intel"].signature = sig;
|
|
|
|
|
|
updateData.platforms["darwin-x86_64"].signature = sig;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 仍然保留对 AppImage 的支持,以防将来使用
|
|
|
|
|
|
if (name.endsWith(".AppImage")) {
|
|
|
|
|
|
// 根据文件名确定架构
|
|
|
|
|
|
if (name.includes("x86_64")) {
|
|
|
|
|
|
updateData.platforms.linux.url = browser_download_url;
|
|
|
|
|
|
updateData.platforms["linux-x86_64"].url = browser_download_url;
|
|
|
|
|
|
} else if (name.includes("i686")) {
|
|
|
|
|
|
updateData.platforms["linux-i686"].url = browser_download_url;
|
|
|
|
|
|
updateData.platforms["linux-x86"].url = browser_download_url;
|
|
|
|
|
|
} else if (name.includes("aarch64")) {
|
|
|
|
|
|
updateData.platforms["linux-aarch64"].url = browser_download_url;
|
|
|
|
|
|
} else if (name.includes("armv7")) {
|
|
|
|
|
|
updateData.platforms["linux-armv7"].url = browser_download_url;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (name.endsWith(".AppImage.sig")) {
|
|
|
|
|
|
const sig = await getSignature(browser_download_url);
|
|
|
|
|
|
|
|
|
|
|
|
// 根据文件名确定架构
|
|
|
|
|
|
if (name.includes("x86_64")) {
|
|
|
|
|
|
updateData.platforms.linux.signature = sig;
|
|
|
|
|
|
updateData.platforms["linux-x86_64"].signature = sig;
|
|
|
|
|
|
} else if (name.includes("i686")) {
|
|
|
|
|
|
updateData.platforms["linux-i686"].signature = sig;
|
|
|
|
|
|
updateData.platforms["linux-x86"].signature = sig;
|
|
|
|
|
|
} else if (name.includes("aarch64")) {
|
|
|
|
|
|
updateData.platforms["linux-aarch64"].signature = sig;
|
|
|
|
|
|
} else if (name.includes("armv7")) {
|
|
|
|
|
|
updateData.platforms["linux-armv7"].signature = sig;
|
|
|
|
|
|
}
|
2022-03-19 10:50:44 +08:00
|
|
|
|
}
|
2022-01-19 00:42:37 +08:00
|
|
|
|
});
|
2022-02-22 01:56:06 +08:00
|
|
|
|
|
2025-02-27 17:19:04 +08:00
|
|
|
|
// 在处理完所有assets后,确保旧格式平台数据与新格式一致
|
2022-02-22 01:56:06 +08:00
|
|
|
|
await Promise.allSettled(promises);
|
2025-02-27 17:19:04 +08:00
|
|
|
|
|
|
|
|
|
|
console.log("同步新旧格式数据...");
|
|
|
|
|
|
|
|
|
|
|
|
// 明确同步新旧格式数据
|
|
|
|
|
|
// Windows
|
|
|
|
|
|
if (updateData.platforms["windows-x86_64"].url) {
|
|
|
|
|
|
console.log("同步 win64 与 windows-x86_64 数据");
|
|
|
|
|
|
updateData.platforms.win64.url = updateData.platforms["windows-x86_64"].url;
|
|
|
|
|
|
updateData.platforms.win64.signature =
|
|
|
|
|
|
updateData.platforms["windows-x86_64"].signature;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Linux
|
|
|
|
|
|
if (updateData.platforms["linux-x86_64"].url) {
|
|
|
|
|
|
console.log("同步 linux 与 linux-x86_64 数据");
|
|
|
|
|
|
updateData.platforms.linux.url = updateData.platforms["linux-x86_64"].url;
|
|
|
|
|
|
updateData.platforms.linux.signature =
|
|
|
|
|
|
updateData.platforms["linux-x86_64"].signature;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// macOS
|
|
|
|
|
|
if (updateData.platforms["darwin-x86_64"].url) {
|
|
|
|
|
|
console.log("同步 darwin 与 darwin-x86_64 数据");
|
|
|
|
|
|
updateData.platforms.darwin.url = updateData.platforms["darwin-x86_64"].url;
|
|
|
|
|
|
updateData.platforms.darwin.signature =
|
|
|
|
|
|
updateData.platforms["darwin-x86_64"].signature;
|
|
|
|
|
|
} else if (updateData.platforms["darwin-aarch64"].url) {
|
|
|
|
|
|
console.log("同步 darwin 与 darwin-aarch64 数据");
|
|
|
|
|
|
updateData.platforms.darwin.url =
|
|
|
|
|
|
updateData.platforms["darwin-aarch64"].url;
|
|
|
|
|
|
updateData.platforms.darwin.signature =
|
|
|
|
|
|
updateData.platforms["darwin-aarch64"].signature;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log("平台数据同步完成,删除空平台数据...");
|
2022-02-22 01:56:06 +08:00
|
|
|
|
console.log(updateData);
|
|
|
|
|
|
|
2022-04-05 23:19:54 +08:00
|
|
|
|
Object.entries(updateData.platforms).forEach(([key, value]) => {
|
|
|
|
|
|
if (!value.url) {
|
2025-02-27 17:19:04 +08:00
|
|
|
|
console.log(`[Error]: 无法解析平台 "${key}" 的发布资产`);
|
2022-04-05 23:19:54 +08:00
|
|
|
|
delete updateData.platforms[key];
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-03-19 11:14:12 +08:00
|
|
|
|
|
2025-02-27 17:19:04 +08:00
|
|
|
|
// 显示最终平台数据
|
|
|
|
|
|
console.log("最终平台数据:");
|
|
|
|
|
|
Object.keys(updateData.platforms).forEach((key) => {
|
|
|
|
|
|
console.log(`- ${key}: ${updateData.platforms[key].url ? "有效" : "无效"}`);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2022-03-19 11:14:12 +08:00
|
|
|
|
// 生成一个代理github的更新文件
|
|
|
|
|
|
// 使用 https://hub.fastgit.xyz/ 做github资源的加速
|
|
|
|
|
|
const updateDataNew = JSON.parse(JSON.stringify(updateData));
|
|
|
|
|
|
|
2025-02-27 17:19:04 +08:00
|
|
|
|
console.log("处理代理更新文件...");
|
2022-04-05 23:19:54 +08:00
|
|
|
|
Object.entries(updateDataNew.platforms).forEach(([key, value]) => {
|
|
|
|
|
|
if (value.url) {
|
2023-11-22 02:56:47 +08:00
|
|
|
|
updateDataNew.platforms[key].url =
|
2024-08-24 02:02:17 +08:00
|
|
|
|
"https://download.clashverge.dev/" + value.url;
|
2022-03-19 11:14:12 +08:00
|
|
|
|
} else {
|
2025-02-27 17:19:04 +08:00
|
|
|
|
console.log(`[警告]: updateDataNew.platforms.${key} 为空`);
|
2022-03-19 11:14:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-02-22 01:56:06 +08:00
|
|
|
|
|
|
|
|
|
|
// update the update.json
|
|
|
|
|
|
const { data: updateRelease } = await github.rest.repos.getReleaseByTag({
|
|
|
|
|
|
...options,
|
|
|
|
|
|
tag: UPDATE_TAG_NAME,
|
2022-01-19 00:37:59 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2022-03-19 11:14:12 +08:00
|
|
|
|
// delete the old assets
|
2022-02-22 01:56:06 +08:00
|
|
|
|
for (let asset of updateRelease.assets) {
|
|
|
|
|
|
if (asset.name === UPDATE_JSON_FILE) {
|
2022-01-19 00:37:59 +08:00
|
|
|
|
await github.rest.repos.deleteReleaseAsset({
|
2022-02-22 01:56:06 +08:00
|
|
|
|
...options,
|
2022-01-19 00:37:59 +08:00
|
|
|
|
asset_id: asset.id,
|
|
|
|
|
|
});
|
2022-03-19 11:14:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (asset.name === UPDATE_JSON_PROXY) {
|
|
|
|
|
|
await github.rest.repos
|
|
|
|
|
|
.deleteReleaseAsset({ ...options, asset_id: asset.id })
|
|
|
|
|
|
.catch(console.error); // do not break the pipeline
|
2022-01-19 00:37:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-05 23:19:54 +08:00
|
|
|
|
// upload new assets
|
2022-01-19 00:37:59 +08:00
|
|
|
|
await github.rest.repos.uploadReleaseAsset({
|
2022-02-22 01:56:06 +08:00
|
|
|
|
...options,
|
|
|
|
|
|
release_id: updateRelease.id,
|
|
|
|
|
|
name: UPDATE_JSON_FILE,
|
2022-01-19 00:37:59 +08:00
|
|
|
|
data: JSON.stringify(updateData, null, 2),
|
|
|
|
|
|
});
|
2022-03-19 11:14:12 +08:00
|
|
|
|
|
|
|
|
|
|
await github.rest.repos.uploadReleaseAsset({
|
|
|
|
|
|
...options,
|
|
|
|
|
|
release_id: updateRelease.id,
|
|
|
|
|
|
name: UPDATE_JSON_PROXY,
|
|
|
|
|
|
data: JSON.stringify(updateDataNew, null, 2),
|
|
|
|
|
|
});
|
2022-01-19 00:37:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-22 01:56:06 +08:00
|
|
|
|
// get the signature file content
|
|
|
|
|
|
async function getSignature(url) {
|
|
|
|
|
|
const response = await fetch(url, {
|
|
|
|
|
|
method: "GET",
|
|
|
|
|
|
headers: { "Content-Type": "application/octet-stream" },
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return response.text();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-05 23:19:54 +08:00
|
|
|
|
resolveUpdater().catch(console.error);
|