mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-14 06:46:36 +00:00
fix generation of updater channel files in CI (#840)
This commit is contained in:
parent
f660058c75
commit
77b430675d
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
@ -60,9 +60,7 @@ jobs:
|
||||
if [ $IS_FORK = true ]; then
|
||||
echo "Skipping the app signing: building from a fork."
|
||||
else
|
||||
export BUILD_SUFFIX="linux";
|
||||
if [ "${{ runner.OS }}" = "macOS" ]; then
|
||||
export BUILD_SUFFIX="mac";
|
||||
export CSC_LINK="${{ runner.temp }}/signing_certificate.p12"
|
||||
# APPLE_SIGNING_CERTIFICATE_P12 secret was produced by following the procedure from:
|
||||
# https://www.kencochrane.com/2020/08/01/build-and-sign-golang-binaries-for-macos-with-github-actions/#exporting-the-developer-certificate
|
||||
@ -71,7 +69,6 @@ jobs:
|
||||
export CSC_KEY_PASSWORD="${{ secrets.KEYCHAIN_PASSWORD }}"
|
||||
|
||||
elif [ "${{ runner.OS }}" = "Windows" ]; then
|
||||
export BUILD_SUFFIX="";
|
||||
export CSC_LINK="${{ runner.temp }}/signing_certificate.pfx"
|
||||
npm config set msvs_version 2017 --global
|
||||
echo "${{ secrets.WINDOWS_SIGNING_CERTIFICATE_PFX }}" | base64 --decode > "$CSC_LINK"
|
||||
@ -83,14 +80,6 @@ jobs:
|
||||
yarn --cwd ./electron/packager/
|
||||
yarn --cwd ./electron/packager/ package
|
||||
|
||||
export BUILD_PREFIX="stable"
|
||||
if [ "$IS_NIGHTLY" = true ]; then
|
||||
export BUILD_PREFIX="nightly"
|
||||
fi
|
||||
|
||||
mv electron/build/dist/latest-$BUILD_SUFFIX.yml electron/build/dist/$BUILD_PREFIX-$BUILD_SUFFIX.yml
|
||||
rm electron/build/dist/alpha* electron/build/dist/beta*
|
||||
|
||||
- name: Upload [GitHub Actions]
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
|
@ -106,7 +106,7 @@ function getChannel() {
|
||||
return 'nightly';
|
||||
}
|
||||
|
||||
return 'none';
|
||||
return '';
|
||||
}
|
||||
|
||||
function timestamp() {
|
||||
|
@ -1,7 +1,6 @@
|
||||
//@ts-check
|
||||
|
||||
(async () => {
|
||||
|
||||
const fs = require('fs');
|
||||
const join = require('path').join;
|
||||
const shell = require('shelljs');
|
||||
@ -10,7 +9,9 @@
|
||||
shell.env.THEIA_ELECTRON_SKIP_REPLACE_FFMPEG = '1'; // Do not run the ffmpeg validation for the packager.
|
||||
shell.env.NODE_OPTIONS = '--max_old_space_size=4096'; // Increase heap size for the CI
|
||||
shell.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = 'true'; // Skip download and avoid `ERROR: Failed to download Chromium`.
|
||||
const template = require('./config').generateTemplate(new Date().toISOString());
|
||||
const template = require('./config').generateTemplate(
|
||||
new Date().toISOString()
|
||||
);
|
||||
const utils = require('./utils');
|
||||
const merge = require('deepmerge');
|
||||
const { isRelease, isElectronPublish, getChannelFile } = utils;
|
||||
@ -31,9 +32,13 @@
|
||||
// multiple Theia extensions will be picked up.
|
||||
if (fs.existsSync(path(rootPath, 'node_modules'))) {
|
||||
// We either do this or change the project structure.
|
||||
echo('🔧 >>> [Hack] Renaming the root \'node_modules\' folder to \'.node_modules\'...');
|
||||
echo(
|
||||
"🔧 >>> [Hack] Renaming the root 'node_modules' folder to '.node_modules'..."
|
||||
);
|
||||
mv('-f', path(rootPath, 'node_modules'), path(rootPath, '.node_modules'));
|
||||
echo('👌 <<< [Hack] Renamed the root \'node_modules\' folder to \'.node_modules\'.')
|
||||
echo(
|
||||
"👌 <<< [Hack] Renamed the root 'node_modules' folder to '.node_modules'."
|
||||
);
|
||||
}
|
||||
|
||||
//---------------------------+
|
||||
@ -42,23 +47,34 @@
|
||||
// rm -rf ../working-copy
|
||||
rm('-rf', path('..', workingCopy));
|
||||
// Clean up the `./electron/build` folder.
|
||||
const resourcesToKeep = ['patch', 'resources', 'scripts', 'template-package.json'];
|
||||
for (const filename of fs.readdirSync(path('..', 'build')).filter(filename => resourcesToKeep.indexOf(filename) === -1)) {
|
||||
rm('-rf', path('..', 'build', filename));
|
||||
}
|
||||
const resourcesToKeep = [
|
||||
'patch',
|
||||
'resources',
|
||||
'scripts',
|
||||
'template-package.json',
|
||||
];
|
||||
fs.readdirSync(path('..', 'build'))
|
||||
.filter((filename) => resourcesToKeep.indexOf(filename) === -1)
|
||||
.forEach((filename) => rm('-rf', path('..', 'build', filename)));
|
||||
|
||||
const extensions = require('./extensions.json');
|
||||
echo(`Building the application with the following extensions:\n${extensions.map(ext => ` - ${ext}`).join(',\n')}`);
|
||||
const allDependencies = [
|
||||
...extensions,
|
||||
'electron-app'
|
||||
]
|
||||
echo(
|
||||
`Building the application with the following extensions:\n${extensions
|
||||
.map((ext) => ` - ${ext}`)
|
||||
.join(',\n')}`
|
||||
);
|
||||
const allDependencies = [...extensions, 'electron-app'];
|
||||
|
||||
//----------------------------------------------------------------------------------------------+
|
||||
// Copy the following items into the `working-copy` folder. Make sure to reuse the `yarn.lock`. |
|
||||
//----------------------------------------------------------------------------------------------+
|
||||
mkdir('-p', path('..', workingCopy));
|
||||
for (const name of [...allDependencies, 'yarn.lock', 'package.json', 'lerna.json']) {
|
||||
for (const name of [
|
||||
...allDependencies,
|
||||
'yarn.lock',
|
||||
'package.json',
|
||||
'lerna.json',
|
||||
]) {
|
||||
cp('-rf', path(rootPath, name), path('..', workingCopy));
|
||||
}
|
||||
|
||||
@ -78,7 +94,10 @@
|
||||
pkg.dependencies[dependency] = version;
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(path('..', workingCopy, dependency, 'package.json'), JSON.stringify(pkg, null, 2));
|
||||
fs.writeFileSync(
|
||||
path('..', workingCopy, dependency, 'package.json'),
|
||||
JSON.stringify(pkg, null, 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
verifyVersions(allDependencies);
|
||||
@ -98,33 +117,49 @@
|
||||
}
|
||||
}
|
||||
pkg.workspaces = workspaces;
|
||||
fs.writeFileSync(path('..', workingCopy, 'package.json'), JSON.stringify(pkg, null, 2));
|
||||
fs.writeFileSync(
|
||||
path('..', workingCopy, 'package.json'),
|
||||
JSON.stringify(pkg, null, 2)
|
||||
);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------+
|
||||
// Rebuild the extension with the copied `yarn.lock`. It is a must to use the same Theia versions. |
|
||||
//-------------------------------------------------------------------------------------------------+
|
||||
exec(`yarn --network-timeout 1000000 --cwd ${path('..', workingCopy)}`, `Building the ${productName} application`);
|
||||
exec(
|
||||
`yarn --network-timeout 1000000 --cwd ${path('..', workingCopy)}`,
|
||||
`Building the ${productName} application`
|
||||
);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------+
|
||||
// Test the application. With this approach, we cannot publish test results to GH Actions but save 6-10 minutes per builds |
|
||||
//-------------------------------------------------------------------------------------------------------------------------+
|
||||
exec(`yarn --network-timeout 1000000 --cwd ${path('..', workingCopy)} test`, `Testing the ${productName} application`);
|
||||
exec(
|
||||
`yarn --network-timeout 1000000 --cwd ${path('..', workingCopy)} test`,
|
||||
`Testing the ${productName} application`
|
||||
);
|
||||
|
||||
// Collect all unused dependencies by the backend. We have to remove them from the electron app.
|
||||
// The `bundle.js` already contains everything we need for the frontend.
|
||||
// We have to do it before changing the dependencies to `local-path`.
|
||||
const unusedDependencies = await utils.collectUnusedDependencies('../working-copy/electron-app/');
|
||||
const unusedDependencies = await utils.collectUnusedDependencies(
|
||||
'../working-copy/electron-app/'
|
||||
);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------+
|
||||
// Change the regular NPM dependencies to `local-paths`, so that we can build them without any NPM registries. |
|
||||
//-------------------------------------------------------------------------------------------------------------+
|
||||
for (const extension of extensions) {
|
||||
if (extension !== 'arduino-ide-extension') { // Do not unlink self.
|
||||
if (extension !== 'arduino-ide-extension') {
|
||||
// Do not unlink self.
|
||||
// @ts-ignore
|
||||
pkg = require(`../working-copy/${extension}/package.json`);
|
||||
// @ts-ignore
|
||||
pkg.dependencies['arduino-ide-extension'] = 'file:../arduino-ide-extension';
|
||||
fs.writeFileSync(path('..', workingCopy, extension, 'package.json'), JSON.stringify(pkg, null, 2));
|
||||
pkg.dependencies['arduino-ide-extension'] =
|
||||
'file:../arduino-ide-extension';
|
||||
fs.writeFileSync(
|
||||
path('..', workingCopy, extension, 'package.json'),
|
||||
JSON.stringify(pkg, null, 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +168,10 @@
|
||||
//------------------------------------------------------------------------------------+
|
||||
// @ts-ignore
|
||||
pkg = require('../working-copy/electron-app/package.json');
|
||||
template.build.files = [...template.build.files, ...unusedDependencies.map(name => `!node_modules/${name}`)];
|
||||
template.build.files = [
|
||||
...template.build.files,
|
||||
...unusedDependencies.map((name) => `!node_modules/${name}`),
|
||||
];
|
||||
|
||||
const dependencies = {};
|
||||
for (const extension of extensions) {
|
||||
@ -144,17 +182,25 @@
|
||||
pkg.devDependencies = { ...pkg.devDependencies, ...template.devDependencies };
|
||||
// Deep-merging the Theia application configuration. We enable the electron window reload in dev mode but not for the final product. (arduino/arduino-pro-ide#187)
|
||||
// @ts-ignore
|
||||
const theia = merge((pkg.theia || {}), (template.theia || {}));
|
||||
const theia = merge(pkg.theia || {}, template.theia || {});
|
||||
const content = {
|
||||
...pkg,
|
||||
...template,
|
||||
theia,
|
||||
// @ts-ignore
|
||||
dependencies: pkg.dependencies,
|
||||
devDependencies: pkg.devDependencies
|
||||
devDependencies: pkg.devDependencies,
|
||||
};
|
||||
const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray;
|
||||
fs.writeFileSync(path('..', 'build', 'package.json'), JSON.stringify(merge(content, template, { arrayMerge: overwriteMerge }), null, 2));
|
||||
const overwriteMerge = (destinationArray, sourceArray, options) =>
|
||||
sourceArray;
|
||||
fs.writeFileSync(
|
||||
path('..', 'build', 'package.json'),
|
||||
JSON.stringify(
|
||||
merge(content, template, { arrayMerge: overwriteMerge }),
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
echo(`📜 Effective 'package.json' for the ${productName} application is:
|
||||
-----------------------
|
||||
@ -176,9 +222,20 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
|
||||
//-------------------------------------------------------------------------------------------+
|
||||
// Install all private and public dependencies for the electron application and build Theia. |
|
||||
//-------------------------------------------------------------------------------------------+
|
||||
exec(`yarn --network-timeout 1000000 --cwd ${path('..', 'build')}`, 'Installing dependencies');
|
||||
exec(`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build${isElectronPublish ? ':publish' : ''}`, `Building the ${productName} application`);
|
||||
exec(`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} rebuild`, 'Rebuild native dependencies');
|
||||
exec(
|
||||
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')}`,
|
||||
'Installing dependencies'
|
||||
);
|
||||
exec(
|
||||
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build${
|
||||
isElectronPublish ? ':publish' : ''
|
||||
}`,
|
||||
`Building the ${productName} application`
|
||||
);
|
||||
exec(
|
||||
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} rebuild`,
|
||||
'Rebuild native dependencies'
|
||||
);
|
||||
|
||||
//------------------------------------------------------------------------------+
|
||||
// Create a throw away dotenv file which we use to feed the builder with input. |
|
||||
@ -194,7 +251,10 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
|
||||
//-----------------------------------+
|
||||
// Package the electron application. |
|
||||
//-----------------------------------+
|
||||
exec(`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} package`, `Packaging your ${productName} application`);
|
||||
exec(
|
||||
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} package`,
|
||||
`Packaging your ${productName} application`
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------+
|
||||
// Copy to another folder. Azure does not support wildcard for `PublishBuildArtifacts@1.pathToPublish` |
|
||||
@ -264,9 +324,13 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
|
||||
|
||||
function restore() {
|
||||
if (fs.existsSync(path(rootPath, '.node_modules'))) {
|
||||
echo('🔧 >>> [Restore] Renaming the root \'.node_modules\' folder to \'node_modules\'...');
|
||||
echo(
|
||||
"🔧 >>> [Restore] Renaming the root '.node_modules' folder to 'node_modules'..."
|
||||
);
|
||||
mv('-f', path(rootPath, '.node_modules'), path(rootPath, 'node_modules'));
|
||||
echo('👌 >>> [Restore] Renamed the root \'.node_modules\' folder to \'node_modules\'.');
|
||||
echo(
|
||||
"👌 >>> [Restore] Renamed the root '.node_modules' folder to 'node_modules'."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,20 +345,38 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
|
||||
// Channel file might be an empty string if we're not building a
|
||||
// nightly or a full release. This can happen when building a package
|
||||
// locally or a tester build when creating a new PR on GH.
|
||||
if (channelFile) {
|
||||
filesToCopy.push(channelFile)
|
||||
if (!!channelFile && fs.existsSync(join(cwd, channelFile))) {
|
||||
const channelFilePath = join(cwd, channelFile);
|
||||
const newChannelFilePath = channelFilePath
|
||||
?.replace('latest', 'stable')
|
||||
?.replace('beta', 'nightly');
|
||||
echo(`🔨 >>> Renaming ${channelFilePath} to ${newChannelFilePath}.`);
|
||||
cp('-f', channelFilePath, newChannelFilePath);
|
||||
filesToCopy.push(newChannelFilePath);
|
||||
}
|
||||
switch (platform) {
|
||||
case 'linux': {
|
||||
filesToCopy.push(...glob.sync('**/arduino-ide*.{zip,AppImage}', { cwd }).map(p => join(cwd, p)));
|
||||
filesToCopy.push(
|
||||
...glob
|
||||
.sync('**/arduino-ide*.{zip,AppImage}', { cwd })
|
||||
.map((p) => join(cwd, p))
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'win32': {
|
||||
filesToCopy.push(...glob.sync('**/arduino-ide*.{exe,msi,zip}', { cwd }).map(p => join(cwd, p)));
|
||||
filesToCopy.push(
|
||||
...glob
|
||||
.sync('**/arduino-ide*.{exe,msi,zip}', { cwd })
|
||||
.map((p) => join(cwd, p))
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'darwin': {
|
||||
filesToCopy.push(...glob.sync('**/arduino-ide*.{dmg,zip}', { cwd }).map(p => join(cwd, p)));
|
||||
filesToCopy.push(
|
||||
...glob
|
||||
.sync('**/arduino-ide*.{dmg,zip}', { cwd })
|
||||
.map((p) => join(cwd, p))
|
||||
);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -328,20 +410,31 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
|
||||
function verifyVersions(allDependencies, expectedVersion) {
|
||||
const versions = new Set();
|
||||
for (const dependency of allDependencies) {
|
||||
versions.add(require(`../working-copy/${dependency}/package.json`).version);
|
||||
versions.add(
|
||||
require(`../working-copy/${dependency}/package.json`).version
|
||||
);
|
||||
}
|
||||
if (versions.size !== 1) {
|
||||
echo(`Mismatching version configuration. All dependencies must have the same version. Versions were: ${JSON.stringify(Array.from(versions), null, 2)}.`);
|
||||
echo(
|
||||
`Mismatching version configuration. All dependencies must have the same version. Versions were: ${JSON.stringify(
|
||||
Array.from(versions),
|
||||
null,
|
||||
2
|
||||
)}.`
|
||||
);
|
||||
shell.exit(1);
|
||||
process.exit(1);
|
||||
}
|
||||
if (expectedVersion) {
|
||||
if (!versions.has(expectedVersion)) {
|
||||
echo(`Mismatching version configuration. Expected version was: '${expectedVersion}' actual was: '${Array.from(versions)[0]}'.`);
|
||||
echo(
|
||||
`Mismatching version configuration. Expected version was: '${expectedVersion}' actual was: '${
|
||||
Array.from(versions)[0]
|
||||
}'.`
|
||||
);
|
||||
shell.exit(1);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -199,9 +199,9 @@ function git(command) {
|
||||
function getChannelFile(platform) {
|
||||
let currentChannel = '';
|
||||
if (isNightly) {
|
||||
currentChannel = 'nightly';
|
||||
currentChannel = 'beta';
|
||||
} else if (isRelease) {
|
||||
currentChannel = 'stable';
|
||||
currentChannel = 'latest';
|
||||
} else {
|
||||
// We're not creating a nightly build nor releasing
|
||||
// a new version, no need for a channel file.
|
||||
|
Loading…
x
Reference in New Issue
Block a user