diff --git a/README_PUBLISH.md b/README_PUBLISH.md index 78cb7e793..e788061e7 100644 --- a/README_PUBLISH.md +++ b/README_PUBLISH.md @@ -3,7 +3,7 @@ ## 发布前 1. 添加环境变量 `APPLEID`、`APPLEIDPASS`、`CSC_LINK` -2. 发布GitHub还需要添加 `GH_PAT` +2. 发布GitHub还需要添加 `GH_TOKEN` 3. 发布私有服务器还需要添加 `DP_KEY` ## 通过 GitHub Actions 发布 diff --git a/electron/build.js b/electron/build.js index 9d7b67f3b..94f1825fd 100644 --- a/electron/build.js +++ b/electron/build.js @@ -176,22 +176,28 @@ function startBuild(data, publish, release) { if (publish !== true || !process.env.APPLEID || !process.env.APPLEIDPASS) { delete econfig.build.afterSign; } + if (publish === true && process.env.GITHUB_REPOSITORY) { + // publish github package config + let repository = process.env.GITHUB_REPOSITORY.split("/") + econfig.build.publish = { + "provider": "github", + "owner": repository[0], + "repo": repository[1] + } + } fs.writeFileSync(packageFile, JSON.stringify(econfig, null, 2), 'utf8'); // build child_process.spawnSync("npm" + comSuffix, ["run", data.platform], {stdio: "inherit", cwd: "electron"}); // package.json Recovery fse.copySync(packageBakFile, packageFile) - // publish - if (publish === true) { - // generic - if (process.env.DP_KEY) { - genericPublish({ - url: data.publish, - key: process.env.DP_KEY, - version: config.version, - output: econfig.build.directories.output - }) - } + // publish generic method + if (publish === true && process.env.DP_KEY) { + genericPublish({ + url: data.publish, + key: process.env.DP_KEY, + version: config.version, + output: econfig.build.directories.output + }) } } diff --git a/electron/package.json b/electron/package.json index 24d37729a..c44967180 100644 --- a/electron/package.json +++ b/electron/package.json @@ -73,7 +73,7 @@ ], "npmRebuild": false, "publish": { - "provider": "github" + "provider": "generic" }, "releaseInfo": {}, "afterSign": "./notarize.js",