Skip to content

Commit

Permalink
Merge pull request #60 from qlrd/main
Browse files Browse the repository at this point in the history
Cube flash for official release
  • Loading branch information
qlrd authored Jul 14, 2024
2 parents 71bdc0b + f807d91 commit aae88ce
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 71 deletions.
92 changes: 51 additions & 41 deletions .github/workflows/build-mac-dmg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:

build-macos-12:
runs-on: macos-12
runs-on: macos-latest

steps:

Expand All @@ -33,24 +33,34 @@ jobs:
echo "app-name=$KRUX_NAME"
echo "::endgroup::"
- name: Install node-gyp deps
run: |
python3 --version
#mkdir .krux-installer-node-gyp
#python3 -m venv .krux-installer-node-gyp
#source .krux-installer-node-gyp/bin/activate
#python3 -m pip install distutils
#python3 -m pip install setuptools
brew install python-setuptools
- name: Install dependencies
run: yarn install

#- name: Install chromedriver
#env:
#CHROMEDRIVER_VERSION: '114.0.5735.90'
#ZIPFILE: 'chromedriver_mac64.zip'
#DESTDIR: './node_modules/chromedriver/bin'
#ZIPURI: 'https://chromedriver.storage.googleapis.com'
#run: |
#curl -o ${TMPDIR}${ZIPFILE} $ZIPURI/$CHROMEDRIVER_VERSION/$ZIPFILE
#unzip -o ${TMPDIR}${ZIPFILE} -d $DESTDIR
#- name: Install chromedriver
# env:
# CHROMEDRIVER_VERSION: '114.0.5735.90'
# ZIPFILE: 'chromedriver_mac64.zip'
# DESTDIR: './node_modules/chromedriver/bin'
# ZIPURI: 'https://chromedriver.storage.googleapis.com'
# run: |
# curl -o ${TMPDIR}${ZIPFILE} $ZIPURI/$CHROMEDRIVER_VERSION/$ZIPFILE
# unzip -o ${TMPDIR}${ZIPFILE} -d $DESTDIR

#- name: List chromedriver binaries
#run: ls -la node_modules/chromedriver/bin
#- name: List chromedriver binaries
# run: ls -la node_modules/chromedriver/bin

#- name: Pre-test chromedriver
#run: ./node_modules/chromedriver/bin/chromedriver --version
#- name: Pre-test chromedriver
# run: ./node_modules/chromedriver/bin/chromedriver --version

- name: Build electron app
env:
Expand All @@ -64,34 +74,34 @@ jobs:
file: ${{ steps.setup.outputs.app-name }}.dmg
ext: sha256.txt

- name: List release files
run: |
echo "::group::Release files"
ls -la release/${{ steps.setup.outputs.app-version }}
echo "::endgroup::"
echo "::group::Unpacked files"
ls -la release/${{ steps.setup.outputs.app-version }}/mac
echo "::endgroup::"
echo "::group::Unpacked .app directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app
echo "::endgroup::"
echo "::group::Unpacked .app/Contents directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents
echo "::endgroup::"
echo "::group::Unpacked .app/Contents/Frameworks directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents/Frameworks
echo "::endgroup::"
echo "::group::Unpacked .app/Contents/MacOS directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents/MacOS
echo "::endgroup::"
echo "::group::Unpacked .app/Contents/Resources directory"
ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents/Resources
echo "::endgroup::"
#- name: List release files
# run: |
# echo "::group::Release files"
# ls -la release/${{ steps.setup.outputs.app-version }}
# echo "::endgroup::"
# echo "::group::Unpacked files"
# ls -la release/${{ steps.setup.outputs.app-version }}/mac
# echo "::endgroup::"
# echo "::group::Unpacked .app directory"
# ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app
# echo "::endgroup::"
# echo "::group::Unpacked .app/Contents directory"
# ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents
# echo "::endgroup::"
# echo "::group::Unpacked .app/Contents/Frameworks directory"
# ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents/Frameworks
# echo "::endgroup::"
# echo "::group::Unpacked .app/Contents/MacOS directory"
# ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents/MacOS
# echo "::endgroup::"
# echo "::group::Unpacked .app/Contents/Resources directory"
# ls -la release/${{ steps.setup.outputs.app-version }}/mac/krux-installer.app/Contents/Resources
# echo "::endgroup::"

- name: E2E test electron app
env:
DEBUG: 'krux:*'
run: ./node_modules/.bin/wdio run wdio.conf.mts
#- name: E2E test electron app
# env:
# DEBUG: 'krux:*'
# run: ./node_modules/.bin/wdio run wdio.conf.mts

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-windows-nsis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
$signame = "krux-$firmware_version.zip.sig"
$pemname = "selfcustody.pem"
$extraResources = "$loc\extraResources"
$opensslVersion = "3.2.1"
$opensslVersion = "3.3.1"
$release_url = "https://github.com/selfcustody/krux/releases/download"
$raw_url = "https://raw.githubusercontent.com/selfcustody/krux/main"
$app_version = node -e "console.log(require('./package.json').version)"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
secrets:
token: ${{ secrets.github_token }}

#build-mac-dmg:
# uses: ./.github/workflows/build-mac-dmg.yml
# secrets:
# token: ${{ secrets.github_token }}
build-mac-dmg:
uses: ./.github/workflows/build-mac-dmg.yml
secrets:
token: ${{ secrets.github_token }}
28 changes: 12 additions & 16 deletions lib/check-if-it-will-flash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,19 @@ export default class CheckIfItWillFlashHandler extends Handler {

if (device.match(/maixpy_(m5stickv|amigo|amigo_ips|amigo_tft|bit|dock|yahboom|cube)/g)) {
if (version.match(/selfcustody\/.*/g)) {
if (device === 'maixpy_cube') {
this.send(`${this.name}:success`, { showFlash: false })
} else {
const __version__ = version.split('tag/')[1]
const destinationResourceZip = join(resources, __version__, `krux-${__version__}.zip`)
const destinationResourceSha = join(resources, __version__, `krux-${__version__}.zip.sha256.txt`)
const destinationResourceSig = join(resources, __version__, `krux-${__version__}.zip.sig`)
const __version__ = version.split('tag/')[1]
const destinationResourceZip = join(resources, __version__, `krux-${__version__}.zip`)
const destinationResourceSha = join(resources, __version__, `krux-${__version__}.zip.sha256.txt`)
const destinationResourceSig = join(resources, __version__, `krux-${__version__}.zip.sig`)

if (
await existsAsync(destinationResourceZip) &&
await existsAsync(destinationResourceSha) &&
await existsAsync(destinationResourceSig)
) {
this.send(`${this.name}:success`, { showFlash: true })
} else {
this.send(`${this.name}:success`, { showFlash: false })
}
if (
await existsAsync(destinationResourceZip) &&
await existsAsync(destinationResourceSha) &&
await existsAsync(destinationResourceSig)
) {
this.send(`${this.name}:success`, { showFlash: true })
} else {
this.send(`${this.name}:success`, { showFlash: false })
}
} else if (version.match(/odudex\/krux_binaries/g)) {
const destinationResourceFirmware = join(resources, version, 'main', device, 'firmware.bin')
Expand Down
24 changes: 24 additions & 0 deletions lib/flash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,17 @@ export default class FlashHandler extends Handler {
// setup flash command
let flasher = null

// special command for MacOS
let xattr = null

this.send(`${this.name}:data`, `\x1b[32m$> ${flash.command} ${flash.args.join(' ')}\x1b[0m\n\n`)

if (os === 'linux') {
const sudoer = new SudoerLinux()
flasher = await sudoer.spawn(flash.command, flash.args.join(' '), { env: process.env })
} else if (os === 'darwin') {
const sudoer = new SudoerDarwin()
xattr = await sudoer.spawn('xattr', `-rc ${cwd}`, {env: process.env})
flasher = await sudoer.spawn(flash.command, flash.args.join(' '), { env: process.env })
} else if (os === 'win32') {
flasher = spawn(flash.command, flash.args)
Expand All @@ -201,6 +205,26 @@ export default class FlashHandler extends Handler {
let err = null
let output = ''

if (xattr !== null) {
xattr.stdout.on('data', (data: any) => {
output = Buffer.from(data, 'utf-8').toString()
this.send(`${this.name}:data`, output)
})

xattr.stderr.on('data', (data: any) => {
output = Buffer.from(data, 'utf-8').toString()
err = new Error(output)
this.send(`${this.name}:data`, output)
})

xattr.on('close', (code: any) => {
if (err) {
this.send(`${this.name}:error`, { was: 'flash', done: false , name: err.name, message: err.message, stack: err.stack })
}
})
}


flasher.stdout.on('data', (data: any) => {
output = Buffer.from(data, 'utf-8').toString()
if (output.match(/\[ERROR\].*/g)) {
Expand Down
3 changes: 2 additions & 1 deletion lib/storage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// <reference path="../typings/index.d.ts"/>
/// <reference path="../node_modules/electron-store/index.d.ts"/>

import { join } from 'path'
import { spawn } from 'child_process'
import Store from 'electron-store'
import Base from './base'
import pkg from '../package.json'
import ElectronStore from 'electron-store'
Expand Down Expand Up @@ -110,6 +110,7 @@ export default class Storage extends Base {
async build (): Promise<ElectronStore> {
try {
this.log('Starting storage')
const { default: Store } = await import('electron-store')
const store = new Store(this.config)
/*
* Variables to set store
Expand Down
8 changes: 4 additions & 4 deletions lib/unzip-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ export default class UnzipResourceHandler extends Handler {
const error = new Error(`Device '${device}' not used anymore in version ${version}. Use 'maixpy_amigo' instead`)
this.send(`${this.name}:error`, { name: error.name, message: error.message, stack: error.stack})
}
if (device.match(/maixpy_cube/g)) {
const error = new Error(`Device '${device}' not implemented for version '${version}'`)
this.send(`${this.name}:error`, { name: error.name, message: error.message, stack: error.stack})
}
//if (device.match(/maixpy_cube/g)) {
// const error = new Error(`Device '${device}' not implemented for version '${version}'`)
// this.send(`${this.name}:error`, { name: error.name, message: error.message, stack: error.stack})
//}
}
this.onUnzip(zipFilePath, resources, device, os, isMac10, options)
} else if (version === 'Select version') {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "krux-installer",
"version": "0.0.13",
"version": "0.0.14",
"main": "dist-electron/main/index.js",
"description": "Graphical User Interface to download, verify and flash Krux´s firmware on Kendryte K210 hardwares as bitcoin signature devices",
"author": "qlrd <[email protected]>",
Expand Down Expand Up @@ -59,9 +59,9 @@
"@wdio/mocha-framework": "^8.27.0",
"@wdio/spec-reporter": "^8.27.0",
"chai": "^5.1.0",
"electron": "^30.1.0",
"electron": "^29.1.0",
"electron-builder": "^24.4.0",
"markdownlint-cli": "^0.41.0",
"markdownlint-cli": "^0.39.0",
"mocha": "^10.2.0",
"os-lang": "^3.1.1",
"rimraf": "^5.0.1",
Expand All @@ -81,7 +81,7 @@
"axios": "^1.4.0",
"command-exists": "^1.2.9",
"debug": "^4.3.4",
"electron-store": "^9.0.0",
"electron-store": "^8.1.0",
"glob": "^10.3.3",
"serialport": "^12.0.0",
"vite-plugin-vuetify": "^2.0.1",
Expand Down

0 comments on commit aae88ce

Please sign in to comment.