Skip to content

Commit 9a16bd3

Browse files
committed
Add function to get channel file during packaging step
1 parent 6a55d85 commit 9a16bd3

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

electron/packager/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
const template = require('./config').generateTemplate(new Date().toISOString());
1414
const utils = require('./utils');
1515
const merge = require('deepmerge');
16-
const { isRelease, isElectronPublish } = utils;
16+
const { isRelease, isElectronPublish, getChannelFile } = utils;
1717
const { version } = template;
1818
const { productName } = template.build;
1919

@@ -276,6 +276,13 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
276276
const targetFolder = path('..', 'build', 'dist', 'build-artifacts');
277277
mkdir('-p', targetFolder);
278278
const filesToCopy = [];
279+
const channelFile = getChannelFile(platform);
280+
// Channel file might be an empty string if we're not building a
281+
// nightly or a full release. This can happen when building a package
282+
// locally or a tester build when creating a new PR on GH.
283+
if (channelFile) {
284+
filesToCopy.push(channelFile)
285+
}
279286
switch (platform) {
280287
case 'linux': {
281288
filesToCopy.push(...glob.sync('**/arduino-ide*.{zip,AppImage}', { cwd }).map(p => join(cwd, p)));

electron/packager/utils.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,31 @@ function git(command) {
168168
}
169169
}
170170

171-
module.exports = { collectUnusedDependencies, adjustArchiveStructure, isZip, unpack, isNightly, isRelease, isElectronPublish, git };
171+
// getChannelFile returns the name of the channel file to be released
172+
// together with the IDE file.
173+
// The channel file depends on the platform and whether we're creating
174+
// a nightly build or a full release.
175+
// In all other cases, like when building a tester build for a PR,
176+
// an empty string is returned since we don't need a channel file.
177+
// The channel files are necessary for updates check with electron-updater
178+
// to work correctly.
179+
// For more information: https://www.electron.build/auto-update
180+
function getChannelFile(platform) {
181+
let currentChannel = "";
182+
if (isNightly) {
183+
currentChannel = "beta";
184+
} else if (isRelease) {
185+
currentChannel = "latest";
186+
} else {
187+
// We're not creating a nightly build nor releasing
188+
// a new version, no need for a channel file.
189+
return "";
190+
}
191+
return currentChannel + {
192+
'linux': "-linux.yml",
193+
'win32': ".yml",
194+
'darwin': "-mac.yml"
195+
}[platform];
196+
}
197+
198+
module.exports = { collectUnusedDependencies, adjustArchiveStructure, isZip, unpack, isNightly, isRelease, isElectronPublish, git, getChannelFile };

0 commit comments

Comments
 (0)