diff --git a/.editorconfig b/.editorconfig index cff859cf..f8770cdb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,10 @@ indent_style = tab insert_final_newline = true trim_trailing_whitespace = true +[{package.json,package-lock.json}] +indent_size = 2 +indent_style = space + [{*.css, *.scss}] tab_width = 2 diff --git a/README.md b/README.md index e2cb9963..c15135e5 100644 --- a/README.md +++ b/README.md @@ -97,23 +97,24 @@ npm run dev ### Build binaries for production ```bash -# 🖥️ Current platform +# 🖥️ Current platform and architecture npm run build -# 🐧 Linux +# 🐧 Linux (x64) npm run build:linux -# 🍏 Mac (Darwin) +# 🍏 macOS (universal) npm run build:mac +# 🍏 macOS (separate x64 and arm64) +npm run build:mac:x64 +npm run build:mac:arm64 -# 🪟 Windows (win32) +# 🪟 Windows (win32-x64) npm run build:windows - -# All -npm run build:all ``` Notes: +- **General recommendation is to always build binaries on the same platform** - Building Windows binaries on Linux/Mac requires Wine - Building Mac binaries on Windows is not supported - Building Linux binaries on Windows is not supported for some Linux distributions @@ -140,17 +141,17 @@ node ./scripts/fetch-server-styles.mjs stable29 ## 📦 Packaging distributions ```bash -# 🐧 Linux +# 🐧 Linux (x64) npm run package:linux -# 🍏 Mac (Darwin) +# 🍏 macOS (universal) npm run package:mac +# 🍏 macOS (separate x64 and arm64) +npm run package:mac:arm64 +npm run package:mac:x64 -# 🪟 Windows (win32) +# 🪟 Windows (win32-x64) npm run package:windows - -# All -npm run package:all ``` ## ✈️ Release @@ -198,9 +199,9 @@ npm run package:all ```md > 📥 Download Binaries on https://github.com/nextcloud-releases/talk-desktop/releases/tag/v$(version) ``` -9. Package release for specified platforms: +9. Package release on each platform separately: ```sh - npm run release:package -- --windows --linux --mac + npm run release:package ``` 10. Upload packages to the GitHub Releases on [nextcloud-releases/talk-desktop](https://github.com/nextcloud-releases/talk-desktop/releases/lastest) 11. Publish both releases on GitHub Releases diff --git a/package.json b/package.json index 51b6713a..2d09e0a6 100644 --- a/package.json +++ b/package.json @@ -20,14 +20,16 @@ "dev": "electron-forge start", "build": "electron-forge package", "build:linux": "electron-forge package --platform=linux", - "build:mac": "electron-forge package --platform=darwin", + "build:mac": "electron-forge package --platform=darwin --arch=universal", + "build:mac:x64": "electron-forge package --platform=darwin --arch=x64", + "build:mac:arm64": "electron-forge package --platform=darwin --arch=arm64", "build:windows": "electron-forge package --platform=win32", - "build:all": "electron-forge package --platform=all", "package": "electron-forge make --skip-package", "package:linux": "electron-forge make --skip-package --platform=linux", - "package:mac": "electron-forge make --skip-package --platform=darwin", + "package:mac": "electron-forge make --skip-package --platform=darwin --arch=universal", + "package:mac:x64": "electron-forge make --skip-package --platform=darwin --arch=x64", + "package:mac:arm64": "electron-forge make --skip-package --platform=darwin --arch=arm64", "package:windows": "electron-forge make --skip-package --platform=win32", - "package:all": "npm run make:linux && npm run make:mac && npm run make:windows", "release:package": "zx ./scripts/prepare-release-packages.mjs", "generate-icons": "node ./scripts/generate-icons.js", "download-vue-devtools": "node ./scripts/download-vue-devtools.mjs", diff --git a/scripts/prepare-release-packages.mjs b/scripts/prepare-release-packages.mjs index 361f754c..c521f33b 100644 --- a/scripts/prepare-release-packages.mjs +++ b/scripts/prepare-release-packages.mjs @@ -4,6 +4,7 @@ */ import { $, echo, spinner, argv, fs, os, usePwsh } from 'zx' +// eslint-disable-next-line no-undef const packageJson = require('../package.json') const TALK_PATH = './out/.temp/spreed/' @@ -11,8 +12,14 @@ const talkDotGit = `${TALK_PATH}.git` $.quiet = true +/** + * Exit with message and code + * @param {string} message - The error message + * @param {number} code - The exit code + */ function exit(message, code) { echo(message) + // eslint-disable-next-line n/no-process-exit process.exit(code) } @@ -23,13 +30,17 @@ function help() { echo`Prepare release packages for Talk Desktop with Talk in ${TALK_PATH} Usage: npm run release:package -- --linux --mac --windows --version=v20.0.0 + If no platform is specified, the current platform will be used. + If no version is specified, the stable version from package.json will be used. Args: --help - show help --version - Optionally a specific Talk version/branch to build with, for example, v20.0.0-rc.1 or main. Default to stable in package.json. --windows - build Windows package --linux - build Linux package - --mac - build macOS package + --mac - build macOS package using universal architecture (recommended) + --mac-x64 - build macOS package using x64 architecture + --mac-arm64 - build macOS package using arm64 architecture --skip-install - skip npm ci in both repositories ` exit('', 0) @@ -43,9 +54,10 @@ function help() { async function prepareRelease() { const version = argv.version ?? packageJson.talk.stable - // Validate arguments - if (!argv.windows && !argv.linux && !argv.mac) { - exit('❌ You must specify at least one of --windows, --linux or --mac', 1) + // Default to the current platform + if (!argv.windows && !argv.linux && !argv.mac && !argv['mac-x64'] && !argv['mac-arm64']) { + const platform = process.platform === 'darwin' ? 'mac' : process.platform === 'win32' ? 'windows' : 'linux' + argv[platform] = true } echo`Packaging Nextcloud Talk v${packageJson.version} with Talk ${version}...` @@ -56,7 +68,7 @@ async function prepareRelease() { // Check Talk Desktop repository echo`[1/5] Check for uncommitted changes in Talk Desktop` if ((await $`git status -s`).stdout) { - exit(`❌ You have uncommitted changes in the Talk Desktop repository`, 1) + exit('❌ You have uncommitted changes in the Talk Desktop repository', 1) } // Check and prepare Talk repository @@ -65,24 +77,24 @@ async function prepareRelease() { echo`- Talk has been found in ${TALK_PATH}` echo`[3.1/5] Check for uncommitted changes in Talk repository` if ((await gitSpreed(['status', '-s'])).stdout) { - exit(`❌ You have uncommitted changes in the Talk repository`, 1) + exit('❌ You have uncommitted changes in the Talk repository', 1) } echo`[3.2/5] Fetch Talk ${version} from origin` await spinner( `Fetch Talk ${version} from origin`, - () => gitSpreed(['fetch', '--no-tags', '--depth=1', 'origin', 'tag', version]) + () => gitSpreed(['fetch', '--no-tags', '--depth=1', 'origin', 'tag', version]), ) echo`[3.3/5] Checkout Talk ${version}` await spinner( `Checkout Talk ${version}`, - () => gitSpreed(['checkout', version]) + () => gitSpreed(['checkout', version]), ) } else { echo`- No Talk has been found in ${TALK_PATH}` echo`[3/5] Clone Talk@${version} to ${TALK_PATH}` await spinner( `Cloning Talk@${version} to ${TALK_PATH}`, - () => $`git clone --branch=${version} --depth=1 -- https://github.com/nextcloud/spreed ${TALK_PATH}` + () => $`git clone --branch=${version} --depth=1 -- https://github.com/nextcloud/spreed ${TALK_PATH}`, ) } @@ -91,12 +103,12 @@ async function prepareRelease() { echo`[4/5] Install dependencies` await spinner( 'Installing dependencies in Talk Desktop', - () => $`npm ci` + () => $`npm ci`, ) await spinner( 'Installing dependencies in Talk', - () => $`npm ci --prefix ${TALK_PATH}` + () => $`npm ci --prefix ${TALK_PATH}`, ) } else { echo`SKIPPED [5/5] Install dependencies` @@ -108,6 +120,8 @@ async function prepareRelease() { argv.windows && await spinner('Package Windows', () => $`npm run build:windows && npm run package:windows`) argv.linux && await spinner('Package Linux', () => $`npm run build:linux && npm run package:linux`) argv.mac && await spinner('Package MacOS', () => $`npm run build:mac && npm run package:mac`) + argv['mac-x64'] && await spinner('Package MacOS x64', () => $`npm run build:mac-x64 && npm run package:mac-x64`) + argv['mac-arm64'] && await spinner('Package MacOS arm64', () => $`npm run build:mac-arm64 && npm run package:mac-arm64`) // Done echo`Done. See output in ./out/make/`