Skip to content

Commit

Permalink
Introduce Update Channels #278
Browse files Browse the repository at this point in the history
* adapt main build Jenkinsfile to not publish at the release location
"theia/ide" but at "theia/ide-preview"
* create dedicated
* add a preference for selecting an update channel
* add additional method to updater that allows passing the channel

Contributed on behalf of STMicroelectronics

Signed-off-by: Johannes Faltermeier <[email protected]>
  • Loading branch information
jfaltermeier committed Jan 22, 2024
1 parent f037dcc commit 257d3bc
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 24 deletions.
24 changes: 12 additions & 12 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,12 @@ def uploadInstaller(String platform) {
def packageJSON = readJSON file: "package.json"
String version = "${packageJSON.version}"
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh [email protected] rm -rf /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}"
sh "ssh [email protected] mkdir -p /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}"
sh "scp ${distFolder}/*.* [email protected]:/home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}"
sh "ssh [email protected] rm -rf /home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}"
sh "ssh [email protected] mkdir -p /home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}"
sh "scp ${distFolder}/*.* [email protected]:/home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}"
sh "ssh [email protected] rm -rf /home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}"
sh "ssh [email protected] mkdir -p /home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}"
sh "scp ${distFolder}/*.* [email protected]:/home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}"
sh "ssh [email protected] rm -rf /home/data/httpd/download.eclipse.org/theia/ide-preview/latest/${platform}"
sh "ssh [email protected] mkdir -p /home/data/httpd/download.eclipse.org/theia/ide-preview/latest/${platform}"
sh "scp ${distFolder}/*.* [email protected]:/home/data/httpd/download.eclipse.org/theia/ide-preview/latest/${platform}"
}
} else {
echo "Skipped upload for branch ${env.BRANCH_NAME}"
Expand All @@ -421,16 +421,16 @@ def copyInstallerAndUpdateLatestYml(String platform, String installer, String ex
def packageJSON = readJSON file: "package.json"
String version = "${packageJSON.version}"
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}/${installer}.${extension} /home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}/${installer}-${version}.${extension}"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}/${installer}.${extension} /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}/${installer}-${version}.${extension}"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}/${installer}.${extension}.blockmap /home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}/${installer}-${version}.${extension}.blockmap"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}/${installer}.${extension}.blockmap /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}/${installer}-${version}.${extension}.blockmap"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide-preview/latest/${platform}/${installer}.${extension} /home/data/httpd/download.eclipse.org/theia/ide-preview/latest/${platform}/${installer}-${version}.${extension}"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}/${installer}.${extension} /home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}/${installer}-${version}.${extension}"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide-preview/latest/${platform}/${installer}.${extension}.blockmap /home/data/httpd/download.eclipse.org/theia/ide-preview/latest/${platform}/${installer}-${version}.${extension}.blockmap"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}/${installer}.${extension}.blockmap /home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}/${installer}-${version}.${extension}.blockmap"
}
if (UPDATABLE_VERSIONS.length() != 0) {
for (oldVersion in UPDATABLE_VERSIONS.split(",")) {
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh [email protected] rm -f /home/data/httpd/download.eclipse.org/theia/ide/${oldVersion}/${platform}/${yaml}"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}/${yaml} /home/data/httpd/download.eclipse.org/theia/ide/${oldVersion}/${platform}/${yaml}"
sh "ssh [email protected] rm -f /home/data/httpd/download.eclipse.org/theia/ide-preview/${oldVersion}/${platform}/${yaml}"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}/${yaml} /home/data/httpd/download.eclipse.org/theia/ide-preview/${oldVersion}/${platform}/${yaml}"
}
}
} else {
Expand Down
78 changes: 78 additions & 0 deletions releng/promote/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* This Jenkinsfile promotes a given version of the Theia IDE from /theia/ide-preview to /theia/ide
*/

/* groovylint-disable NestedBlockDepth */
import groovy.json.JsonSlurper

pipeline {
agent none
options {
timeout(time: 3, unit: 'HOURS')
disableConcurrentBuilds()
}
environment {
}
stages {

stage('Setup parameters') {
steps {
script {
properties([
parameters([
string(
defaultValue: 'latest',
name: 'VERSION',
trim: true
),
string(
defaultValue: '1.41.0,1.42.1,1.43.0',
name: 'TOUPDATE',
trim: true
)
])
])
}
}
}

stage('Promote') {
agent any
steps {
script {
promote('linux', params.VERSION)
promote('macos', params.VERSION)
promote('windows', params.VERSION)

// update latest.yaml on windows for differential updater
updateLatestYaml('windows', params.VERSION, 'TheiaIDESetup', 'exe', 'latest.yml', params.TOUPDATE)
}
}
}
}
}

def promote(String platform, String version) {
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh [email protected] rm -rf /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}"
sh "ssh [email protected] mkdir -p /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}"
sh "scp [email protected]:/home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}/*.* [email protected]:/home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}"

sh "ssh [email protected] rm -rf /home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}"
sh "ssh [email protected] mkdir -p /home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}"
sh "scp [email protected]:/home/data/httpd/download.eclipse.org/theia/ide-preview/${version}/${platform}/*.* [email protected]:/home/data/httpd/download.eclipse.org/theia/ide/latest/${platform}"
}
}

def updateLatestYaml(String platform, String version, String installer, String extension, String yaml, String UPDATABLE_VERSIONS) {
if (UPDATABLE_VERSIONS.length() != 0) {
for (oldVersion in UPDATABLE_VERSIONS.split(",")) {
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh [email protected] rm -f /home/data/httpd/download.eclipse.org/theia/ide/${oldVersion}/${platform}/${yaml}"
sh "ssh [email protected] cp /home/data/httpd/download.eclipse.org/theia/ide/${version}/${platform}/${yaml} /home/data/httpd/download.eclipse.org/theia/ide/${oldVersion}/${platform}/${yaml}"
}
}
} else {
echo "No updateable versions"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface TheiaUpdater extends JsonRpcServer<TheiaUpdaterClient> {
downloadUpdate(): void;
onRestartToUpdateRequested(): void;
disconnectClient(client: TheiaUpdaterClient): void;
setUpdateChannel(channel: string): void;
}

export const TheiaUpdaterClient = Symbol('TheiaUpdaterClient');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ export class TheiaUpdaterFrontendContribution implements CommandContribution, Me

@postConstruct()
protected init(): void {
this.preferenceService.ready.then(() => this.updater.setUpdateChannel(this.preferenceService.get('updates.channel', 'stable')));
this.preferenceService.onPreferenceChanged(e => {
if (e.preferenceName === 'updates.channel') {
this.updater.setUpdateChannel(this.preferenceService.get('updates.channel', 'stable'));
}
});

this.updaterClient.onUpdateAvailable(available => {
if (available) {
this.handleDownloadUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export const theiaUpdaterPreferenceSchema: PreferenceSchema = {
type: 'boolean',
description: 'Report available updates after application start.',
default: true
}
},
'updates.channel': {
type: 'string',
enum: ['stable', 'preview'], // once we have a nightly/next build, we can add a third channel
default: 'stable'
},
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ import * as path from 'path';
import { ElectronMainApplication, ElectronMainApplicationContribution } from '@theia/core/lib/electron-main/electron-main-application';
import { TheiaUpdater, TheiaUpdaterClient } from '../../common/updater/theia-updater';
import { injectable } from '@theia/core/shared/inversify';
import { isOSX, isWindows } from '@theia/core';

const STABLE_CHANNEL_WINDOWS = 'https://download.eclipse.org/theia/ide/version/windows';
const STABLE_CHANNEL_MACOS = 'https://download.eclipse.org/theia/ide/latest/macos';
const STABLE_CHANNEL_LINUX = 'https://download.eclipse.org/theia/ide/latest/linux';

const PREVIEW_CHANNEL_WINDOWS = 'https://download.eclipse.org/theia/ide-preview/version/windows';
const PREVIEW_CHANNEL_MACOS = 'https://download.eclipse.org/theia/ide-preview/latest/macos';
const PREVIEW_CHANNEL_LINUX = 'https://download.eclipse.org/theia/ide-preview/latest/linux';

const { autoUpdater } = require('electron-updater');

Expand All @@ -26,27 +35,32 @@ export class TheiaUpdaterImpl implements TheiaUpdater, ElectronMainApplicationCo
protected clients: Array<TheiaUpdaterClient> = [];

private initialCheck: boolean = true;
private updateChannelReported: boolean = false;
private reportOnFirstRegistration: boolean = false;

constructor() {
autoUpdater.autoDownload = false;
autoUpdater.on('update-available', () => {
const startupCheck = this.initialCheck;
if (this.initialCheck) {
this.initialCheck = false;
if (this.clients.length === 0) {
this.reportOnFirstRegistration = true;
if (this.updateChannelReported) {
const startupCheck = this.initialCheck;
if (this.initialCheck) {
this.initialCheck = false;
if (this.clients.length === 0) {
this.reportOnFirstRegistration = true;
}
}
this.clients.forEach(c => c.updateAvailable(true, startupCheck));
}
this.clients.forEach(c => c.updateAvailable(true, startupCheck));
});
autoUpdater.on('update-not-available', () => {
if (this.initialCheck) {
this.initialCheck = false;
/* do not report that no update is available on start up */
return;
if (this.updateChannelReported) {
if (this.initialCheck) {
this.initialCheck = false;
/* do not report that no update is available on start up */
return;
}
this.clients.forEach(c => c.updateAvailable(false, false));
}
this.clients.forEach(c => c.updateAvailable(false, false));
});

autoUpdater.on('update-downloaded', () => {
Expand Down Expand Up @@ -102,6 +116,26 @@ export class TheiaUpdaterImpl implements TheiaUpdater, ElectronMainApplicationCo
}
}

setUpdateChannel(channel: string): void {
const feedURL = this.getFeedURL(channel);
autoUpdater.setFeedURL(feedURL);
if (!this.updateChannelReported) {
this.updateChannelReported = true;
this.checkForUpdates();
}
}

protected getFeedURL(channel: string): string {
if (isWindows) {
const curVersion = autoUpdater.currentVersion.toString();
return (channel === 'preview') ? PREVIEW_CHANNEL_WINDOWS.replace('version', curVersion) : STABLE_CHANNEL_WINDOWS.replace('version', curVersion);
} else if (isOSX) {
return (channel === 'preview') ? PREVIEW_CHANNEL_MACOS : STABLE_CHANNEL_MACOS;
} else {
return (channel === 'preview') ? PREVIEW_CHANNEL_LINUX : STABLE_CHANNEL_LINUX;
}
}

disconnectClient(client: TheiaUpdaterClient): void {
const index = this.clients.indexOf(client);
if (index !== -1) {
Expand Down

0 comments on commit 257d3bc

Please sign in to comment.