mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-09-24 21:04:57 +00:00
MacOS Support
This commit is contained in:
@@ -7,6 +7,8 @@ const fs = require("fs");
|
||||
const fse = require("fs-extra");
|
||||
const buildutils = require("./buildutils");
|
||||
const execSync = require("child_process").execSync;
|
||||
const electronNotarize = require("electron-notarize");
|
||||
const { signAsync } = require("tobspr-osx-sign");
|
||||
|
||||
function gulptasksStandalone($, gulp) {
|
||||
const targets = [
|
||||
@@ -96,6 +98,24 @@ function gulptasksStandalone($, gulp) {
|
||||
cb();
|
||||
});
|
||||
|
||||
gulp.task(taskPrefix + "standalone.prepareVDF.darwin", cb => {
|
||||
if (!steam) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
const hash = buildutils.getRevision();
|
||||
const steampipeDir = path.join(__dirname, "steampipe-darwin", "scripts");
|
||||
const templateContents = fs
|
||||
.readFileSync(path.join(steampipeDir, "app.vdf.template"), { encoding: "utf-8" })
|
||||
.toString();
|
||||
|
||||
const convertedContents = templateContents.replace("$DESC$", "Commit " + hash);
|
||||
fs.writeFileSync(path.join(steampipeDir, "app.vdf"), convertedContents);
|
||||
|
||||
cb();
|
||||
});
|
||||
|
||||
gulp.task(taskPrefix + "standalone.prepare.minifyCode", () => {
|
||||
return gulp.src(path.join(electronBaseDir, "*.js")).pipe(gulp.dest(tempDestBuildDir));
|
||||
});
|
||||
@@ -127,11 +147,11 @@ function gulptasksStandalone($, gulp) {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {'win32'|'linux'} platform
|
||||
* @param {'win32'|'linux'|'darwin'} platform
|
||||
* @param {'x64'|'ia32'} arch
|
||||
* @param {function():void} cb
|
||||
*/
|
||||
function packageStandalone(platform, arch, cb) {
|
||||
function packageStandalone(platform, arch, cb, isRelease = true) {
|
||||
const tomlFile = fs.readFileSync(path.join(__dirname, ".itch.toml"));
|
||||
const privateArtifactsPath = "node_modules/shapez.io-private-artifacts";
|
||||
|
||||
@@ -154,8 +174,23 @@ function gulptasksStandalone($, gulp) {
|
||||
name: "shapez.io-standalone" + suffix,
|
||||
out: tempDestDir,
|
||||
overwrite: true,
|
||||
appBundleId: "io.shapez.standalone",
|
||||
appBundleId: "tobspr.shapezio.standalone",
|
||||
appCategoryType: "public.app-category.games",
|
||||
...(isRelease &&
|
||||
platform === "darwin" && {
|
||||
osxSign: {
|
||||
"identity": process.env.SHAPEZ_CLI_APPLE_CERT_NAME,
|
||||
"hardenedRuntime": true,
|
||||
"entitlements": "entitlements.plist",
|
||||
"entitlements-inherit": "entitlements.plist",
|
||||
"signatureFlags": ["library"],
|
||||
"version": "16.0.7",
|
||||
},
|
||||
osxNotarize: {
|
||||
appleId: process.env.SHAPEZ_CLI_APPLE_ID,
|
||||
appleIdPassword: process.env.SHAPEZ_CLI_APPLE_APP_PW,
|
||||
},
|
||||
}),
|
||||
}).then(
|
||||
appPaths => {
|
||||
console.log("Packages created:", appPaths);
|
||||
@@ -185,6 +220,22 @@ function gulptasksStandalone($, gulp) {
|
||||
);
|
||||
fs.chmodSync(path.join(appPath, "play.sh"), 0o775);
|
||||
}
|
||||
if (platform === "darwin") {
|
||||
if (!isRelease) {
|
||||
fse.copySync(
|
||||
path.join(tempDestBuildDir, "steam_appid.txt"),
|
||||
path.join(
|
||||
path.join(
|
||||
appPath,
|
||||
"shapez.io-standalone.app",
|
||||
"Contents",
|
||||
"MacOS"
|
||||
),
|
||||
"steam_appid.txt"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -197,10 +248,89 @@ function gulptasksStandalone($, gulp) {
|
||||
);
|
||||
}
|
||||
|
||||
// Manual signing with patched @electron/osx-sign (we need --no-strict)
|
||||
gulp.task(taskPrefix + "standalone.package.prod.darwin64.signManually", cb =>
|
||||
packageStandalone(
|
||||
"darwin",
|
||||
"x64",
|
||||
() => {
|
||||
const appFile = path.join(tempDestDir, "shapez.io-standalone-darwin-x64");
|
||||
const appFileInner = path.join(appFile, "shapez.io-standalone.app");
|
||||
const appIdDest = path.join(
|
||||
path.join(appFileInner, "Contents", "MacOS"),
|
||||
"steam_appid.txt"
|
||||
);
|
||||
console.warn("++ Preparing ++");
|
||||
fse.copySync(path.join(tempDestBuildDir, "steam_appid.txt"), appIdDest);
|
||||
|
||||
console.warn("++ Signing ++");
|
||||
console.warn("Signing steam_appid.txt");
|
||||
|
||||
execSync(
|
||||
`codesign --force --verbose --options runtime --timestamp --no-strict --sign "${
|
||||
process.env.SHAPEZ_CLI_APPLE_CERT_NAME
|
||||
}" --entitlements "${path.join(__dirname, "entitlements.plist")}" ${appIdDest}`,
|
||||
{
|
||||
cwd: appFile,
|
||||
}
|
||||
);
|
||||
|
||||
console.warn("Base dir:", appFile);
|
||||
|
||||
signAsync({
|
||||
app: appFileInner,
|
||||
hardenedRuntime: true,
|
||||
identity: process.env.SHAPEZ_CLI_APPLE_CERT_NAME,
|
||||
strictVerify: false,
|
||||
|
||||
version: "16.0.7",
|
||||
type: "distribution",
|
||||
optionsForFile: f => {
|
||||
return {
|
||||
entitlements: path.join(__dirname, "entitlements.plist"),
|
||||
hardenedRuntime: true,
|
||||
signatureFlags: ["runtime"],
|
||||
};
|
||||
},
|
||||
}).then(() => {
|
||||
execSync(
|
||||
`codesign --verify --verbose ${path.join(appFile, "shapez.io-standalone.app")}`,
|
||||
{
|
||||
cwd: appFile,
|
||||
}
|
||||
);
|
||||
|
||||
console.warn("++ Notarizing ++");
|
||||
electronNotarize
|
||||
.notarize({
|
||||
appPath: path.join(appFile, "shapez.io-standalone.app"),
|
||||
tool: "legacy",
|
||||
appBundleId: "tobspr.shapezio.standalone",
|
||||
|
||||
appleId: process.env.SHAPEZ_CLI_APPLE_ID,
|
||||
appleIdPassword: process.env.SHAPEZ_CLI_APPLE_APP_PW,
|
||||
teamId: process.env.SHAPEZ_CLI_APPLE_TEAM_ID,
|
||||
})
|
||||
.then(() => {
|
||||
console.warn("-> Notarized!");
|
||||
cb();
|
||||
});
|
||||
});
|
||||
},
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
gulp.task(taskPrefix + "standalone.package.prod.win64", cb => packageStandalone("win32", "x64", cb));
|
||||
gulp.task(taskPrefix + "standalone.package.prod.linux64", cb =>
|
||||
packageStandalone("linux", "x64", cb)
|
||||
);
|
||||
gulp.task(taskPrefix + "standalone.package.prod.darwin64", cb =>
|
||||
packageStandalone("darwin", "x64", cb)
|
||||
);
|
||||
gulp.task(taskPrefix + "standalone.package.prod.darwin64.unsigned", cb =>
|
||||
packageStandalone("darwin", "x64", cb, false)
|
||||
);
|
||||
|
||||
gulp.task(
|
||||
taskPrefix + "standalone.package.prod",
|
||||
@@ -208,7 +338,8 @@ function gulptasksStandalone($, gulp) {
|
||||
taskPrefix + "standalone.prepare",
|
||||
gulp.parallel(
|
||||
taskPrefix + "standalone.package.prod.win64",
|
||||
taskPrefix + "standalone.package.prod.linux64"
|
||||
taskPrefix + "standalone.package.prod.linux64",
|
||||
taskPrefix + "standalone.package.prod.darwin64"
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user