chore: alpha release add portable

This commit is contained in:
GyDi 2022-11-22 00:16:30 +08:00
parent 10f3ba4ff4
commit e4e16999c8
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A
2 changed files with 11 additions and 60 deletions

View File

@ -78,9 +78,10 @@ jobs:
includeDebug: ${{ github.event.inputs.debug }} includeDebug: ${{ github.event.inputs.debug }}
prerelease: true prerelease: true
# - name: Portable Bundle - name: Portable Bundle
# if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
# run: | run: |
# yarn run portable yarn run portable
# env: env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG_NAME: alpha
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -4,8 +4,6 @@ import AdmZip from "adm-zip";
import { createRequire } from "module"; import { createRequire } from "module";
import { getOctokit, context } from "@actions/github"; import { getOctokit, context } from "@actions/github";
const META = process.argv.includes("--meta"); // use Clash.Meta
/// Script for ci /// Script for ci
/// 打包绿色版/便携版 (only Windows) /// 打包绿色版/便携版 (only Windows)
async function resolvePortable() { async function resolvePortable() {
@ -41,9 +39,11 @@ async function resolvePortable() {
const options = { owner: context.repo.owner, repo: context.repo.repo }; const options = { owner: context.repo.owner, repo: context.repo.repo };
const github = getOctokit(process.env.GITHUB_TOKEN); const github = getOctokit(process.env.GITHUB_TOKEN);
console.log("[INFO]: upload to ", process.env.TAG_NAME || `v${version}`);
const { data: release } = await github.rest.repos.getReleaseByTag({ const { data: release } = await github.rest.repos.getReleaseByTag({
...options, ...options,
tag: `v${version}`, tag: process.env.TAG_NAME || `v${version}`,
}); });
console.log(release.name); console.log(release.name);
@ -56,54 +56,4 @@ async function resolvePortable() {
}); });
} }
/// 打包包含Clash.Meta的 (only Windows) resolvePortable().catch(console.error);
async function resolvePortableMeta() {
if (process.platform !== "win32") return;
const releaseDir = "./src-tauri/target/release";
if (!(await fs.pathExists(releaseDir))) {
throw new Error("could not found the release dir");
}
const zip = new AdmZip();
zip.addLocalFile(path.join(releaseDir, "Clash Verge.exe"));
zip.addLocalFile(path.join(releaseDir, "clash.exe"));
zip.addLocalFile(path.join(releaseDir, "clash-meta.exe"));
zip.addLocalFolder(path.join(releaseDir, "resources"), "resources");
const require = createRequire(import.meta.url);
const packageJson = require("../package.json");
const { version } = packageJson;
const zipFile = `Clash.Verge.Meta_${version}_x64_portable.zip`;
zip.writeZip(zipFile);
console.log("[INFO]: create portable zip successfully");
// push release assets
if (process.env.GITHUB_TOKEN === undefined) {
throw new Error("GITHUB_TOKEN is required");
}
const options = { owner: context.repo.owner, repo: context.repo.repo };
const github = getOctokit(process.env.GITHUB_TOKEN);
const { data: release } = await github.rest.repos.getReleaseByTag({
...options,
tag: `v${version}`,
});
console.log(release.name);
await github.rest.repos.uploadReleaseAsset({
...options,
release_id: release.id,
name: zipFile,
data: zip.toBuffer(),
});
}
if (META) resolvePortableMeta().catch(console.error);
else resolvePortable().catch(console.error);