mattermost-desktop/scripts/afterpack.js
Devin Binnie 0a7be91576
[MM-42538] Submit nightly builds to TestFlight for macOS (#2023)
* Initial MAS build, working on TestFlight

* Migration of old configs to MAS

* Ignore fastlane files

* Add mac app store build to nightly build

* Revert Me - For testing in PR

* Don't need to install fastlane

* BIG D

* Fix patch updater script to allow for no yml

* Nevermind, do this instead

* Update xcode

* Let's try a fake version that works

* Revert version and rename for test flight

* Use Xcode 13.0.0

* Use CircleCI build number when available

* Revert testing changes

* Remove notarize for MAS

* Change vars to MACOS instead of IOS

* Revert electron-builder to v22

* Revert package-lock.json

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-03-28 11:06:00 -04:00

51 lines
1.5 KiB
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const path = require('path');
const {spawn} = require('electron-notarize/lib/spawn.js');
const SETUID_PERMISSIONS = '4755';
const {flipFuses, FuseVersion, FuseV1Options} = require('@electron/fuses');
function fixSetuid(context) {
return async (target) => {
if (!['appimage', 'snap'].includes(target.name.toLowerCase())) {
const result = await spawn('chmod', [SETUID_PERMISSIONS, path.join(context.appOutDir, 'chrome-sandbox')]);
if (result.code !== 0) {
throw new Error(
`Failed to set proper permissions for linux arch on ${target.name}`,
);
}
}
};
}
function getAppFileName(context) {
switch (context.electronPlatformName) {
case 'win32':
return 'Mattermost.exe';
case 'darwin':
case 'mas':
return 'Mattermost.app';
case 'linux':
return context.packager.executableName;
default:
return '';
}
}
exports.default = async function afterPack(context) {
await flipFuses(
`${context.appOutDir}/${getAppFileName(context)}`, // Returns the path to the electron binary
{
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false, // Disables ELECTRON_RUN_AS_NODE
});
if (context.electronPlatformName === 'linux') {
context.targets.forEach(fixSetuid(context));
}
};