From d2fb4ef0353d00c96ac016c2ae1aff15bbb07836 Mon Sep 17 00:00:00 2001 From: qlrd Date: Wed, 3 Jan 2024 18:19:34 -0300 Subject: [PATCH 01/10] Upgraded electron to 28.1.1 Added quit button on FlashDevicePage Added Error page when device isnt properly connected --- electron/main/index.ts | 7 ++- lib/flash.ts | 11 ++++- lib/quit.ts | 49 +++++++++++++++++++++ package.json | 4 +- src/App.vue | 1 - src/pages/ErrorMsg.vue | 57 +++++++++++++++---------- src/pages/FlashToDevice.vue | 25 +++++++++-- test/e2e/specs/002.app-startup.spec.mts | 2 +- 8 files changed, 123 insertions(+), 33 deletions(-) create mode 100644 lib/quit.ts diff --git a/electron/main/index.ts b/electron/main/index.ts index 1513727a..9276d7e1 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -13,6 +13,7 @@ import StoreGetHandler from '../../lib/store-get' import VerifyOpensslHandler from '../../lib/verify-openssl' import CheckIfItWillFlashHandler from '../../lib/check-if-it-will-flash' import FlashHandler from '../../lib/flash' +import QuitHandler from '../../lib/quit' const { version } = createRequire(import.meta.url)('../../package.json') const kruxInstaller = new App(`KruxInstaller | v${version}`) @@ -71,10 +72,14 @@ kruxInstaller.start(async ({ app, win, ipcMain}) => { const checkIfItWillFlashHandler = new CheckIfItWillFlashHandler(win, app.store, ipcMain) checkIfItWillFlashHandler.build() - // Create flash' handler + // Create 'flash' handler const flashHandler = new FlashHandler(win, app.store, ipcMain) flashHandler.build() + // Create 'quit' handler + const quitHandler = new QuitHandler(win, app.store, ipcMain) + quitHandler.build() + // Create Wdio test handlers // if environment variable WDIO_ELECTRON equals 'true' if (process.env.NODE_ENV === 'test') { diff --git a/lib/flash.ts b/lib/flash.ts index a6728e59..675604a2 100644 --- a/lib/flash.ts +++ b/lib/flash.ts @@ -140,6 +140,15 @@ export default class FlashHandler extends Handler { flasher.stdout.on('data', (data: any) => { output = Buffer.from(data, 'utf-8').toString() + if (output.match(/\[ERROR\].*/g)) { + output = output.replace("\x1b[31m", "") + output = output.replace("\x1b[1m", "") + output = output.replace("\x1b[0m", "") + output = output.replace("\x1b[32m", "") + output = output.replace("\x1b[0m \n", "") + output = output.replace("[ERROR]", "") + err = new Error(output) + } this.send(`${this.name}:data`, output) }) @@ -151,7 +160,7 @@ export default class FlashHandler extends Handler { flasher.on('close', (code: any) => { if (err) { - this.send(`${this.name}:error`, { name: err.name, message: err.message, stack: err.stack }) + this.send(`${this.name}:error`, { done: false , name: err.name, message: err.message, stack: err.stack }) } else { this.send(`${this.name}:success`, { done: true }) } diff --git a/lib/quit.ts b/lib/quit.ts new file mode 100644 index 00000000..f7e0577c --- /dev/null +++ b/lib/quit.ts @@ -0,0 +1,49 @@ +/// + +import { app } from 'electron' +import ElectronStore from 'electron-store' +import Handler from './handler' + +export default class QuitHandler extends Handler { + + constructor (win: Electron.BrowserWindow, storage: ElectronStore, ipcMain: Electron.IpcMain) { + super('krux:quit', win, storage, ipcMain); + } + + /** + * Builds a `handle` method for `ipcMain` to be called + * with `invoke` method in `ipcRenderer`. + * + * @example + * ``` + * // change some key in store + * // some keys are forbidden to change + * // https://api.github.com/repos/selfcustody/krux/git/refs/tags + * methods: { + * async download () { + * await window.api.invoke('krux:quit') + * + * window.api.onSuccess('krux:quit', function(_, isChanged) { + * // ... do something + * }) + * + * window.api.onError('krux:quit', function(_, error) { + * // ... do something + * }) + * } + * } + * + * ``` + */ + build () { + super.build(async (options) => { + try { + this.send(`${this.name}:success`, '👋 Quiting krux-installer...') + app.quit() + process.exit(0) + } catch (error) { + this.send(`${this.name}:error`, { name: error.name, stack: error.stack, message: error.message }) + } + }) + } +} diff --git a/package.json b/package.json index c2129c83..8c538e21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "krux-installer", - "version": "0.0.1", + "version": "0.0.11", "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 <106913782+qlrd@users.noreply.github.com>", @@ -59,7 +59,7 @@ "@wdio/mocha-framework": "^8.27.0", "@wdio/spec-reporter": "^8.27.0", "chai": "^4.3.7", - "electron": "^28.1.0", + "electron": "^28.1.1", "electron-builder": "^24.4.0", "glob": "^10.3.3", "markdownlint-cli": "^0.38.0", diff --git a/src/App.vue b/src/App.vue index 2eacbfb3..eb020b9c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -54,7 +54,6 @@ import onKruxFlash from './utils/onKruxFlash'; import onKruxFlashData from './utils/onKruxFlashData'; import onKruxUnzipData from './utils/onKruxUnzipData'; - /** * Reference for which component will be used as showing page */ diff --git a/src/pages/ErrorMsg.vue b/src/pages/ErrorMsg.vue index 7e9a53f4..fbd852a6 100644 --- a/src/pages/ErrorMsg.vue +++ b/src/pages/ErrorMsg.vue @@ -2,31 +2,37 @@ - - - - - - Back - - - + + + + + + Back + + + Quit + + + - \ No newline at end of file + diff --git a/src/pages/FlashToDevice.vue b/src/pages/FlashToDevice.vue index 12b2f39f..92628894 100644 --- a/src/pages/FlashToDevice.vue +++ b/src/pages/FlashToDevice.vue @@ -7,8 +7,10 @@ - {{ !done ? 'Flashing...' : 'Done' }} - {{ !done ? 'Do not unplug device or shutdown computer!' : 'Shutdown your device and unplug it' }} + {{ !done ? 'Flashing...' : 'Do not trust, verify! ' }} + {{ !done ? 'Do not unplug device or shutdown computer!' : 'Before quit:' }} + {{ !done ? '' : '(1) Scroll down the output to check what happened to your device;' }} + {{ !done ? '' : '(2) shutdown your device and unplug it' }}
@@ -17,12 +19,22 @@ - Back - + + + + + Quit + @@ -42,6 +54,7 @@ const props = defineProps<{ const { output, done } = toRefs(props) const allOutput: Ref = ref('') + /** Methods */ @@ -50,6 +63,10 @@ async function backToFn () { await window.api.invoke('krux:store:get', { from: 'FlashToDevice', keys: ['device', 'version', 'os', 'isMac10', 'showFlash'] }) } +async function exitAppFn () { + await window.api.invoke('krux:quit') +} + onMounted(async function () { allOutput.value = allOutput.value.split(' ').splice(0).join('') await window.api.invoke('krux:unzip') diff --git a/test/e2e/specs/002.app-startup.spec.mts b/test/e2e/specs/002.app-startup.spec.mts index 4d739a11..3cd2590b 100644 --- a/test/e2e/specs/002.app-startup.spec.mts +++ b/test/e2e/specs/002.app-startup.spec.mts @@ -22,7 +22,7 @@ describe('KruxInstaller start up', () => { const version = await browser.electron.execute(function (electron) { return electron.app.getVersion() }) - expect(version).to.be.equal('0.0.1') + expect(version).to.be.equal('0.0.11') }) }) From eb9699b1303db4cc022ffb6d3e882814a0ae43d9 Mon Sep 17 00:00:00 2001 From: qlrd Date: Fri, 5 Jan 2024 18:18:56 -0300 Subject: [PATCH 02/10] added rpm package to build removed last test on 039-verified-official-release --- ...uild-linux-deb.yml => build-linux-pkg.yml} | 21 ++++++++++++------- .github/workflows/build.yml | 4 ++-- .../039-verified-official-release.spec.mts | 7 +------ 3 files changed, 17 insertions(+), 15 deletions(-) rename .github/workflows/{build-linux-deb.yml => build-linux-pkg.yml} (79%) diff --git a/.github/workflows/build-linux-deb.yml b/.github/workflows/build-linux-pkg.yml similarity index 79% rename from .github/workflows/build-linux-deb.yml rename to .github/workflows/build-linux-pkg.yml index 3c01d68c..ed179e6d 100644 --- a/.github/workflows/build-linux-deb.yml +++ b/.github/workflows/build-linux-pkg.yml @@ -1,4 +1,4 @@ -name: Build electron application as deb package on linux +name: Build electron application as deb/rpm package on linux on: workflow_call: @@ -10,12 +10,19 @@ jobs: build-linux: runs-on: ubuntu-latest - + matrix: + strategy: + - pkg: [deb, rpm] + steps: - name: Checkout Git repository uses: actions/checkout@v3 + - name: Install RPM dependencies + if: ${{ matrix.pkg == 'rpm' }} + run: sudo apt-get install rpm + - name: Install node uses: actions/setup-node@v3 with: @@ -39,13 +46,13 @@ jobs: - name: Build electron app env: GH_TOKEN: ${{ secrets.token }} - run: yarn run build --linux deb + run: yarn run build --linux ${{ matrix.pkg }} - name: Hash electron app (Linux) uses: qlrd/sha256sum-action@v2 with: working-directory: ./release/${{ steps.setup.outputs.app-version }} - file: ${{ steps.setup.outputs.app-name }}.deb + file: ${{ steps.setup.outputs.app-name }}.${{ matrix.pkg }} ext: sha256.txt - name: List release files @@ -66,8 +73,8 @@ jobs: uses: actions/upload-artifact@v3 if: ${{ github.ref_name == 'main' }} with: - name: ${{ runner.os }}-${{ steps.setup.outputs.app-name }}-deb + name: ${{ runner.os }}-${{ steps.setup.outputs.app-name }}-${{ matrix.pkg }} retention-days: 5 path: | - release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.deb - release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.deb.sha256.txt + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.${{ matrix.pkg }} + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.${{ matrix.pkg }}.sha256.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a57a4156..cda20a87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,8 +22,8 @@ jobs: secrets: token: ${{ secrets.github_token }} - build-linux-deb: - uses: ./.github/workflows/build-linux-deb.yml + build-linux-pkg: + uses: ./.github/workflows/build-linux-pkg.yml secrets: token: ${{ secrets.github_token }} diff --git a/test/e2e/specs/039-verified-official-release.spec.mts b/test/e2e/specs/039-verified-official-release.spec.mts index 4daf8633..7f35111b 100644 --- a/test/e2e/specs/039-verified-official-release.spec.mts +++ b/test/e2e/specs/039-verified-official-release.spec.mts @@ -187,9 +187,4 @@ describe('KruxInstaller VerifiedOfficialRelease page (show and click back button await instance.verifiedOfficialReleasePage.waitForExist({ reverse: true }) }) - it('should be in Main page', async () => { - await instance.mainPage.waitForExist() - await expect(instance.mainPage).toBeDisplayed() - }) - -}) \ No newline at end of file +}) From 7f3174dc5207d6c98241834795710a64f5f7d971 Mon Sep 17 00:00:00 2001 From: qlrd Date: Fri, 5 Jan 2024 18:22:05 -0300 Subject: [PATCH 03/10] fixing matrix strategy on build --- .github/workflows/build-linux-pkg.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-linux-pkg.yml b/.github/workflows/build-linux-pkg.yml index ed179e6d..77921475 100644 --- a/.github/workflows/build-linux-pkg.yml +++ b/.github/workflows/build-linux-pkg.yml @@ -10,9 +10,9 @@ jobs: build-linux: runs-on: ubuntu-latest - matrix: - strategy: - - pkg: [deb, rpm] + strategy: + matrix: + pkg: [deb, rpm] steps: From 50220468790e518831289429e55693f4fac3b80b Mon Sep 17 00:00:00 2001 From: qlrd Date: Fri, 5 Jan 2024 19:00:56 -0300 Subject: [PATCH 04/10] fixed build rpm package as another build --- .github/workflows/build-linux-deb.yml | 73 +++++++++++++++++++ ...uild-linux-pkg.yml => build-linux-rpm.yml} | 18 ++--- 2 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/build-linux-deb.yml rename .github/workflows/{build-linux-pkg.yml => build-linux-rpm.yml} (80%) diff --git a/.github/workflows/build-linux-deb.yml b/.github/workflows/build-linux-deb.yml new file mode 100644 index 00000000..6e364831 --- /dev/null +++ b/.github/workflows/build-linux-deb.yml @@ -0,0 +1,73 @@ +name: Build electron application as deb package on linux + +on: + workflow_call: + secrets: + token: + required: true + +jobs: + + build-linux: + runs-on: ubuntu-latest + + steps: + + - name: Checkout Git repository + uses: actions/checkout@v3 + + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: "20.10.0" + + - name: Variables helpers + id: setup + run: | + KRUX_VERSION=`node -e "console.log(require('./package.json').version)"` + echo "app-version=$KRUX_VERSION" >> $GITHUB_OUTPUT + KRUX_NAME=krux-installer + echo "app-name=${KRUX_NAME}_${KRUX_VERSION}_amd64" >> $GITHUB_OUTPUT + echo "::group::Variables" + echo "app-version=$KRUX_VERSION" + echo "app-name=$KRUX_NAME" + echo "::endgroup::" + + - name: Install dependencies + run: yarn install + + - name: Build electron app + env: + GH_TOKEN: ${{ secrets.token }} + run: yarn run build --linux deb + + - name: Hash electron app (Linux) + uses: qlrd/sha256sum-action@v2 + with: + working-directory: ./release/${{ steps.setup.outputs.app-version }} + file: ${{ steps.setup.outputs.app-name }}.deb + ext: sha256.txt + + - name: List release files + run: | + echo "::group::Release files" + ls -la release/${{ steps.setup.outputs.app-version }} + echo "::endgroup::" + + - name: Install xvfb-maybe to allow headless test + run: yarn add --dev xvfb-maybe + + - name: E2E test electron app + env: + DEBUG: 'krux:*' + run: ./node_modules/.bin/xvfb-maybe ./node_modules/.bin/wdio run wdio.conf.mts + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + if: ${{ github.ref_name == 'main' }} + with: + name: ${{ runner.os }}-${{ steps.setup.outputs.app-name }}-deb + retention-days: 5 + path: | + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.deb + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.deb.sha256.txt diff --git a/.github/workflows/build-linux-pkg.yml b/.github/workflows/build-linux-rpm.yml similarity index 80% rename from .github/workflows/build-linux-pkg.yml rename to .github/workflows/build-linux-rpm.yml index 77921475..b5824849 100644 --- a/.github/workflows/build-linux-pkg.yml +++ b/.github/workflows/build-linux-rpm.yml @@ -1,4 +1,4 @@ -name: Build electron application as deb/rpm package on linux +name: Build electron application as rpm package on linux on: workflow_call: @@ -10,9 +10,6 @@ jobs: build-linux: runs-on: ubuntu-latest - strategy: - matrix: - pkg: [deb, rpm] steps: @@ -20,7 +17,6 @@ jobs: uses: actions/checkout@v3 - name: Install RPM dependencies - if: ${{ matrix.pkg == 'rpm' }} run: sudo apt-get install rpm - name: Install node @@ -34,7 +30,7 @@ jobs: KRUX_VERSION=`node -e "console.log(require('./package.json').version)"` echo "app-version=$KRUX_VERSION" >> $GITHUB_OUTPUT KRUX_NAME=krux-installer - echo "app-name=${KRUX_NAME}_${KRUX_VERSION}_amd64" >> $GITHUB_OUTPUT + echo "app-name=${KRUX_NAME}-${KRUX_VERSION}.x86_64" >> $GITHUB_OUTPUT echo "::group::Variables" echo "app-version=$KRUX_VERSION" echo "app-name=$KRUX_NAME" @@ -46,13 +42,13 @@ jobs: - name: Build electron app env: GH_TOKEN: ${{ secrets.token }} - run: yarn run build --linux ${{ matrix.pkg }} + run: yarn run build --linux rpm - name: Hash electron app (Linux) uses: qlrd/sha256sum-action@v2 with: working-directory: ./release/${{ steps.setup.outputs.app-version }} - file: ${{ steps.setup.outputs.app-name }}.${{ matrix.pkg }} + file: ${{ steps.setup.outputs.app-name }}.rpm ext: sha256.txt - name: List release files @@ -73,8 +69,8 @@ jobs: uses: actions/upload-artifact@v3 if: ${{ github.ref_name == 'main' }} with: - name: ${{ runner.os }}-${{ steps.setup.outputs.app-name }}-${{ matrix.pkg }} + name: ${{ runner.os }}-${{ steps.setup.outputs.app-name }}-rpm retention-days: 5 path: | - release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.${{ matrix.pkg }} - release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.${{ matrix.pkg }}.sha256.txt + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.rpm + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.rpm.sha256.txt From d0f3ab0b304af054f534a1b596c39f9e632dae85 Mon Sep 17 00:00:00 2001 From: qlrd Date: Fri, 5 Jan 2024 19:02:44 -0300 Subject: [PATCH 05/10] fixed call on build.yml --- .github/workflows/build.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cda20a87..28c58d5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,11 +22,16 @@ jobs: secrets: token: ${{ secrets.github_token }} - build-linux-pkg: - uses: ./.github/workflows/build-linux-pkg.yml + build-linux-deb: + uses: ./.github/workflows/build-linux-deb.yml secrets: token: ${{ secrets.github_token }} + build-linux-rpm: + uses: ./.github/workflows/build-linux-rpm.yml + secrets: + token: ${{ secrets.github_token }} + build-windows-nsis: uses: ./.github/workflows/build-windows-nsis.yml secrets: From 4184bf025672a8350e8466de831f55ef19730b82 Mon Sep 17 00:00:00 2001 From: qlrd Date: Wed, 10 Jan 2024 12:54:07 -0300 Subject: [PATCH 06/10] Added check for failed flash and quit buttons Added Fedora build Added ARM64 builds --- .github/workflows/build-linux-deb-arm64.yml | 82 +++++++++++++++++++++ .github/workflows/build-linux-rpm-arm64.yml | 82 +++++++++++++++++++++ .github/workflows/build.yml | 22 +++++- dockerfiles/deb/Dockerfile | 28 +++++++ dockerfiles/rpm/Dockerfile | 29 ++++++++ electron-builder.json5 | 2 +- wdio.conf.mts | 17 ++++- 7 files changed, 254 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/build-linux-deb-arm64.yml create mode 100644 .github/workflows/build-linux-rpm-arm64.yml create mode 100644 dockerfiles/deb/Dockerfile create mode 100644 dockerfiles/rpm/Dockerfile diff --git a/.github/workflows/build-linux-deb-arm64.yml b/.github/workflows/build-linux-deb-arm64.yml new file mode 100644 index 00000000..4d16a3ed --- /dev/null +++ b/.github/workflows/build-linux-deb-arm64.yml @@ -0,0 +1,82 @@ +name: Build electron application as deb package on linux (arm64) + +on: + workflow_call: + secrets: + DOCKER_USERNAME: + required: true + DOCKER_PASSWORD: + required: true + token: + required: true + +jobs: + + build-linux-deb-arm64: + runs-on: ubuntu-latest + env: + DOCKER_IMAGE: krux-installer-deb + DOCKER_TARGET_PLATFORM: ubuntu/arm64/v8 + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + steps: + - uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Setup variables + id: setup + run: | + echo "docker-platform=${DOCKER_TARGET_PLATFORM}" >> $GITHUB_OUTPUT + echo "docker-image=${DOCKER_IMAGE}/${DOCKER_TARGET_PLATFORM}" >> $GITHUB_OUTPUT + echo "docker-version=${GITHUB_RUN_NUMBER}" >> $GITHUB_OUTPUT + KRUX_VERSION=`node -e "console.log(require('./package.json').version)"` + echo "app-version=$KRUX_VERSION" >> $GITHUB_OUTPUT + echo "app-name=krux-installer_${KRUX_VERSION}_arm64" >> $GITHUB_OUTPUT + + - name: Docker Login + run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Create release folder + run: mkdir -p ./release/${{ steps.setup.outputs.app-version }} + + - name: Run Buildx + run: | + docker buildx build \ + --file ./dockerfiles/deb/Dockerfile \ + --platform ${{ steps.setup.outputs.docker-platform }} \ + --tag ${{ steps.setup.outputs.docker-image }}:${{ steps.setup.outputs.docker-version }} \ + --output type=local,dest=./release . + + - name: Hash electron app + uses: qlrd/sha256sum-action@v2 + with: + working-directory: release/${{ steps.setup.outputs.app-version }} + file: ${{ steps.setup.outputs.app-name }}.deb + ext: sha256.txt + + - name: List releases + run: ls ./release/${{ steps.setup.outputs.app-version }} + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + if: ${{ github.ref_name == 'main' }} + with: + name: ${{ runner.os }}-${{ steps.setup.outputs.app-name }}-deb + retention-days: 5 + path: | + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.deb + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.deb.sha256.txt diff --git a/.github/workflows/build-linux-rpm-arm64.yml b/.github/workflows/build-linux-rpm-arm64.yml new file mode 100644 index 00000000..e691b04d --- /dev/null +++ b/.github/workflows/build-linux-rpm-arm64.yml @@ -0,0 +1,82 @@ +name: Build electron application as rpm package on linux (arm64) + +on: + workflow_call: + secrets: + DOCKER_USERNAME: + required: true + DOCKER_PASSWORD: + required: true + token: + required: true + +jobs: + + build-linux-rpm-arm64: + runs-on: ubuntu-latest + env: + DOCKER_IMAGE: krux-installer-rpm + DOCKER_TARGET_PLATFORM: ubuntu/arm64/v8 + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + steps: + - uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Setup variables + id: setup + run: | + echo "docker-platform=${DOCKER_TARGET_PLATFORM}" >> $GITHUB_OUTPUT + echo "docker-image=${DOCKER_IMAGE}/${DOCKER_TARGET_PLATFORM}" >> $GITHUB_OUTPUT + echo "docker-version=${GITHUB_RUN_NUMBER}" >> $GITHUB_OUTPUT + KRUX_VERSION=`node -e "console.log(require('./package.json').version)"` + echo "app-version=$KRUX_VERSION" >> $GITHUB_OUTPUT + echo "app-name=krux-installer-${KRUX_VERSION}.aarch64" >> $GITHUB_OUTPUT + + - name: Docker Login + run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Create release folder + run: mkdir -p ./release/${{ steps.setup.outputs.app-version }} + + - name: Run Buildx + run: | + docker buildx build \ + --file ./dockerfiles/rpm/Dockerfile \ + --platform ${{ steps.setup.outputs.docker-platform }} \ + --tag ${{ steps.setup.outputs.docker-image }}:${{ steps.setup.outputs.docker-version }} \ + --output type=local,dest=./release . + + - name: Hash electron app + uses: qlrd/sha256sum-action@v2 + with: + working-directory: release/${{ steps.setup.outputs.app-version }} + file: ${{ steps.setup.outputs.app-name }}.rpm + ext: sha256.txt + + - name: List releases + run: ls ./release/${{ steps.setup.outputs.app-version }} + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + if: ${{ github.ref_name == 'main' }} + with: + name: ${{ runner.os }}-${{ steps.setup.outputs.app-name }}-rpm + retention-days: 5 + path: | + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.rpm + release/${{ steps.setup.outputs.app-version }}/${{ steps.setup.outputs.app-name }}.rpm.sha256.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 28c58d5e..6de0df9c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,6 +27,20 @@ jobs: secrets: token: ${{ secrets.github_token }} + build-linux-deb-arm64: + uses: ./.github/workflows/build-linux-deb-arm64.yml + secrets: + token: ${{ secrets.github_token }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + build-linux-rpm-arm64: + uses: ./.github/workflows/build-linux-rpm-arm64.yml + secrets: + token: ${{ secrets.github_token }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + build-linux-rpm: uses: ./.github/workflows/build-linux-rpm.yml secrets: @@ -37,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 }} diff --git a/dockerfiles/deb/Dockerfile b/dockerfiles/deb/Dockerfile new file mode 100644 index 00000000..b9b0caef --- /dev/null +++ b/dockerfiles/deb/Dockerfile @@ -0,0 +1,28 @@ +FROM arm64v8/node AS build-stage +ENV NODE_ENV "test" +ENV NODE_DOCKER true +ENV DEBUG "krux:*" +ENV USE_SYSTEM_FPM true +ENV DOCUMENTS /app/Documents + +ADD . /app +WORKDIR /app +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + libopenjp2-tools \ + ruby \ + ruby-dev + +RUN gem install fpm +RUN yarn install +RUN yarn run build --arm64 --linux deb +#RUN apt-get install --fix-missing -y xvfb +#RUN yarn add --dev xvfb-maybe +#RUN node ./node_modules/.bin/xvfb-maybe \ +# ./node_modules/.bin/wdio \ +# run \ +# wdio.conf.mts + +FROM scratch AS export-stage +COPY --from=build-stage /app/release / diff --git a/dockerfiles/rpm/Dockerfile b/dockerfiles/rpm/Dockerfile new file mode 100644 index 00000000..422debc0 --- /dev/null +++ b/dockerfiles/rpm/Dockerfile @@ -0,0 +1,29 @@ +FROM arm64v8/node AS build-stage +ENV NODE_ENV "test" +ENV NODE_DOCKER true +ENV DEBUG "krux:*" +ENV USE_SYSTEM_FPM true +ENV DOCUMENTS /app/Documents + +ADD . /app +WORKDIR /app +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + libopenjp2-tools \ + ruby \ + ruby-dev \ + rpm + +RUN gem install fpm +RUN yarn install +RUN yarn run build --arm64 --linux rpm +#RUN apt-get install --fix-missing -y xvfb +#RUN yarn add --dev xvfb-maybe +#RUN node ./node_modules/.bin/xvfb-maybe \ +# ./node_modules/.bin/wdio \ +# run \ +# wdio.conf.mts + +FROM scratch AS export-stage +COPY --from=build-stage /app/release / diff --git a/electron-builder.json5 b/electron-builder.json5 index 065c71bb..9cc61d8c 100644 --- a/electron-builder.json5 +++ b/electron-builder.json5 @@ -30,7 +30,7 @@ "Keywords": "electron;krux;vite;vuetify;vue3;vue", "Terminal": false }, - "target": [ "AppImage" ] + "target": [ "AppImage", "deb", "rpm" ] }, "win": { "target": [ diff --git a/wdio.conf.mts b/wdio.conf.mts index 706599c9..6f4da2eb 100644 --- a/wdio.conf.mts +++ b/wdio.conf.mts @@ -6,7 +6,7 @@ import { tmpdir, homedir } from 'os' import { createRequire } from 'module' import { osLangSync } from 'os-lang' import createDebug from 'debug' -import { accessSync } from 'fs'; +import { accessSync, readFileSync } from 'fs'; import { exec, execFile } from 'child_process'; const { devDependencies, version } = createRequire(import.meta.url)('./package.json') @@ -18,7 +18,11 @@ const __dirname = dirname(__filename); // for each OS let APP_PATH: string if (process.platform === 'linux') { - APP_PATH = join(__dirname, 'release', version, 'linux-unpacked', 'krux-installer') + if (process.arch === 'arm64') { + APP_PATH = join(__dirname, 'release', version, 'linux-arm64-unpacked', 'krux-installer') + } else { + APP_PATH = join(__dirname, 'release', version, 'linux-unpacked', 'krux-installer') + } } else if (process.platform === 'win32') { APP_PATH = join(__dirname, 'release', version, 'win-unpacked', 'krux-installer.exe') } else if (process.platform === 'darwin') { @@ -58,8 +62,15 @@ if (process.env.CI && process.env.GITHUB_ACTION) { resources = join(home, 'Documents', 'krux-installer') } else if ( lang.match(/pt-*/g)) { resources = join(home, 'Documentos', 'krux-installer') + } else if ( lang.match(/POSIX/) ) { + // Check if is running under docker container (containerized build for arm64) + if (process.env.NODE_DOCKER) { + resources = join(process.env.DOCUMENTS, 'krux-installer') + } else { + throw new Error('Failed to check if is running under docker') + } } else { - throw new Error(`${lang} not implemented. Please implement it with correct \'Documents\' folder name`) + throw new Error(`'${lang}'' lang not implemented. Please implement it with correct \'Documents\' folder name`) } } From 0c9de12e5b1152597d4b67583ebb7143ae5d4d5f Mon Sep 17 00:00:00 2001 From: qlrd <106913782+qlrd@users.noreply.github.com> Date: Thu, 11 Jan 2024 12:00:15 +0000 Subject: [PATCH 07/10] Update build.yml Commented arm64 and mac builds since need some discussion with the team --- .github/workflows/build.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6de0df9c..fc25b6e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,19 +27,19 @@ jobs: secrets: token: ${{ secrets.github_token }} - build-linux-deb-arm64: - uses: ./.github/workflows/build-linux-deb-arm64.yml - secrets: - token: ${{ secrets.github_token }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + #build-linux-deb-arm64: + # uses: ./.github/workflows/build-linux-deb-arm64.yml + # secrets: + # token: ${{ secrets.github_token }} + # DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + # DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - build-linux-rpm-arm64: - uses: ./.github/workflows/build-linux-rpm-arm64.yml - secrets: - token: ${{ secrets.github_token }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + #build-linux-rpm-arm64: + # uses: ./.github/workflows/build-linux-rpm-arm64.yml + # secrets: + # token: ${{ secrets.github_token }} + # DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + # DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} build-linux-rpm: uses: ./.github/workflows/build-linux-rpm.yml @@ -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 }} From 425c658d051662613a4ae81efb2601676eb33e0c Mon Sep 17 00:00:00 2001 From: qlrd Date: Thu, 11 Jan 2024 11:49:05 -0300 Subject: [PATCH 08/10] added path for icon in desktop entries for .deb package --- electron-builder.json5 | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/electron-builder.json5 b/electron-builder.json5 index 9cc61d8c..2d7bd71e 100644 --- a/electron-builder.json5 +++ b/electron-builder.json5 @@ -25,14 +25,30 @@ "linux": { "category": "Utility", "icon": "public/icon.png", - "desktop": { - "Icon": "org.selfcustody.krux-installer", - "Keywords": "electron;krux;vite;vuetify;vue3;vue", - "Terminal": false - }, - "target": [ "AppImage", "deb", "rpm" ] + "target": [ + { + "target": "AppImage" + }, + { + "target": "deb", + "desktop": { + "Icon": "/usr/share/icons/hicolor/0x0/apps/krux-installer.png", + "Keywords": "electron;krux;vite;vuetify;vue3;vue", + "Terminal": false + } + }, + { + "target": "rpm", + "desktop": { + "Icon": "/usr/share/icons/hicolor/0x0/apps/krux-installer.png", + "Keywords": "electron;krux;vite;vuetify;vue3;vue", + "Terminal": false + } + } + ] }, "win": { + "icon": "public/icon.png", "target": [ { "target": "nsis", From af97e8cc8195cca6e2b4894ad3b268f64cc252e8 Mon Sep 17 00:00:00 2001 From: qlrd Date: Thu, 11 Jan 2024 12:42:03 -0300 Subject: [PATCH 09/10] Fixed json definition of desktop entries --- electron-builder.json5 | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/electron-builder.json5 b/electron-builder.json5 index 2d7bd71e..c34cceea 100644 --- a/electron-builder.json5 +++ b/electron-builder.json5 @@ -25,27 +25,12 @@ "linux": { "category": "Utility", "icon": "public/icon.png", - "target": [ - { - "target": "AppImage" - }, - { - "target": "deb", - "desktop": { - "Icon": "/usr/share/icons/hicolor/0x0/apps/krux-installer.png", - "Keywords": "electron;krux;vite;vuetify;vue3;vue", - "Terminal": false - } - }, - { - "target": "rpm", - "desktop": { - "Icon": "/usr/share/icons/hicolor/0x0/apps/krux-installer.png", - "Keywords": "electron;krux;vite;vuetify;vue3;vue", - "Terminal": false - } - } - ] + "desktop": { + "Icon": "/usr/share/icons/hicolor/0x0/apps/krux-installer.png", + "Keywords": "electron;krux;vite;vuetify;vue3;vue", + "Terminal": false + }, + "target": ["AppImage", "deb", "rpm"] }, "win": { "icon": "public/icon.png", From ef81e3168bbe20621cdaa94815017c3d6985fc43 Mon Sep 17 00:00:00 2001 From: qlrd Date: Fri, 12 Jan 2024 10:19:16 -0300 Subject: [PATCH 10/10] fixed typo on wdio.conf.mts --- wdio.conf.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wdio.conf.mts b/wdio.conf.mts index 6f4da2eb..4a5b25b3 100644 --- a/wdio.conf.mts +++ b/wdio.conf.mts @@ -70,7 +70,7 @@ if (process.env.CI && process.env.GITHUB_ACTION) { throw new Error('Failed to check if is running under docker') } } else { - throw new Error(`'${lang}'' lang not implemented. Please implement it with correct \'Documents\' folder name`) + throw new Error(`'${lang}' lang not implemented`) } }