Skip to content

Commit

Permalink
Prevent update downgrade from stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Hollister committed Nov 21, 2024
1 parent d79417a commit 4af2a53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions receivers/electron/forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports = {
const exePath = `./out/${APPLICATION_NAME}-${packageResults.platform}-${packageResults.arch}/${APPLICATION_NAME}.exe`;

if (fs.existsSync(CI_SIGNING_DIR)) {
console.log(cp.execSync(path.join(CI_SIGNING_DIR, `sign.sh ${exePath}`)));
console.log(cp.execSync(path.join(CI_SIGNING_DIR, `sign.sh ${exePath}`)).toString().trim());
}
else {
console.warn('Windows signing script not found, skipping...');
Expand Down Expand Up @@ -163,7 +163,7 @@ module.exports = {
fs.renameSync(`./out/make/wix/${e.arch}/${artifactName}`, artifactPath);

if (fs.existsSync(CI_SIGNING_DIR)) {
console.log(cp.execSync(path.join(CI_SIGNING_DIR, `sign.sh ${artifactPath}`)));
console.log(cp.execSync(path.join(CI_SIGNING_DIR, `sign.sh ${artifactPath}`)).toString().trim());
}
else {
console.warn('Windows signing script not found, skipping...');
Expand All @@ -182,8 +182,8 @@ module.exports = {
console.log(`Making a zip distributable for ${e.platform}/${e.arch}`);
const zipPath = path.resolve(process.cwd(), 'out', 'make', 'zip', e.platform, e.arch, generateArtifactName(e.packageJSON, e.platform, e.arch, 'zip'));

console.log(cp.execSync(`mkdir -p ${path.dirname(zipPath)}`));
console.log(cp.execSync(`cd out/${APPLICATION_NAME}-${e.platform}-${e.arch}; zip -r -y "${zipPath}" "${APPLICATION_TITLE}.app"`));
console.log(cp.execSync(`mkdir -p ${path.dirname(zipPath)}`).toString().trim());
console.log(cp.execSync(`cd out/${APPLICATION_NAME}-${e.platform}-${e.arch}; zip -r -y "${zipPath}" "${APPLICATION_TITLE}.app"`).toString().trim());
break;
}
case "linux": {
Expand Down
7 changes: 5 additions & 2 deletions receivers/electron/src/Updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export class Updater {
const localChannelVersion: number = Updater.localPackageJson.channelVersion ? Updater.localPackageJson.channelVersion : 0;
const currentChannelVersion: number = Updater.releasesJson.channelCurrentVersions[Updater.updateChannel] ? Updater.releasesJson.channelCurrentVersions[Updater.updateChannel] : 0;
logger.info('Update check', {
channel: Updater.updateChannel,
updateChannel: Updater.updateChannel,
channel_version: localChannelVersion,
localVersion: Updater.localPackageJson.version,
currentVersion: Updater.releasesJson.currentVersion,
Expand All @@ -340,7 +340,10 @@ export class Updater {
// Allow for update promotion to stable, while still getting updates from the subscribed channel
const newCommit = (Updater.updateChannel !== 'stable' && Updater.localPackageJson.commit !== Updater.releasesJson.currentCommit);

if (newVersion || newChannelVersion || newCommit) {
// Prevent downgrading to sub channel if on stable
const isDowngrade = Updater.releaseChannel === 'stable' && newChannelVersion;

if ((newVersion || newChannelVersion || newCommit) && !isDowngrade) {
logger.info('Update available...');
return true;
}
Expand Down

0 comments on commit 4af2a53

Please sign in to comment.