From b67d531ce0727cc49e162dba61e47d8bc83a6a60 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Fri, 25 Nov 2022 16:03:12 +0800 Subject: [PATCH] feat: provide macos arm m1 package and sign it --- .github/workflows/release.yml | 17 ++++++++--------- package.json | 1 + scripts/afterPack.js | 10 ++++++++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80db4628..61654e1e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -125,15 +125,14 @@ jobs: CI: true CI_PULL_REQUEST: ${{ github.event_name == 'pull_request' }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Seems M1 can use x64 package, but arm package will show its broken - # - name: Make macOS (arm64) - # run: npm run make:mac-arm - # env: - # APPLE_ID: ${{ secrets.APPLE_ID }} - # APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - # CI: true - # CI_PULL_REQUEST: ${{ github.event_name == 'pull_request' }} - # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Make macOS (arm64) + run: npm run make:mac-arm + env: + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} + CI: true + CI_PULL_REQUEST: ${{ github.event_name == 'pull_request' }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create Release uses: softprops/action-gh-release@v1 diff --git a/package.json b/package.json index 7d43c8ba..17c4fbcb 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "test-without-package": "mkdir -p logs && cross-env NODE_ENV=test cucumber-js", "package": "npm run init:git-submodule && electron-forge package", "make:mac-x64": "npm run init:git-submodule && cross-env NODE_ENV=production electron-forge make --platform=darwin --arch=x64", + "make:mac-arm": "npm run init:git-submodule && cross-env NODE_ENV=production electron-forge make --platform=darwin --arch=arm64", "make:win-x64": "npm run init:git-submodule && cross-env NODE_ENV=production electron-forge make --platform=win32 --arch=x64", "make:win-ia32": "npm run init:git-submodule && cross-env NODE_ENV=production electron-forge make --platform=win32 --arch=ia32", "make:win-arm": "npm run init:git-submodule && cross-env NODE_ENV=production electron-forge make --platform=win32 --arch=arm64", diff --git a/scripts/afterPack.js b/scripts/afterPack.js index bfd5bee5..e15702c8 100644 --- a/scripts/afterPack.js +++ b/scripts/afterPack.js @@ -23,8 +23,10 @@ const keepingLprojRegEx = /(en|zh_CN)\.lproj/g; * @returns */ exports.default = async (buildPath, electronVersion, platform, arch, callback) => { - const cwd = path.join(buildPath, '..'); - const projectRoot = path.join(__dirname, '..'); + const cwd = path.resolve(buildPath, '..'); + const projectRoot = path.resolve(__dirname, '..'); + const appParentPath = path.resolve(buildPath, '..', '..', '..', '..'); + const appPath = path.join(appParentPath, 'Electron.app'); /** delete useless lproj files to make it clean */ const lproj = glob.sync('*.lproj', { cwd }); @@ -48,6 +50,10 @@ exports.default = async (buildPath, electronVersion, platform, arch, callback) = await exec(`npm i --legacy-building`, { cwd: path.join(cwd, 'node_modules', 'zx', 'node_modules', 'globby') }); await exec(`npm i --legacy-building --ignore-scripts`, { cwd: path.join(cwd, 'node_modules', 'zx', 'node_modules', 'node-fetch') }); } + /** sign it for mac m1 https://www.zhihu.com/question/431722091/answer/1592339574 */ + if (platform === 'darwin') { + await exec(`xattr -rd com.apple.quarantine ${appPath}`, { cwd: appParentPath }); + } /** complete this hook */ callback(); };