8000 Revert "update build and release workflow" by dhchandw · Pull Request #1599 · project-chip/zap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Revert "update build and release workflow" #1599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/matter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ jobs:
- name: Build & Release for Linux
if: startsWith(matrix.os, 'ubuntu')
run: |
node src-script/build-release-package.js --platform l
npm run pack:linux
npm run pkg:linux
ls ./dist/
npm run pack:cli:linux

mv dist/zap-linux-amd64.deb dist/zap-linux-x64.deb
mv dist/zap-linux-x86_64.rpm dist/zap-linux-x64.rpm
Expand Down
344 changes: 181 additions & 163 deletions .github/workflows/release.yml

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@
"pack:win": "cross-env NODE_OPTIONS=--max-old-space-size=4096 electron-builder -w",
"pack:mac": "cross-env NODE_OPTIONS=--max-old-space-size=4096 electron-builder -m",
"pack:mac:native": "cross-env NODE_OPTIONS=--max-old-space-size=4096 electron-builder -m",
"pack:cli:linux": "node ./src-script/pack-cli.js -p linux",
"pack:cli:win": "node ./src-script/pack-cli.js -p win",
"pack:cli:mac": "node ./src-script/pack-cli.js -p mac",
"pkg": "npx pkg --out-path dist/ --compress GZip --options max-old-space-size=4096 .",
"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 .",
"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 .",
"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 .",
"pkg:mac": "npx pkg -t node18-macos-x64,node18-macos-arm64 --output dist/zap-macos --compress GZip --options max-old-space-size=4096 .",
"pkg:mac": "npx pkg -t node18-macos-x64 --output dist/zap-macos --compress GZip --options max-old-space-size=4096 .",
"dist": "node src-script/build-release-package.js --output dist/release",
"dist:mac": "node src-script/build-release-package.js --platform m --output dist/release",
"dist:win": "node src-script/build-release-package.js --platform w --output dist/release",
Expand Down Expand Up @@ -222,8 +225,8 @@
"build": {
"appId": "zap.id",
"artifactName": "${productName}-${os}-${arch}.${ext}",
"afterPack": "./src-script/after-pack-linux.js",
"afterAllArtifactBuild": "./src-script/after-all-artifacts.js",
"afterPack": "./src-script/pack-apack-win-linux.js",
"afterAllArtifactBuild": "./src-script/pack-apack-mac.js",
"mac": {
"category": "public.app-category.developer-tools",
"darkModeSupport": true,
Expand Down
86 changes: 0 additions & 86 deletions src-script/after-all-artifacts.js

This file was deleted.

38 changes: 0 additions & 38 deletions src-script/after-pack-linux.js

This file was deleted.

9 changes: 6 additions & 3 deletions src-script/build-release-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ async function buildForOS(osName, outputPath) {
switch (osName) {
case 'm':
console.log(`Building for Mac... Output: ${outputPath}`)
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:mac']) // Building zap-cli
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:mac']) // Building electron app
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:mac']) // Building zap-cli
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:cli:mac']) // Adding zap-cli to zip file
if (outputPath) {
await scriptUtil.executeCmd({}, 'mv', [
'./dist/zap-mac-x64.zip',
Expand All @@ -48,8 +49,9 @@ async function buildForOS(osName, outputPath) {

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

case 'l':
console.log(`Building for Linux... Output: ${outputPath}`)
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:linux']) // Building zap-cli
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:linux']) // Building electron app
await scriptUtil.executeCmd({}, 'npm', ['run', 'pkg:linux']) // Building zap-cli
await scriptUtil.executeCmd({}, 'npm', ['run', 'pack:cli:linux']) // Adding zap-cli to zip file
if (outputPath) {
await scriptUtil.executeCmd({}, 'mv', [
'dist/zap-linux-x64.zip',
Expand Down
2 changes: 1 addition & 1 deletion src-script/install-packages-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# to get source build to compile via npm install or npm ci
#
apt-get update
apt-get install -y --fix-missing libpixman-1-dev libcairo-dev libsdl-pango-dev libjpeg-dev libgif-dev rpm
apt-get install -y --fix-missing libpixman-1-dev libcairo-dev libsdl-pango-dev libjpeg-dev libgif-dev
52 changes: 52 additions & 0 deletions src-script/pack-apack-mac.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const fs = require('fs')
const path = require('path')
const Seven = require('node-7z')
const sevenBin = require('7zip-bin')
const pathTo7zip = sevenBin.path7za

exports.default = async function (buildResult) {
for (const element of buildResult?.artifactPaths || []) {
if (
(element.includes('mac') ||
element.includes('win') ||
element.includes('linux')) &&
element.endsWith('.zip')
) {
// Add apack.json first
await new Promise((resolve, reject) => {
const myStream1 = Seven.add(
element, // The .zip file (output)
path.join(buildResult.outDir, '../apack.json'), // Add apack.json
{
$progress: true,
$bin: pathTo7zip
}
)

myStream1.on('end', resolve)
myStream1.on('error', (err) => {
console.log('Error adding apack.json:', err.stderr)
reject(err)
})
})

// Then add zap.png after apack.json is added
await new Promise((resolve, reject) => {
const myStream2 = Seven.add(
element, // The .zip file (output)
path.join(buildResult.outDir, '../src/assets/zap.png'), // Add zap.png
{
$progress: true,
$bin: pathTo7zip
}
)

myStream2.on('end', resolve)
myStream2.on('error', (err) => {
console.log('Error adding zap.png:', err.stderr)
reject(err)
})
})
}
}
}
19 changes: 19 additions & 0 deletions src-script/pack-apack-win-linux.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const scriptUtil = require('./script-util.js')
const path = require('path')

exports.default = async function (context) {
if (
context.electronPlatformName === 'win32' ||
context.electronPlatformName === 'linux'
) {
await scriptUtil.executeCmd({}, 'npx', [
'copyfiles',
'-V',
'-f',
path.resolve(context.outDir, '../apack.json'),
path.resolve(context.outDir, '../src/assets/zap.png'),
context.appOutDir
])
console.log('Files copied successfully.')
}
}
79 changes: 79 additions & 0 deletions src-script/pack-cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use strict'

// Utilty script for adding ${cli} binaries to zap binaries generated via "pack:$platform" NPM targets

const zip = require('../node_modules/7zip-bin/index')
const scriptUtil = require('./script-util.js')
const fsp = require('fs/promises')
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const argv = yargs(hideBin(process.argv)).argv
const baseDir = `${__dirname}/../`
const dist = `${baseDir}/dist`
console.log(argv)

const platform = argv.p ? argv.p : process.platform

/**
* Zip file
* @param {*} dst
* @param {*} filename
*/
async function addToZip(dst, filename) {
await scriptUtil.executeCmd({}, zip.path7za, [
'a',
`${dist}/${dst}`,
`${dist}/${filename}`
])
}

/**
* Rename file
* @param {*} oldPath
* @param {*} newPath
*/
async function rename(oldPath, newPath) {
await fsp.rename(`${dist}/${oldPath}`, `${dist}/${newPath}`)
}

/**
* Package ZAP.
*/
async function main() {
if (platform.includes('darwin') || platform.includes('mac')) {
let file = 'zap-macos'
let cli = `zap-cli`

await rename(`${file}`, cli)
await addToZip(`zap-mac-x64.zip`, cli)

// NOTE: `pkg` build tool does not officially support building for mac arch64 yet.
// until official support is out, x86 version will be packaged as
// Apple Rosetta will kick in.
await addToZip(`zap-mac-arm64.zip`, cli)

// NOTE: pkg support for macos-arm64 is experimental
// await rename(`${file}-arm64`, cli)
// await addToZip(`${file}-arm64.zip`, cli)
} else if (platform.includes('win')) {
let file = 'zap-win'
let cli = `zap-cli.exe`

await rename(`${file}-x64.exe`, cli)
await addToZip(`${file}-x64.zip`, cli)

await rename(`${file}-arm64.exe`, cli)
await addToZip(`${file}-arm64.zip`, cli)
} else if (platform.includes('linux')) {
let file = 'zap-linux'
let cli = `zap-cli`

await rename(`${file}-x64`, cli)
await addToZip(`${file}-x64.zip`, cli)

await rename(`${file}-arm64`, cli)
await addToZip(`${file}-arm64.zip`, cli)
}
}

main()
0