diff --git a/electron-builder.json b/electron-builder.json index a74e25cd..60ef3059 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -38,6 +38,7 @@ ], "afterPack": "scripts/afterpack.js", "afterSign": "scripts/notarize.js", + "afterAllArtifactBuild": "scripts/afterbuild.js", "deb": { "artifactName": "${version}/${name}_${version}-1_${arch}.${ext}", "synopsis": "Mattermost Desktop App", diff --git a/scripts/afterbuild.js b/scripts/afterbuild.js new file mode 100644 index 00000000..2b8d8b7e --- /dev/null +++ b/scripts/afterbuild.js @@ -0,0 +1,25 @@ +// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +const {spawnSync} = require('child_process'); + +const {path7za} = require('7zip-bin'); + +const windowsZipRegex = /win-[A-Za-z0-9]+\.zip$/g; + +async function removeAppUpdate(path) { + const result = await spawnSync(path7za, ['d', path, 'resources/app-update.yml', '-r']); + if (result.error) { + throw new Error( + `Failed to remove files from ${path}: ${result.error} ${result.stderr} ${result.stdout}`, + ); + } +} + +exports.default = async function afterAllArtifactBuild(context) { + await context.artifactPaths.forEach(async (path) => { + if (path.match(windowsZipRegex)) { + await removeAppUpdate(path); + } + }); +}; diff --git a/scripts/generate_release_markdown.sh b/scripts/generate_release_markdown.sh index 60e66961..5dfd1269 100755 --- a/scripts/generate_release_markdown.sh +++ b/scripts/generate_release_markdown.sh @@ -28,6 +28,10 @@ $(print_link "${BASE_URL}/mattermost-desktop-${VERSION}-x86.msi") #### Windows - setup exe files $(print_link "${BASE_URL}/mattermost-desktop-setup-${VERSION}-win.exe") +#### Windows - zip files +$(print_link "${BASE_URL}/mattermost-desktop-${VERSION}-win32.zip") +$(print_link "${BASE_URL}/mattermost-desktop-${VERSION}-win64.zip") + #### Mac $(print_link "${BASE_URL}/mattermost-desktop-${VERSION}-mac-universal.dmg") $(print_link "${BASE_URL}/mattermost-desktop-${VERSION}-mac-x64.dmg") diff --git a/src/common/config/index.ts b/src/common/config/index.ts index 7c818d2e..c2a06c70 100644 --- a/src/common/config/index.ts +++ b/src/common/config/index.ts @@ -41,6 +41,12 @@ function checkWriteableApp() { if (process.platform === 'win32') { try { fs.accessSync(path.join(path.dirname(app.getAppPath()), '../../'), fs.constants.W_OK); + + // check to make sure that app-update.yml exists + if (!fs.existsSync(path.join(process.resourcesPath, 'app-update.yml'))) { + log.warn('app-update.yml does not exist, disabling auto-updates'); + return false; + } } catch (error) { log.info(`${app.getAppPath()}: ${error}`); log.warn('autoupgrade disabled');