Skip to content

Commit

Permalink
Merge pull request #896 from nextcloud/build/add-arch-to-scripts
Browse files Browse the repository at this point in the history
build(mac): default to universal arch and adjust scripts and docs
  • Loading branch information
ShGKme authored Nov 15, 2024
2 parents cd63aac + 77dd580 commit f7af2cd
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 30 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
36 changes: 25 additions & 11 deletions scripts/prepare-release-packages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@
*/

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/'
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)
}

Expand All @@ -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)
Expand All @@ -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}...`
Expand All @@ -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
Expand All @@ -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}`,
)
}

Expand All @@ -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`
Expand All @@ -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/`
Expand Down

0 comments on commit f7af2cd

Please sign in to comment.