Skip to content

Commit

Permalink
build(scripts): cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
elyukai committed Nov 6, 2023
1 parent 64c0fd1 commit d20e60b
Show file tree
Hide file tree
Showing 17 changed files with 323 additions and 368 deletions.
123 changes: 123 additions & 0 deletions build/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// @ts-check
import builder from "electron-builder"
import { notarize } from "./notarize.js"

const args = process.argv.slice(2)

// Detect channel

if (!args.includes("--stable") && !args.includes("--prerelease")) {
throw new TypeError(`Missing channel argument (either "--stable" or "--prerelease")`)
}

const isPrerelease = args.includes("--prerelease")

console.log(`Detected channel: ${isPrerelease ? "prerelease" : "stable"}`)

// Detect OS

let osKey
let osName

if (process.argv.includes("--linux") || process.platform === "linux") {
osKey = /** @type {const} */ ("LINUX")
osName = "Linux"
} else if (process.argv.includes("--mac") || process.platform === "darwin") {
osKey = /** @type {const} */ ("MAC")
osName = "macOS"
} else if (process.argv.includes("--win") || process.platform === "win32") {
osKey = /** @type {const} */ ("WINDOWS")
osName = "Windows"
} else {
throw new TypeError(`The target operating system cannot be inferred from the environment.`)
}

console.log(`Detected operating system: ${osName}`)

// Prepare electron-builder configuration

/**
* @type {import("electron-builder").Configuration}
*/
const config = {
appId: isPrerelease ? "com.lukasobermann.optolithinsider" : "com.lukasobermann.optolith",
productName: isPrerelease ? "Optolith Insider" : "Optolith",
copyright:
"© 2017–present Lukas Obermann. This product was created under a license. Das Schwarze Auge and its logo as well as Aventuria, Dere, Myranor, Riesland, Tharun and Uthuria and their logos are trademarks of Significant GbR. The title and contents of this book are protected under the copyright laws of the United States of America. No part of this publication may be reproduced, stored in retrieval systems or transmitted, in any form or by any means, whether electronic, mechanical, photocopy, recording, or otherwise, without prior written consent by Ulisses Spiele GmbH, Waldems. This publication includes material that is protected under copyright laws by Ulisses Spiele and/or other authors. Such material is used under the Community Content Agreement for the SCRIPTORIUM AVENTURIS. All other original materials in this work is copyright 2017-present by Lukas Obermann and published under the Community Content Agreement for the SCRIPTORIUM AVENTURIS.",
files: [
".webpack/**",
"LICENSE",
"node_modules/optolith-database-schema/schema/**",
"src/database/contents/cache/**",
"src/database/contents/Compatibility/**",
"src/database/contents/Data/**",
],
asar: false, // otherwise optolith-database-schema package is not properly resolved
asarUnpack: [
"node_modules/optolith-character-schema/**",
"node_modules/optolith-database-schema/**",
"src/database/contents/**",
],
directories: {
output: isPrerelease ? "dist/insider" : "dist",
},
win: {
target: [
{
target: "nsis",
arch: ["x64", "ia32"],
},
],
icon: isPrerelease ? "src/assets/icon/AppList.targetsize-512.pre.png" : "src/assets/icon/icon.ico",
artifactName: isPrerelease ? "OptolithInsiderSetup_${version}.${ext}" : "OptolithSetup_${version}.${ext}",
},
nsis: {
perMachine: true,
differentialPackage: true,
deleteAppDataOnUninstall: false,
},
linux: {
category: "RolePlaying",
target: [
{
target: "AppImage",
arch: ["x64"],
},
{
target: "tar.gz",
arch: ["x64"],
},
],
executableName: isPrerelease ? "OptolithInsider" : "Optolith",
icon: isPrerelease ? "src/assets/icon/icon.pre.png" : "src/assets/icon/AppList.targetsize-512.png",
artifactName: isPrerelease ? "OptolithInsider_${version}.${ext}" : "Optolith_${version}.${ext}",
},
mac: {
category: "public.app-category.role-playing-games",
type: "distribution",
target: [
{
target: "default",
arch: "universal",
},
],
icon: isPrerelease ? "src/assets/icon/AppIcon.pre.icns" : "src/assets/icon/AppIcon.icns",
artifactName: isPrerelease ? "OptolithInsider_${version}.${ext}" : "Optolith_${version}.${ext}",
mergeASARs: false,
darkModeSupport: true,
gatekeeperAssess: true,
},
publish: {
provider: "generic",
url: isPrerelease ? `${process.env.UPDATE_URL}/insider/\${os}` : `${process.env.UPDATE_URL}/\${os}`,
channel: "latest",
},
afterSign: osKey === "MAC" ? notarize : undefined,
}

await builder.build({
config,
targets: builder.Platform[osKey].createTarget(),
})

console.log(`Build finished successfully.`)
File renamed without changes.
10 changes: 10 additions & 0 deletions build/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?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.debugger</key>
<true/>
</dict>
</plist>
24 changes: 18 additions & 6 deletions deploy/notarize.js → build/notarize.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
// @ts-check
import { notarize as electronNotarize } from '@electron/notarize'
import { notarize as electronNotarize } from "@electron/notarize"

/**
* Notarizes the app package after it has been built. It detects the
* authentication method from the environment variables.
* @param context {import("electron-builder").AfterPackContext}
*/
export const notarize = async (context) => {
export const notarize = async context => {
const { electronPlatformName, appOutDir } = context

if (electronPlatformName === 'darwin') {
if (electronPlatformName === "darwin") {
const appName = context.packager.appInfo.productFilename

if (typeof process.env.APPLEID === "string" && typeof process.env.APPLEIDPASS === "string" && typeof process.env.TEAMID === "string") {
if (
typeof process.env.APPLEID === "string" &&
typeof process.env.APPLEIDPASS === "string" &&
typeof process.env.TEAMID === "string"
) {
console.log(`Notarizing "${appName}.app" via Apple ID ...`)
await electronNotarize({
tool: "notarytool",
Expand All @@ -20,7 +26,11 @@ export const notarize = async (context) => {
teamId: process.env.TEAMID,
})
console.log(`Notarization successful`)
} else if (typeof process.env.APPLEAPIKEY === "string" && typeof process.env.APPLEAPIKEYID === "string" && typeof process.env.APPLEAPIISSUER === "string") {
} else if (
typeof process.env.APPLEAPIKEY === "string" &&
typeof process.env.APPLEAPIKEYID === "string" &&
typeof process.env.APPLEAPIISSUER === "string"
) {
console.log(`Notarizing "${appName}.app" via App Store Connect API ...`)
await electronNotarize({
tool: "notarytool",
Expand All @@ -40,7 +50,9 @@ export const notarize = async (context) => {
})
console.log(`Notarization successful`)
} else {
throw new Error(`Notarization failed: No valid authentication method found in environment. Please provide either APPLEID and APPLEIDPASS, or APPLEAPIKEY, APPLEAPIKEYID and APPLEAPIISSUER, or (optional) KEYCHAIN and KEYCHAINPROFILE.`)
throw new Error(
`Notarization failed: No valid authentication method found in environment. Please provide either APPLEID and APPLEIDPASS, or APPLEAPIKEY, APPLEAPIKEYID and APPLEAPIISSUER, or (optional) KEYCHAIN and KEYCHAINPROFILE.`,
)
}
}
}
52 changes: 0 additions & 52 deletions deploy/assetNames.js

This file was deleted.

70 changes: 0 additions & 70 deletions deploy/build.base.config.js

This file was deleted.

26 changes: 0 additions & 26 deletions deploy/build.js

This file was deleted.

35 changes: 0 additions & 35 deletions deploy/build.prerelease.config.js

This file was deleted.

Loading

0 comments on commit d20e60b

Please sign in to comment.