Skip to content

Commit 4854df0

Browse files
committed
新增:MacOS 打包使用官方证书
1 parent c4cabe4 commit 4854df0

5 files changed

Lines changed: 32 additions & 10 deletions

File tree

.github/workflows/main-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ jobs:
5454
run: npm run build
5555
env:
5656
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
APPLE_ID: ${{ secrets.APPLE_ID }}
58+
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
59+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
5760

5861
- name: Set Build Name ( Linux / macOS )
5962
if: runner.os == 'Linux' || runner.os == 'macOS'

.github/workflows/tag-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353
run: npm run build
5454
env:
5555
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
APPLE_ID: ${{ secrets.APPLE_ID }}
57+
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
58+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
5659

5760
- name: Release Assets
5861
uses: softprops/action-gh-release@v2

electron-builder.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,5 @@
181181
}
182182
]
183183
},
184-
// "afterSign": "./scripts/notarize.cjs",
184+
"afterSign": "./scripts/notarize.cjs",
185185
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"vite-plugin-electron-renderer": "^0.14.5",
5151
"vite-plugin-html": "^3.2.2",
5252
"vue": "^3.4.21",
53-
"vue-tsc": "^2.0.6"
53+
"vue-tsc": "^2.0.6",
54+
"@electron/notarize": "^2.5.0"
5455
},
5556
"dependencies": {
5657
"@babel/runtime": "^7.24.8",

scripts/notarize.cjs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
1-
const {notarize} = require('electron-notarize');
1+
const {notarize} = require("@electron/notarize");
22

33
exports.default = async function notarizing(context) {
4+
const appName = context.packager.appInfo.productFilename;
45
const {electronPlatformName, appOutDir} = context;
5-
6-
if (electronPlatformName !== 'darwin') {
6+
// We skip notarization if the process is not running on MacOS and
7+
// if the enviroment variable SKIP_NOTARIZE is set to `true`
8+
// This is useful for local testing where notarization is useless
9+
if (
10+
electronPlatformName !== "darwin" ||
11+
process.env.SKIP_NOTARIZE === "true"
12+
) {
13+
console.log(` • Skipping notarization`);
714
return;
815
}
916

10-
const appName = context.packager.appInfo.productFilename;
17+
// THIS MUST BE THE SAME AS THE `appId` property
18+
// in your electron builder configuration
19+
const appId = "FocusAny";
20+
21+
let appPath = `${appOutDir}/${appName}.app`;
22+
let {APPLE_ID, APPLE_ID_PASSWORD, APPLE_TEAM_ID} = process.env;
23+
console.log(` • Notarizing ${appPath}`);
1124

1225
return await notarize({
13-
appBundleId: 'com.focusany',
14-
appPath: `${appOutDir}/${appName}.app`,
15-
appleId: 'your-apple-id@example.com',
16-
appleIdPassword: 'your-app-specific-password',
26+
tool: "notarytool",
27+
appBundleId: appId,
28+
appPath,
29+
appleId: APPLE_ID,
30+
appleIdPassword: APPLE_ID_PASSWORD,
31+
teamId: APPLE_TEAM_ID,
1732
});
1833
};

0 commit comments

Comments
 (0)