Skip to content

Commit edb12bb

Browse files
authored
Revert "update build and release workflow (#1597)" (#1599)
This reverts commit b3c77e6.
1 parent af9340b commit edb12bb

File tree

10 files changed

+348
-295
lines changed

10 files changed

+348
-295
lines changed

.github/workflows/matter.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ jobs:
8989
- name: Build & Release for Linux
9090
if: startsWith(matrix.os, 'ubuntu')
9191
run: |
92-
node src-script/build-release-package.js --platform l
92+
npm run pack:linux
93+
npm run pkg:linux
94+
ls ./dist/
95+
npm run pack:cli:linux
9396
9497
mv dist/zap-linux-amd64.deb dist/zap-linux-x64.deb
9598
mv dist/zap-linux-x86_64.rpm dist/zap-linux-x64.rpm

.github/workflows/release.yml

Lines changed: 181 additions & 163 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@
106106
"pack:win": "cross-env NODE_OPTIONS=--max-old-space-size=4096 electron-builder -w",
107107
"pack:mac": "cross-env NODE_OPTIONS=--max-old-space-size=4096 electron-builder -m",
108108
"pack:mac:native": "cross-env NODE_OPTIONS=--max-old-space-size=4096 electron-builder -m",
109+
"pack:cli:linux": "node ./src-script/pack-cli.js -p linux",
110+
"pack:cli:win": "node ./src-script/pack-cli.js -p win",
111+
"pack:cli:mac": "node ./src-script/pack-cli.js -p mac",
109112
"pkg": "npx pkg --out-path dist/ --compress GZip --options max-old-space-size=4096 .",
110113
"pkg:linux": "npx pkg -t node18-linux-x64,node18-linux-arm64 --public --no-bytecode --output dist/zap-linux --compress GZip --options max-old-space-size=4096 .",
111114
"pkg-use-local-fork": "node ../pkg/lib-es5/bin.js -t node18-linux-x64 --output dist/zap-linux --compress GZip --options max-old-space-size=4096 .",
112115
"pkg:win": "npx pkg -t node18-win-x64,node18-win-arm64 --public --no-bytecode --output dist/zap-win --compress GZip --options max-old-space-size=4096 .",
113-
"pkg:mac": "npx pkg -t node18-macos-x64,node18-macos-arm64 --output dist/zap-macos --compress GZip --options max-old-space-size=4096 .",
116+
"pkg:mac": "npx pkg -t node18-macos-x64 --output dist/zap-macos --compress GZip --options max-old-space-size=4096 .",
114117
"dist": "node src-script/build-release-package.js --output dist/release",
115118
"dist:mac": "node src-script/build-release-package.js --platform m --output dist/release",
116119
"dist:win": "node src-script/build-release-package.js --platform w --output dist/release",
@@ -222,8 +225,8 @@
222225
"build": {
223226
"appId": "zap.id",
224227
"artifactName": "${productName}-${os}-${arch}.${ext}",
225-
"afterPack": "./src-script/after-pack-linux.js",
226-
"afterAllArtifactBuild": "./src-script/after-all-artifacts.js",
228+
"afterPack": "./src-script/pack-apack-win-linux.js",
229+
"afterAllArtifactBuild": "./src-script/pack-apack-mac.js",
227230
"mac": {
228231
"category": "public.app-category.developer-tools",
229232
"darkModeSupport": true,

src-script/after-all-artifacts.js

Lines changed: 0 additions & 86 deletions
This file was deleted.

src-script/after-pack-linux.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

src-script/build-release-package.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ async function buildForOS(osName, outputPath) {
3232
switch (osName) {
3333
case 'm':
3434
console.log(`Building for Mac... Output: ${outputPath}`)
35-
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:mac']) // Building zap-cli
3635
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:mac']) // Building electron app
36+
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:mac']) // Building zap-cli
37+
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:cli:mac']) // Adding zap-cli to zip file
3738
if (outputPath) {
3839
await scriptUtil.executeCmd({}, 'mv', [
3940
'./dist/zap-mac-x64.zip',
@@ -48,8 +49,9 @@ async function buildForOS(osName, outputPath) {
4849

4950
case 'w':
5051
console.log(`Building for Windows... Output: ${outputPath}`)
51-
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:win']) // Building zap-cli
5252
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:win']) // Building electron app
53+
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:win']) // Building zap-cli
54+
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:cli:win']) // Adding zap-cli to zip file
5355
if (outputPath) {
5456
await scriptUtil.executeCmd({}, 'mv', [
5557
'dist/zap-win-x64.zip',
@@ -64,8 +66,9 @@ async function buildForOS(osName, outputPath) {
6466

6567
case 'l':
6668
console.log(`Building for Linux... Output: ${outputPath}`)
67-
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:linux']) // Building zap-cli
6869
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:linux']) // Building electron app
70+
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:linux']) // Building zap-cli
71+
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:cli:linux']) // Adding zap-cli to zip file
6972
if (outputPath) {
7073
await scriptUtil.executeCmd({}, 'mv', [
7174
'dist/zap-linux-x64.zip',

src-script/install-packages-ubuntu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# to get source build to compile via npm install or npm ci
55
#
66
apt-get update
7-
apt-get install -y --fix-missing libpixman-1-dev libcairo-dev libsdl-pango-dev libjpeg-dev libgif-dev rpm
7+
apt-get install -y --fix-missing libpixman-1-dev libcairo-dev libsdl-pango-dev libjpeg-dev libgif-dev

src-script/pack-apack-mac.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const Seven = require('node-7z')
4+
const sevenBin = require('7zip-bin')
5+
const pathTo7zip = sevenBin.path7za
6+
7+
exports.default = async function (buildResult) {
8+
for (const element of buildResult?.artifactPaths || []) {
9+
if (
10+
(element.includes('mac') ||
11+
element.includes('win') ||
12+
element.includes('linux')) &&
13+
element.endsWith('.zip')
14+
) {
15+
// Add apack.json first
16+
await new Promise((resolve, reject) => {
17+
const myStream1 = Seven.add(
18+
element, // The .zip file (output)
19+
path.join(buildResult.outDir, '../apack.json'), // Add apack.json
20+
{
21+
$progress: true,
22+
$bin: pathTo7zip
23+
}
24+
)
25+
26+
myStream1.on('end', resolve)
27+
myStream1.on('error', (err) => {
28+
console.log('Error adding apack.json:', err.stderr)
29+
reject(err)
30+
})
31+
})
32+
33+
// Then add zap.png after apack.json is added
34+
await new Promise((resolve, reject) => {
35+
const myStream2 = Seven.add(
36+
element, // The .zip file (output)
37+
path.join(buildResult.outDir, '../src/assets/zap.png'), // Add zap.png
38+
{
39+
$progress: true,
40+
$bin: pathTo7zip
41+
}
42+
)
43+
44+
myStream2.on('end', resolve)
45+
myStream2.on('error', (err) => {
46+
console.log('Error adding zap.png:', err.stderr)
47+
reject(err)
48+
})
49+
})
50+
}
51+
}
52+
}

src-script/pack-apack-win-linux.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const scriptUtil = require('./script-util.js')
2+
const path = require('path')
3+
4+
exports.default = async function (context) {
5+
if (
6+
context.electronPlatformName === 'win32' ||
7+
context.electronPlatformName === 'linux'
8+
) {
9+
await scriptUtil.executeCmd({}, 'npx', [
10+
'copyfiles',
11+
'-V',
12+
'-f',
13+
path.resolve(context.outDir, '../apack.json'),
14+
path.resolve(context.outDir, '../src/assets/zap.png'),
15+
context.appOutDir
16+
])
17+
console.log('Files copied successfully.')
18+
}
19+
}

src-script/pack-cli.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
'use strict'
2+
3+
// Utilty script for adding ${cli} binaries to zap binaries generated via "pack:$platform" NPM targets
4+
5+
const zip = require('../node_modules/7zip-bin/index')
6+
const scriptUtil = require('./script-util.js')
7+
const fsp = require('fs/promises')
8+
const yargs = require('yargs/yargs')
9+
const { hideBin } = require('yargs/helpers')
10+
const argv = yargs(hideBin(process.argv)).argv
11+
const baseDir = `${__dirname}/../`
12+
const dist = `${baseDir}/dist`
13+
console.log(argv)
14+
15+
const platform = argv.p ? argv.p : process.platform
16+
17+
/**
18+
* Zip file
19+
* @param {*} dst
20+
* @param {*} filename
21+
*/
22+
async function addToZip(dst, filename) {
23+
await scriptUtil.executeCmd({}, zip.path7za, [
24+
'a',
25+
`${dist}/${dst}`,
26+
`${dist}/${filename}`
27+
])
28+
}
29+
30+
/**
31+
* Rename file
32+
* @param {*} oldPath
33+
* @param {*} newPath
34+
*/
35+
async function rename(oldPath, newPath) {
36+
await fsp.rename(`${dist}/${oldPath}`, `${dist}/${newPath}`)
37+
}
38+
39+
/**
40+
* Package ZAP.
41+
*/
42+
async function main() {
43+
if (platform.includes('darwin') || platform.includes('mac')) {
44+
let file = 'zap-macos'
45+
let cli = `zap-cli`
46+
47+
await rename(`${file}`, cli)
48+
await addToZip(`zap-mac-x64.zip`, cli)
49+
50+
// NOTE: `pkg` build tool does not officially support building for mac arch64 yet.
51+
// until official support is out, x86 version will be packaged as
52+
// Apple Rosetta will kick in.
53+
await addToZip(`zap-mac-arm64.zip`, cli)
54+
55+
// NOTE: pkg support for macos-arm64 is experimental
56+
// await rename(`${file}-arm64`, cli)
57+
// await addToZip(`${file}-arm64.zip`, cli)
58+
} else if (platform.includes('win')) {
59+
let file = 'zap-win'
60+
let cli = `zap-cli.exe`
61+
62+
await rename(`${file}-x64.exe`, cli)
63+
await addToZip(`${file}-x64.zip`, cli)
64+
65+
await rename(`${file}-arm64.exe`, cli)
66+
await addToZip(`${file}-arm64.zip`, cli)
67+
} else if (platform.includes('linux')) {
68+
let file = 'zap-linux'
69+
let cli = `zap-cli`
70+
71+
await rename(`${file}-x64`, cli)
72+
await addToZip(`${file}-x64.zip`, cli)
73+
74+
await rename(`${file}-arm64`, cli)
75+
await addToZip(`${file}-arm64.zip`, cli)
76+
}
77+
}
78+
79+
main()

0 commit comments

Comments
 (0)