Skip to content

Commit

Permalink
Update Checksums for Mac Build after Signing #422
Browse files Browse the repository at this point in the history
* also extend update checksum script to have more control over what
happens (when to update paths, which files to update)
* bump versions to 1.57.102
  • Loading branch information
jfaltermeier committed Jan 16, 2025
1 parent 57e3a13 commit 6cb0122
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 28 deletions.
81 changes: 70 additions & 11 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,74 @@ spec:
}
}
stage('Sign, Notarize and Upload Mac') {
agent any
agent {
kubernetes {
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: theia-dev
image: eclipsetheia/theia-blueprint:builder
imagePullPolicy: Always
command:
- cat
tty: true
resources:
limits:
memory: "8Gi"
cpu: "2"
requests:
memory: "8Gi"
cpu: "2"
volumeMounts:
- name: global-cache
mountPath: /.cache
- name: global-yarn
mountPath: /.yarn
- name: global-npm
mountPath: /.npm
- name: electron-cache
mountPath: /.electron-gyp
- name: jnlp
volumeMounts:
- name: volume-known-hosts
mountPath: /home/jenkins/.ssh
volumes:
- name: global-cache
emptyDir: {}
- name: global-yarn
emptyDir: {}
- name: global-npm
emptyDir: {}
- name: electron-cache
emptyDir: {}
- name: volume-known-hosts
configMap:
name: known-hosts
"""
}
}
steps {
unstash 'mac'
script {
signInstaller('zip', 'mac')
signInstaller('dmg', 'mac')
notarizeInstaller('zip')
notarizeInstaller('dmg')
uploadInstaller('macos')
container('theia-dev') {
withCredentials([string(credentialsId: "github-bot-token", variable: 'GITHUB_TOKEN')]) {
script {
def packageJSON = readJSON file: "package.json"
String version = "${packageJSON.version}"
signInstaller('zip', 'mac')
signInstaller('dmg', 'mac')
notarizeInstaller('zip')
notarizeInstaller('dmg')
updateMetadata('TheiaIDE-' + version + '-mac.zip', 'latest-mac.yml', 'macos', false, '.zip', 1200)
updateMetadata('TheiaIDE.dmg', 'latest-mac.yml', 'macos', false, '.dmg', 1200)
}
}
}
container('jnlp') {
script {
uploadInstaller('macos')
}
}
}
}
Expand Down Expand Up @@ -260,7 +319,7 @@ spec:
withCredentials([string(credentialsId: "github-bot-token", variable: 'GITHUB_TOKEN')]) {
script {
signInstaller('exe', 'windows')
updateMetadata('TheiaIDESetup.exe', 'latest.yml', 'windows', 1200)
updateMetadata('TheiaIDESetup.exe', 'latest.yml', 'windows', true, '.exe', 1200)
}
}
}
Expand Down Expand Up @@ -378,7 +437,7 @@ def notarizeInstaller(String ext) {
}
}

def updateMetadata(String executable, String yaml, String platform, int sleepBetweenRetries) {
def updateMetadata(String executable, String yaml, String platform, Boolean updatePaths, String fileExtension, int sleepBetweenRetries) {
if (!isRelease()) {
echo "This is not a release, so skipping updating metadata for branch ${env.BRANCH_NAME}"
return
Expand All @@ -389,14 +448,14 @@ def updateMetadata(String executable, String yaml, String platform, int sleepBet
// make sure the npm dependencies are available to the update scripts
sh "yarn install --force"
sh "yarn electron update:blockmap -e ${executable}"
sh "yarn electron update:checksum -e ${executable} -y ${yaml} -p ${platform}"
sh "yarn electron update:checksum -e ${executable} -y ${yaml} -p ${platform} -u ${updatePaths} -f ${fileExtension}"
} catch (error) {
retry(maxRetry) {
sleep(sleepBetweenRetries)
echo "yarn failed - Retrying"
sh "yarn install --force"
sh "yarn electron update:blockmap -e ${executable}"
sh "yarn electron update:checksum -e ${executable} -y ${yaml} -p ${platform}"
sh "yarn electron update:checksum -e ${executable} -y ${yaml} -p ${platform} -u ${updatePaths} -f ${fileExtension}"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions applications/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "theia-ide-browser-app",
"description": "Eclipse Theia IDE browser product",
"productName": "Theia IDE",
"version": "1.57.101",
"version": "1.57.102",
"license": "MIT",
"author": "Eclipse Theia <[email protected]>",
"homepage": "https://github.com/eclipse-theia/theia-ide#readme",
Expand Down Expand Up @@ -102,7 +102,7 @@
"@theia/vsx-registry": "1.57.1",
"@theia/workspace": "1.57.1",
"fs-extra": "^9.0.1",
"theia-ide-product-ext": "1.57.101"
"theia-ide-product-ext": "1.57.102"
},
"devDependencies": {
"@theia/cli": "1.57.1"
Expand Down
8 changes: 4 additions & 4 deletions applications/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "theia-ide-electron-app",
"description": "Eclipse Theia IDE product",
"productName": "Theia IDE",
"version": "1.57.101",
"version": "1.57.102",
"main": "scripts/theia-electron-main.js",
"license": "MIT",
"author": "Eclipse Theia <[email protected]>",
Expand Down Expand Up @@ -112,9 +112,9 @@
"@theia/vsx-registry": "1.57.1",
"@theia/workspace": "1.57.1",
"fs-extra": "^9.0.1",
"theia-ide-launcher-ext": "1.57.101",
"theia-ide-product-ext": "1.57.101",
"theia-ide-updater-ext": "1.57.101"
"theia-ide-launcher-ext": "1.57.102",
"theia-ide-product-ext": "1.57.102",
"theia-ide-updater-ext": "1.57.102"
},
"devDependencies": {
"@theia/cli": "1.57.1",
Expand Down
3 changes: 3 additions & 0 deletions applications/electron/scripts/update-blockmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ async function execute(): Promise<void> {
executable
);
const blockMapFile = `${executablePath}${BLOCK_MAP_FILE_SUFFIX}`;

console.log(`Exe: ${executablePath}; Blockmap: ${blockMapFile}`);

rmSync(blockMapFile, {
force: true,
});
Expand Down
28 changes: 22 additions & 6 deletions applications/electron/scripts/update-checksum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const argv = yargs(hideBin(process.argv))
.option('executable', { alias: 'e', type: 'string', default: 'TheiaIDE.AppImage', description: 'The executable for which the checksum needs to be updated' })
.option('yaml', { alias: 'y', type: 'string', default: 'latest-linux.yml', description: 'The yaml file where the checksum needs to be updated' })
.option('platform', { alias: 'p', type: 'string', default: 'linux', description: 'The OS platform' })
.option('updatepaths', { alias: 'u', type: 'boolean', default: true, description: 'Whether to update the paths from absolute to relative' })
.option('fileextension', { alias: 'f', type: 'string', default: '.AppImage', description: 'Only paths/urls with this extension will be updated' })
.version(false)
.wrap(120)
.parseSync();
Expand All @@ -27,6 +29,8 @@ async function execute(): Promise<void> {
const executable = argv.executable;
const yaml = argv.yaml;
const platform = argv.platform;
const updatePaths = argv.updatepaths;
const fileExtension = argv.fileextension;

const executablePath = path.resolve(
__dirname,
Expand All @@ -40,24 +44,36 @@ async function execute(): Promise<void> {
yaml
);

console.log('Exe: ' + executablePath + '; Yaml: ' + yamlPath + '; Platform: ' + platform);
console.log(`Exe: ${executablePath}; Yaml: ${yamlPath}; Platform: ${platform}; Update Paths: ${updatePaths}; File Extension: ${fileExtension}`);

const hash = await hashFile(executablePath, 'sha512', 'base64', {});
const size = fs.statSync(executablePath).size;

const yamlContents: string = fs.readFileSync(yamlPath, { encoding: 'utf8' });
console.log(`Initial Yaml Contents: ${yamlContents}`);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const latestYaml: any = jsyaml.safeLoad(yamlContents);
latestYaml.sha512 = hash;
latestYaml.path = updatedPath(latestYaml.path, latestYaml.version, platform);

if (latestYaml.path.endsWith(fileExtension)) {
latestYaml.sha512 = hash;
if (updatePaths) {
latestYaml.path = updatedPath(latestYaml.path, latestYaml.version, platform);
}
}

for (const file of latestYaml.files) {
file.sha512 = hash;
file.size = size;
file.url = updatedPath(file.url, latestYaml.version, platform);
if (file.url.endsWith(fileExtension)) {
file.sha512 = hash;
file.size = size;
if (updatePaths) {
file.url = updatedPath(file.url, latestYaml.version, platform);
}
}
}

// line width -1 to avoid adding >- on long strings like a hash
const newYamlContents = jsyaml.dump(latestYaml, { lineWidth: -1 });
console.log(`New Yaml Contents: ${newYamlContents}`);
fs.writeFileSync(yamlPath, newYamlContents);
}

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "4.0.0",
"version": "1.57.101",
"version": "1.57.102",
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "1.57.101",
"version": "1.57.102",
"license": "MIT",
"author": "Rob Moran <[email protected]>",
"homepage": "https://github.com/eclipse-theia/theia-ide#readme",
Expand Down
2 changes: 1 addition & 1 deletion theia-extensions/launcher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "theia-ide-launcher-ext",
"version": "1.57.101",
"version": "1.57.102",
"keywords": [
"theia-extension"
],
Expand Down
2 changes: 1 addition & 1 deletion theia-extensions/product/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "theia-ide-product-ext",
"version": "1.57.101",
"version": "1.57.102",
"description": "Eclipse Theia IDE Product Branding",
"dependencies": {
"@theia/core": "1.57.1",
Expand Down
2 changes: 1 addition & 1 deletion theia-extensions/updater/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "theia-ide-updater-ext",
"version": "1.57.101",
"version": "1.57.102",
"description": "Eclipse Theia IDE Updater",
"dependencies": {
"@theia/core": "1.57.1",
Expand Down

0 comments on commit 6cb0122

Please sign in to comment.