Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This PR brings us up to date with platform drift in GitHub's build infrastructure. #1315

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ jobs:
- name: Install udev-dev
run: sudo apt update && sudo apt install libudev-dev
if: runner.os == 'Linux'

- name: Workaround a missing python dep
if: matrix.os == 'macos-13'
run: |
sudo -H pip install setuptools
- name: Set up yarn network timeout
run: yarn config set network-timeout 1000000 -g

Expand All @@ -86,7 +89,6 @@ jobs:
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
sudo -H pip install setuptools
yarn run make --arch=universal
- name: Release (non-macos)
shell: bash
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ jobs:
- name: Install udev-dev
run: sudo apt update && sudo apt install libudev-dev
if: runner.os == 'Linux'

- name: Workaround a missing python dep
if: matrix.os == 'macos-13'
run: |
sudo -H pip install setuptools
- name: Set up yarn network timeout
run: yarn config set network-timeout 1000000 -g

Expand All @@ -76,7 +79,6 @@ jobs:
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
sudo -H pip install setuptools
yarn run publish --arch=universal
- name: Release (non-macos)
if: matrix.os != 'macos-13'
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jobs:
- name: Install udev-dev
run: sudo apt update && sudo apt install libudev-dev
if: runner.os == 'Linux'

- name: Workaround a missing python dep
if: matrix.os == 'macos-13'
run: |
sudo -H pip install setuptools
- name: Set up yarn network timeout
run: yarn config set network-timeout 1000000 -g

Expand All @@ -37,7 +40,6 @@ jobs:
UNTRUSTED: 1
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sudo -H pip install setuptools
yarn run publish --arch=universal --dry-run
- name: Release (non-macos)
if: matrix.os != 'macos-13'
Expand Down
161 changes: 97 additions & 64 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const { spawnSync } = require("child_process");
const { generateCLDRData } = require("./tools/precompile.js");
const { glob } = require('glob');
const fs = require('fs');
const { glob } = require("glob");
const fs = require("fs");
const path = require("path");

let config = {
let config = {
packagerConfig: {
asar: true,
appBundleId: 'keyboardio.chrysalis',
appBundleId: "keyboardio.chrysalis",
darwinDarkModeSupport: "true",
icon: "build/icon",
name: "Chrysalis",
Expand Down Expand Up @@ -36,54 +37,51 @@ let config = {
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
{
name: "@electron-forge/maker-squirrel",
config: {
certificateFile: './cert.pfx',
certificateFile: "./cert.pfx",
certificatePassword: process.env.WINDOWS_CERTIFICATE_PASSWORD,
},
},
},
{
name: "@electron-forge/maker-dmg",
config: {},
},
{
name: "@electron-forge/maker-zip",
},
{
name: "@reforged/maker-appimage",
config: {
options: {
// Package name.
// name: "example-app",
// Executable name.
bin: "Chrysalis",
// Human-friendly name of the application.
// productName: "Example Electron Application",
// `GenericName` in generated `.desktop` file.
// genericName: "Example application",
// Path to application's icon.
icon: "build/icon.png",
// `Categories` in generated `.desktop` file.
categories: [ "Utility" ],
// Actions of generated `.desktop` file.
// actions: {
// new_window: {
// Name: "Launch in new window!",
// Icon: "/path/to/new-window.png",
// Exec: "example-app --new-window"
// }
//},
// Desktop file to be used instead of the configuration above.
// desktopFile: "/path/to/example-app.desktop",
// Release of `AppImage/AppImageKit`, either number or "continuous".
// AppImageKitRelease: "continuous"
}
}
}



{
name: "@reforged/maker-appimage",
config: {
options: {
// Package name.
// name: "example-app",
// Executable name.
bin: "Chrysalis",
// Human-friendly name of the application.
// productName: "Example Electron Application",
// `GenericName` in generated `.desktop` file.
// genericName: "Example application",
// Path to application's icon.
icon: "build/icon.png",
// `Categories` in generated `.desktop` file.
categories: ["Utility"],
// Actions of generated `.desktop` file.
// actions: {
// new_window: {
// Name: "Launch in new window!",
// Icon: "/path/to/new-window.png",
// Exec: "example-app --new-window"
// }
//},
// Desktop file to be used instead of the configuration above.
// desktopFile: "/path/to/example-app.desktop",
// Release of `AppImage/AppImageKit`, either number or "continuous".
// AppImageKitRelease: "continuous"
},
},
},
],
publishers: [
{
Expand Down Expand Up @@ -132,7 +130,7 @@ let config = {
// only copy deps if there isn't any
if (Object.keys(packageJson.dependencies).length === 0) {
const originalPackageJson = await fs.readJson(
path.resolve(__dirname, "package.json")
path.resolve(__dirname, "package.json"),
);
const webpackConfigJs = require("./webpack.renderer.config.js");
Object.keys(webpackConfigJs.externals).forEach((package) => {
Expand All @@ -142,32 +140,67 @@ let config = {
}
return packageJson;
},
packageAfterPrune: async (forgeConfig, buildPath, electronVersion, platform, arch) => {
const npmInstall = spawnSync("npm", ["install", "--omit=dev"], {
cwd: buildPath,
stdio: "inherit",
shell: true,
});
packageAfterPrune: async (
forgeConfig,
buildPath,
electronVersion,
platform,
arch,
) => {
const npmInstall = spawnSync("npm", ["install", "--omit=dev"], {
cwd: buildPath,
stdio: "inherit",
shell: true,
});

console.log(buildPath);
// Clear out prebuilds for other architectures
// 1) we don't need them
// 2) windows binary signing tool blows up when it tries to sign them.

const prebuilds = glob.GlobSync(`${buildPath}/**/prebuilds/*`);
const matchString = new RegExp(`prebuilds/${platform}`);
prebuilds.found.forEach(function (path) {
if (!path.match(matchString)) {
fs.rmSync(path, { recursive: true });
}
});
// Workaround from https://www.update.rocks/blog/fixing-the-python3/
if (platform === "darwin") {
// Directory to inspect
const dirPath = path.join(
buildPath,
"node_modules/macos-alias/build/node_gyp_bins",
);
// Check if the directory exists
if (fs.existsSync(dirPath)) {
// List files in the directory
console.log("Contents of the directory before removal: ");
const files = fs.readdirSync(path.join(dirPath));
files.forEach((file) => {
console.log(file);
});

// Clear out prebuilds for other architectures
// 1) we don't need them
// 2) windows binary signing tool blows up when it tries to sign them.

const prebuilds = glob.GlobSync(`${buildPath}/**/prebuilds/*`);
const matchString = new RegExp(`prebuilds/${platform}`);
prebuilds.found.forEach(function(path) {
if (! path.match(matchString)) {
fs.rmdirSync(path, { recursive: true });
}
});
// Files to remove
const filesToRemove = ["python", "python2", "python3"];

// Remove files if they exist
filesToRemove.forEach((file) => {
const filePath = path.join(dirPath, file);
if (fs.existsSync(filePath)) {
console.log(`Removing file: ${file}`);
fs.unlinkSync(filePath);
}
});
} else {
console.log(`Directory not found: ${dirPath}`);
}
}
},
},
}
};
if (process.env.UNTRUSTED) {
delete config['packagerConfig']['osxSign'];
delete config['packagerConfig']['osxNotarize'];
delete config["packagerConfig"]["osxSign"];
delete config["packagerConfig"]["osxNotarize"];
}

module.exports = config;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"prettier": "^2.6.1",
"style-loader": "^3.0.0",
"stylelint": "^15.10.1",
"stylelint-config-standard": "^25.0.0",
"stylelint-config-standard": "^32.0.0",
"unraw": "^2.0.0",
"webpack": "^5.75.0",
"xml2js": "^0.5.0",
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9664,17 +9664,17 @@ style-to-object@^0.3.0:
dependencies:
inline-style-parser "0.1.1"

stylelint-config-recommended@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-7.0.0.tgz#7497372ae83ab7a6fffc18d7d7b424c6480ae15e"
integrity sha512-yGn84Bf/q41J4luis1AZ95gj0EQwRX8lWmGmBwkwBNSkpGSpl66XcPTulxGa/Z91aPoNGuIGBmFkcM1MejMo9Q==
stylelint-config-recommended@^11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-11.0.0.tgz#b1cb7d71bd92f9b8593f93c2ca6df16ed7d61522"
integrity sha512-SoGIHNI748OCZn6BxFYT83ytWoYETCINVHV3LKScVAWQQauWdvmdDqJC5YXWjpBbxg2E761Tg5aUGKLFOVhEkA==

stylelint-config-standard@^25.0.0:
version "25.0.0"
resolved "https://registry.yarnpkg.com/stylelint-config-standard/-/stylelint-config-standard-25.0.0.tgz#2c916984e6655d40d6e8748b19baa8603b680bff"
integrity sha512-21HnP3VSpaT1wFjFvv9VjvOGDtAviv47uTp3uFmzcN+3Lt+RYRv6oAplLaV51Kf792JSxJ6svCJh/G18E9VnCA==
stylelint-config-standard@^32.0.0:
version "32.0.0"
resolved "https://registry.yarnpkg.com/stylelint-config-standard/-/stylelint-config-standard-32.0.0.tgz#97179035e967f22a7b7e27f14a74f5d5fc0f0bd6"
integrity sha512-UnGJxYDyYFrIE9CjDMZRkrNh2o4lOtO+MVZ9qG5b8yARfsWho0GMx4YvhHfsv8zKKgHeWX2wfeyxmuoqcaYZ4w==
dependencies:
stylelint-config-recommended "^7.0.0"
stylelint-config-recommended "^11.0.0"

stylelint@^15.10.1:
version "15.10.1"
Expand Down