Skip to content

Commit

Permalink
fix: bulid process
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Sep 27, 2024
1 parent 0778271 commit 8a263cd
Show file tree
Hide file tree
Showing 18 changed files with 674 additions and 681 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
app:
permissions:
contents: write

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -76,6 +80,10 @@ jobs:
run: yarn && yarn build:dist
working-directory: ../platform

- name: Enable Corepack
if: ${{ matrix.os == 'windows-latest' }}
run: corepack enable

- name: Allow yarn to adjust lockfile
run: yarn config set enableImmutableInstalls false

Expand All @@ -86,28 +94,32 @@ jobs:
if: ${{ github.event.inputs.importProject }}
run: yarn sync:repos:dist && yarn sync:build

- name: List packages
run: ls -la packages && ls -lart node_modules/@ulixee
shell: bash

- name: Build Project
run: yarn build

- run: mkdir ~/.private_keys && echo "$APPLE_NOTARIZE_KEY" > ~/.private_keys/AuthKey_5VH6PQ3585.p8
- run: |
mkdir ~/.private_keys
echo "$APPLE_NOTARIZE_KEY" > ~/.private_keys/AuthKey_27VRA75WCS.p8
chmod 600 ~/.private_keys/AuthKey_27VRA75WCS.p8
if: ${{ matrix.os == 'macos-latest' }}
shell: bash
env:
APPLE_NOTARIZE_KEY: ${{secrets.APPLE_NOTARIZE_KEY}}
- name: Build Desktop
run: yarn electron-builder --publish onTagOrDraft
env:
NODE_ENV: production
USE_HARD_LINKS: false
force_no_cache: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_IDENTITY_AUTO_DISCOVERY: ${{ github.event.inputs.skipSigning != true }}
CSC_LINK: ${{ matrix.os == 'windows-latest' && secrets.WIN_CSC_LINK || secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ matrix.os == 'windows-latest' && secrets.WIN_CSC_KEY_PASSWORD || secrets.CSC_KEY_PASSWORD }}
APPLE_API_KEY: ~/.private_keys/AuthKey_5VH6PQ3585.p8
APPLE_API_KEY_ID: 5VH6PQ3585
APPLE_API_ISSUER: a89474ed-637f-4cf0-8429-da45ef388882
CSC_IDENTITY_AUTO_DISCOVERY: ${{ github.event.inputs.skipSigning != 'true' }}
CSC_LINK: "${{ matrix.os == 'windows-latest' && secrets.WIN_CSC_LINK || secrets.CSC_LINK }}"
CSC_KEY_PASSWORD: "${{ matrix.os == 'windows-latest' && secrets.WIN_CSC_KEY_PASSWORD || secrets.CSC_KEY_PASSWORD }}"
DEBUG: electron-notarize:*

- name: Upload App
if: startsWith(github.ref, 'refs/tags/v') == false || failure()
Expand Down
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
nodeLinker: node-modules
supportedArchitectures:
cpu: ['current', 'x64', 'arm64']
Binary file added build-resources/IconTemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build-resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build-resources/arg.icns
Binary file not shown.
Binary file added build-resources/arg.ico
Binary file not shown.
Binary file added build-resources/arg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified build-resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions electron-builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
const { notarize } = require('@electron/notarize');
const binary = require('binary-info');
const { Arch } = require('electron-builder');
const { fdir } = require('fdir');
const { execSync } = require('node:child_process');
const { unlinkSync } = require('node:fs');
const Path = require('path');

module.exports = {
appId: 'dev.ulixee.desktop',
productName: 'Ulixee',
directories: {
buildResources: 'build-resources',
},
files: [
'package.json',
'!packages/**',
'!dist',
'main/**',
'ui/**',
'resources/*',
'!.vscode',
'!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme}',
'!**/node_modules/*/{test,__tests__,tests,powered-test,example,examples}',
'!**/node_modules/*.d.ts',
'!**/node_modules/.bin',
],
// asar: false,
asarUnpack: ['resources/**', 'ui/**', '**/*.node', '**/connect'],
npmRebuild: true,
nativeRebuilder: 'parallel',
mac: {
defaultArch: 'arm64',
category: 'public.app-category.developer-tools',
target: {
target: 'default',
arch: ['x64', 'arm64'],
},
hardenedRuntime: true,
gatekeeperAssess: false,
extendInfo: {
LSUIElement: 1,
},
entitlements: 'build-resources/entitlements.mac.plist',
entitlementsInherit: 'build-resources/entitlements.mac.plist',
notarize: false, // do this manually
},
win: {
target: 'NSIS',
},
linux: {
category: 'Development',
target: 'AppImage',
},
publish: {
provider: 'github',
releaseType: 'release',
},
fileAssociations: [
{
ext: 'argon',
name: 'ARGON',
description: 'Argon Cash',
icon: 'arg',
rank: 'Owner',
},
],
async beforePack(context) {
const path = require.resolve('@ulixee/unblocked-agent-mitm-socket/install.js');
console.log('Running install script', path);
execSync(`node install.js`, {
cwd: Path.dirname(path),
stdio: 'inherit',
env: {
...process.env,
npm_config_target_arch: Arch[context.arch],
npm_config_target_platform: context.electronPlatformName,
npm_config_cpu: Arch[context.arch],
npm_config_os: context.electronPlatformName,
},
});
},
async afterPack(context) {
console.log('Removing incompatible binaries', context.appOutDir);
const dirs = new fdir()
.withFullPaths()
.filter(path => binary.isIncompatible(path, context.electronPlatformName, Arch[context.arch]))
.crawl(context.appOutDir)
.sync();
for (const file of dirs) {
try {
unlinkSync(file);
console.log('Deleted incompatible binary', file.split(Path.sep).slice(-2).join(Path.sep));
} catch (e) {
console.error('Unable to delete file', file, e);
}
}
},
async afterSign(context) {
const { electronPlatformName, appOutDir } = context;

if (
electronPlatformName !== 'darwin' ||
process.env.SKIP_NOTARIZE ||
process.env.CSC_IDENTITY_AUTO_DISCOVERY === 'false'
) {
return;
}

const appName = context.packager.appInfo.productFilename;

return await notarize({
tool: 'notarytool',
appPath: `${appOutDir}/${appName}.app`,
appleApiKey: '~/.private_keys/AuthKey_27VRA75WCS.p8',
appleApiKeyId: '27VRA75WCS',
appleApiIssuer: 'a89474ed-637f-4cf0-8429-da45ef388882',
// teamId: 'DY8K483XWV',
});
},
};
71 changes: 0 additions & 71 deletions electron-builder.json5

This file was deleted.

22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.0.0-alpha.29",
"description": "This is a builder project that uses the dual package.json approach (./app contains the app package.json).",
"private": true,
"author": "Ulixee Foundation",
"main": "./main/index.js",
"type": "commonjs",
"license": "MIT",
Expand All @@ -18,18 +19,16 @@
"build": "yarn typecheck && yarn build:run",
"build:deps": "electron-builder install-app-deps",
"build:run": "vite build --config vite.config.ts",
"build:unpack": "yarn build && CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder --dir",
"build:win": "yarn build && electron-builder --win",
"build:mac": "yarn build && electron-builder --mac",
"build:linux": "yarn build && electron-builder --linux",
"dist:unpack": "yarn build && CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder --dir",
"dist:local": "shx rm -rf ~/.cache/config-file-ts && PYTHON=python3.10 electron-builder",
"sync": "yarn sync:repos && yarn sync:build",
"sync:build": "shx rm -rf node_modules/@ulixee && yarn install --refresh-lockfile",
"sync:build": "rm yarn.lock && yarn install --check-resolutions",
"sync:repos": "NODE_OPTIONS=\"-r ts-node/register --no-warnings\" node scripts/importMonorepo.ts",
"sync:repos:dist": "yarn sync:repos build-dist",
"unpack:asar": "npx @electron/asar extract dist/mac-arm64/Ulixee.app/Contents/Resources/app.asar dist/mac-arm64/app_unpacked"
"unpack:asar": "npx @electron/asar extract dist/mac/Ulixee.app/Contents/Resources/app.asar dist/mac/app_unpacked"
},
"dependencies": {
"@argonprotocol/localchain": "0.0.8",
"@argonprotocol/localchain": "^0.0.8",
"@electron-toolkit/preload": "^3.0.0",
"@ulixee/cloud": "2.0.0-alpha.29",
"@ulixee/commons": "2.0.0-alpha.29",
Expand All @@ -45,6 +44,7 @@
"@ulixee/net": "2.0.0-alpha.29",
"@ulixee/platform-specification": "2.0.0-alpha.29",
"@ulixee/platform-utils": "2.0.0-alpha.29",
"@ulixee/unblocked-agent-mitm-socket": "^2.0.0-alpha.29",
"@ulixee/unblocked-specification": "2.0.0-alpha.29",
"better-sqlite3": "^11.1.2",
"electron-log": "^5.1.7",
Expand All @@ -61,6 +61,7 @@
"@electron-toolkit/eslint-config-ts": "^2.0.0",
"@electron-toolkit/tsconfig": "^1.0.1",
"@electron/asar": "^3.2.13",
"@electron/notarize": "^2.5.0",
"@headlessui/vue": "^1.7.17",
"@heroicons/vue": "^2.1.1",
"@rushstack/eslint-patch": "^1.10.3",
Expand All @@ -75,11 +76,13 @@
"@vue/eslint-config-typescript": "^13.0.0",
"@webcomponents/custom-elements": "^1.6.0",
"autoprefixer": "^10.4.17",
"binary-info": "^0.1.0",
"electron": "^32.1.0",
"electron-builder": "25.0.5",
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vue": "^9.26.0",
"fdir": "^6.3.0",
"magic-string": "^0.30.11",
"moment": "^2.29.4",
"pinia": "^2.1.7",
Expand Down Expand Up @@ -117,5 +120,8 @@
},
"swc": true
},
"packageManager": "[email protected]"
"resolutions": {
"@electron/notarize": "2.5.0"
},
"packageManager": "[email protected]"
}
16 changes: 11 additions & 5 deletions scripts/importMonorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ function copyDir(baseDir: string, outPath?: string): void {
if (!Fs.existsSync(packageDir)) Fs.mkdirSync(packageDir, { recursive: true });
if (dirOrFile === 'package.json') {
const finalPackageJson = {
name: packageJson.name,
version: packageJson.version,
dependencies: packageJson.dependencies,
...packageJson,
devDependencies: {},
};
Fs.writeFileSync(`${packageDir}/${dirOrFile}`, JSON.stringify(finalPackageJson, null, 2));
continue;
Expand All @@ -90,12 +89,14 @@ if (!existsSync(pathToPlatform)) {
}

const buildDir = process.argv[2] ?? 'build';
console.log('Importing Platform into Desktop, out=', buildDir);
if (!existsSync(Path.join(pathToPlatform, buildDir))) {
throw new Error(`The build directory does not exist: ${buildDir}`);
}
const baseBuild = Path.join(pathToPlatform, buildDir);
copyDir(baseBuild);
if (buildDir === 'build' && existsSync(Path.join(pathToHero, buildDir))) {
if (existsSync(Path.join(pathToHero, buildDir))) {
console.log('Importing Hero into Desktop, out=', buildDir);
copyDir(Path.join(pathToHero, buildDir));
// copyDir(`${baseBuild}/../mainchain/localchain`);
copyDir(`${pathToHero}/browser-emulator-builder/data`, `${dest}/default-browser-emulator/data`);
Expand All @@ -113,5 +114,10 @@ if (buildDir === 'build' && existsSync(Path.join(pathToHero, buildDir))) {
);
}

const chromeVersions = resolve(__dirname, '../../chrome-versions');
if (existsSync(chromeVersions)) {
copyDir(Path.join(chromeVersions, 'packages', 'chrome-app'), `${dest}/chrome-app`);
}

// eslint-disable-next-line no-console
console.log('Copied files to dest');
console.log(`Copied files to ${dest}`);
Loading

0 comments on commit 8a263cd

Please sign in to comment.