allow manual triggering of builds

bump action versions
add token reference for electron build
add release workflow
add links for windows replacements
add helper for github build workflow
align asset names with build artifact names
produce zip artifacts from electron build
change artifact name to KiriMoto and add array build target
add mac app signing
add electron app icons
add links.csv helper
add dryrun cache build and integration into electron app for faster startup
allow windows install alt location. suppress gdpr on localhost / built apps
This commit is contained in:
Stewart Allen 2024-06-14 17:48:01 -04:00
commit b526bec87e
18 changed files with 372 additions and 59 deletions

BIN
bin/GS.icns Normal file

Binary file not shown.

BIN
bin/GS.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

BIN
bin/GS.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.debugger</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<false/>
<key>com.apple.security.inherit</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

24
bin/electron-notarize.js Normal file
View file

@ -0,0 +1,24 @@
require('dotenv').config();
const { notarize } = require('@electron/notarize');
exports.default = async function notarizing(context) {
const { electronPlatformName, appOutDir } = context;
if (process.env.SKIPNOT || electronPlatformName !== 'darwin') {
return;
}
const appName = context.packager.appInfo.productFilename;
console.log(' ** notarizing:', appName);
const result = await notarize({
appBundleId: 'space.grid.kiri',
appPath: `${appOutDir}/${appName}.app`,
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
});
console.log(' ** notarizing complete:', result || 'no process output');
};

17
bin/electron-post.js Normal file
View file

@ -0,0 +1,17 @@
const fs = require('fs-extra');
async function removeDirectory(dirPath) {
try {
await fs.remove(dirPath);
console.log('Directory removed successfully!');
} catch (err) {
console.error('Error removing directory:', err);
}
}
async function main() {
console.log('npm post running');
await removeDirectory("tmp");
}
main().catch(err => console.error('Error', err));

16
bin/electron-pre.js Normal file
View file

@ -0,0 +1,16 @@
const fs = require('fs-extra');
const path = require('path');
const server = require('@gridspace/app-server');
// deref src and web for windows
const srcTmp = path.join('tmp','src');
fs.copySync("src", srcTmp, { dereference: true });
const webTmp = path.join('tmp','web');
fs.copySync("web", webTmp, { dereference: true });
// pre-build asset cache
server({
dryrun: true,
single: true
});

18
bin/github-getver.js Normal file
View file

@ -0,0 +1,18 @@
// create version for release for github build workflow
const fs = require('fs');
const type = process.argv[2];
if (type && process.env.GITHUB_ENV) {
const pkgVer = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
const rando = ((Math.random() * 0xfff) & 0xfff).toString().padStart(4,0);
const releaseTag =
type === 'workflow_dispatch' ? `${pkgVer}.${rando}` :
type === 'push' ? pkgVer :
(`rogue-` + ( (Math.random() * 0xfffff) & 0xfffff ))
console.log({ type, version: pkgVer, releaseTag });
// write version to GITHUB_ENV file
fs.appendFileSync(process.env.GITHUB_ENV, `TAG_NAME=${releaseTag}\n`);
}

81
bin/install-pre.js Normal file
View file

@ -0,0 +1,81 @@
const os = require('os');
const fs = require('fs-extra');
const fetchr = import('node-fetch');
const path = require('path');
async function download(url, filePath) {
const fetch = (await fetchr).default;
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: ${response.statusText}`);
}
fs.ensureDir(path.dirname(filePath));
const fileStream = fs.createWriteStream(filePath);
return new Promise((resolve, reject) => {
response.body.pipe(fileStream);
response.body.on('error', reject);
fileStream.on('error', error => {
console.log({ error });
});
fileStream.on('finish', () => {
resolve();
});
});
}
async function main() {
console.log('npm pre running');
await download(
"https://static.grid.space/gapp/manifold.js",
path.join("src", "ext", "manifold.js")
);
await download(
"https://static.grid.space/gapp/manifold.wasm",
path.join("src", "wasm", "manifold.wasm")
);
const links = fs.readFileSync("links.csv")
.toString()
.trim()
.split('\n')
.map(line => line.trim())
.map(line => line.split(',').map(v => v.trim()));
if (os.platform() === 'win32')
for (let [link, target] of links) {
const absoluteTarget = path.resolve(path.dirname(link), target);
// console.log({ link, target, absoluteTarget });
try {
// Remove existing link if it exists
// if (fs.existsSync(link)) {
// console.log({ unlink: link });
// fs.unlinkSync(link);
// } else {
// console.log('no file', link);
// }
console.log({ win32_replace: link });
await fs.remove(link).catch(error => console.log({ remove_error: error }));
// console.log({ copy: absoluteTarget, to: link });
await fs.copy(absoluteTarget, link, { dereference: true }).catch(error => console.log({ copy_error: error }));
// const targetStats = fs.lstatSync(absoluteTarget);
// let type = targetStats.isDirectory() ? 'junction' : 'file';
// // Create the symlink
// console.log(`relink: ${link} as ${type}`);
// fs.symlinkSync(absoluteTarget, link, type);
} catch (err) {
// console.error(`Error creating symlink: ${link} -> ${target}`, err);
console.error(`Error creating symlink: ${link} -> ${absoluteTarget}`, err);
}
}
}
main().catch(err => console.error('Error', err));

View file

@ -1,4 +0,0 @@
#!/bin/sh
[ -d tmp ] && rm -rf tmp

View file

@ -1,5 +0,0 @@
#!/bin/sh
( curl https://static.grid.space/gapp/manifold.js > src/ext/manifold.js ) > /dev/null 2>&1
( curl https://static.grid.space/gapp/manifold.wasm > src/wasm/manifold.wasm ) > /dev/null 2>&1