Skip to content

Commit

Permalink
Merge pull request #39 from qlrd/main
Browse files Browse the repository at this point in the history
Added minor updates;
An error page with quit buttons;
Show an error page when flash fail;
A quit button when flash is done;
A .rpm package for Fedora Linux And RedHat Linux based distros with x86_64/amd_64 architetures.
  • Loading branch information
qlrd authored Jan 15, 2024
2 parents ee96e0f + ef81e31 commit a425747
Show file tree
Hide file tree
Showing 18 changed files with 458 additions and 45 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/build-linux-deb-arm64.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/build-linux-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

build-linux:
runs-on: ubuntu-latest

steps:

- name: Checkout Git repository
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/build-linux-rpm-arm64.yml
Original file line number Diff line number Diff line change
@@ -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
76 changes: 76 additions & 0 deletions .github/workflows/build-linux-rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build electron application as rpm 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 RPM dependencies
run: sudo apt-get install rpm

- 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}.x86_64" >> $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 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 }}.rpm
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 }}-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
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ 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:
token: ${{ secrets.github_token }}

build-windows-nsis:
uses: ./.github/workflows/build-windows-nsis.yml
secrets:
Expand Down
28 changes: 28 additions & 0 deletions dockerfiles/deb/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 /
29 changes: 29 additions & 0 deletions dockerfiles/rpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 /
5 changes: 3 additions & 2 deletions electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
"category": "Utility",
"icon": "public/icon.png",
"desktop": {
"Icon": "org.selfcustody.krux-installer",
"Icon": "/usr/share/icons/hicolor/0x0/apps/krux-installer.png",
"Keywords": "electron;krux;vite;vuetify;vue3;vue",
"Terminal": false
},
"target": [ "AppImage" ]
"target": ["AppImage", "deb", "rpm"]
},
"win": {
"icon": "public/icon.png",
"target": [
{
"target": "nsis",
Expand Down
7 changes: 6 additions & 1 deletion electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down Expand Up @@ -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') {
Expand Down
Loading

0 comments on commit a425747

Please sign in to comment.