Skip to content

Commit

Permalink
Merge pull request #13 from tonkeeper/feature/cd
Browse files Browse the repository at this point in the history
Desktop PR workflow
  • Loading branch information
KuznetsovNikita authored Jan 7, 2024
2 parents 79aad63 + 245c9b5 commit dc72baa
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 65 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/cd-linux.yaml

This file was deleted.

104 changes: 104 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Tonkeeper Desktop CD
on:
push:
tags:
- v*
jobs:
desktop-build:
name: desktop-build
strategy:
matrix:
os: [ubuntu-latest, macos-13]
node-version: [20.7.0]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout to git repository
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Enable Corepack
run: |
corepack enable
- name: Decode service account into a file
if: runner.os == 'macOS'
env:
CREDENTIALS: ${{ secrets.APPLE_API_KEY }}
run: |
echo $CREDENTIALS | base64 -d > ${{ github.workspace }}/AuthKey.p8
- name: Configure keychain
if: runner.os == 'macOS'
env:
IDENTITY_PASSPHRASE: ${{ secrets.IDENTITY_PASSPHRASE }}
IDENTITY_P12_B64: ${{ secrets.IDENTITY_P12_B64 }}
run: |
echo $IDENTITY_P12_B64 | base64 -d > DS_ID_App.p12
security create-keychain -p $IDENTITY_PASSPHRASE build.keychain
security unlock-keychain -p $IDENTITY_PASSPHRASE build.keychain
security list-keychains -d user -s build.keychain
security default-keychain -s build.keychain
security import DS_ID_App.p12 -k build.keychain -P $IDENTITY_PASSPHRASE -A -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k $IDENTITY_PASSPHRASE build.keychain
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install

- name: Run build packages
uses: borales/actions-yarn@v4
with:
cmd: build:pkg

- name: Run build intel distributive
uses: borales/actions-yarn@v4
env:
APPLE_API_KEY: ${{ github.workspace }}/AuthKey.p8
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
REACT_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
DEBUG: electron*
with:
cmd: publish:intel
dir: 'apps/desktop'

- name: Run build arm distributive
uses: borales/actions-yarn@v4
env:
APPLE_API_KEY: ${{ github.workspace }}/AuthKey.p8
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
REACT_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
DEBUG: electron*
with:
cmd: publish:arm
dir: 'apps/desktop'

- name: Run build universal distributive
if: runner.os == 'macOS'
uses: borales/actions-yarn@v4
env:
APPLE_API_KEY: ${{ github.workspace }}/AuthKey.p8
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
REACT_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
DEBUG: electron*
with:
cmd: publish:universal
dir: 'apps/desktop'

- name: Clean-up credentials
if: always() && runner.os == 'macOS'
run: |
security delete-keychain build.keychain
rm ${{ github.workspace }}/AuthKey.p8
109 changes: 109 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Tonkeeper Desktop Distributives
on:
workflow_dispatch:
pull_request:

jobs:
desktop-build:
name: desktop-build
strategy:
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
node-version: [20.7.0]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout to git repository
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Enable Corepack
run: |
corepack enable
- name: Decode service account into a file
if: runner.os == 'macOS'
env:
CREDENTIALS: ${{ secrets.APPLE_API_KEY }}
run: |
echo $CREDENTIALS | base64 -d > ${{ github.workspace }}/AuthKey.p8
- name: Configure keychain
if: runner.os == 'macOS'
env:
IDENTITY_PASSPHRASE: ${{ secrets.IDENTITY_PASSPHRASE }}
IDENTITY_P12_B64: ${{ secrets.IDENTITY_P12_B64 }}
run: |
echo $IDENTITY_P12_B64 | base64 -d > DS_ID_App.p12
security create-keychain -p $IDENTITY_PASSPHRASE build.keychain
security unlock-keychain -p $IDENTITY_PASSPHRASE build.keychain
security list-keychains -d user -s build.keychain
security default-keychain -s build.keychain
security import DS_ID_App.p12 -k build.keychain -P $IDENTITY_PASSPHRASE -A -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k $IDENTITY_PASSPHRASE build.keychain
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install

- name: Run build packages
uses: borales/actions-yarn@v4
with:
cmd: build:pkg

- name: Run build intel distributive
uses: borales/actions-yarn@v4
env:
APPLE_API_KEY: ${{ github.workspace }}/AuthKey.p8
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
REACT_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE }}
DEBUG: electron*
with:
cmd: make:intel
dir: 'apps/desktop'

- name: Run build arm distributive
uses: borales/actions-yarn@v4
env:
APPLE_API_KEY: ${{ github.workspace }}/AuthKey.p8
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
REACT_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE }}
DEBUG: electron*
with:
cmd: make:arm
dir: 'apps/desktop'

- name: Run build universal distributive
if: runner.os == 'macOS'
uses: borales/actions-yarn@v4
env:
APPLE_API_KEY: ${{ github.workspace }}/AuthKey.p8
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
REACT_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE }}
DEBUG: electron*
with:
cmd: make:universal
dir: 'apps/desktop'

- name: Upload distributives to artifacts
uses: actions/upload-artifact@v4
with:
name: Tonkeeper Desktop ${{ runner.os }}
retention-days: 10
path: |
${{ github.workspace }}/apps/desktop/out/make
- name: Clean-up credentials
if: always() && runner.os == 'macOS'
run: |
security delete-keychain build.keychain
rm ${{ github.workspace }}/AuthKey.p8
51 changes: 32 additions & 19 deletions apps/desktop/forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import path from 'path';
import { mainConfig } from './webpack.main.config';
import { rendererConfig } from './webpack.renderer.config';

const { parsed } = dotenv.config();
dotenv.config();

const schemes = ['tc', 'tonkeeper', 'tonkeeper-tc'];

const devAndRpmOptions = {
name: 'Tonkeeper',
productName: 'Tonkeeper',
genericName: 'Tonkeeper',
license: "Apache-2.0",
maintainer: "Ton Apps Group",
bin: "Tonkeeper", // bin name
license: 'Apache-2.0',
maintainer: 'Ton Apps Group',
bin: 'Tonkeeper', // bin name
description: 'Your desktop wallet on The Open Network',
homepage: 'https://tonkeeper.com',
icon: path.join(__dirname, 'public', 'icon.png'),
Expand All @@ -43,7 +43,7 @@ const config: ForgeConfig = {
schemes: schemes
}
],
appBundleId: parsed!.APPLE_BUILD_ID,
appBundleId: 'com.tonapps.tonkeeperpro',
osxSign: {
optionsForFile: (optionsForFile: string) => {
return {
Expand All @@ -52,18 +52,25 @@ const config: ForgeConfig = {
}
},
osxNotarize: {
appleApiKey: parsed!.APPLE_API_KEY,
appleApiKeyId: parsed!.APPLE_API_KEY_ID,
appleApiIssuer: parsed!.APPLE_API_ISSUER
appleApiKey: process.env.APPLE_API_KEY,
appleApiKeyId: process.env.APPLE_API_KEY_ID,
appleApiIssuer: process.env.APPLE_API_ISSUER
} as NotaryToolCredentials,
extraResource: [
"./public"
]
extraResource: ['./public']
},
rebuildConfig: {},
makers: [
new MakerSquirrel({}),
new MakerZIP({}, ['darwin', "linux"]),
new MakerSquirrel(
{
name: 'Tonkeeper',
authors: 'Ton Apps Group',
description: 'Your desktop wallet on The Open Network',
iconUrl: path.join(process.cwd(), 'public', 'icon.ico'),
setupIcon: path.join(process.cwd(), 'public', 'icon.ico')
},
['win32']
),
new MakerZIP({}, ['darwin', 'linux', 'win32']),
new MakerDMG(
arch => ({
background: path.join(process.cwd(), 'public', 'dmg-bg.png'),
Expand All @@ -82,12 +89,18 @@ const config: ForgeConfig = {
}),
['darwin']
),
new MakerRpm({
options: devAndRpmOptions
}, ['linux']),
new MakerDeb({
options: devAndRpmOptions
}, ['linux'])
new MakerRpm(
{
options: devAndRpmOptions
},
['linux']
),
new MakerDeb(
{
options: devAndRpmOptions
},
['linux']
)
],
plugins: [
new AutoUnpackNativesPlugin({}),
Expand Down
Binary file added apps/desktop/public/icon.ico
Binary file not shown.
16 changes: 11 additions & 5 deletions apps/desktop/src/electron/mainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,26 @@ export abstract class MainWindow {

const icon = (() => {
switch (process.platform) {
case "darwin": return path.join(process.cwd(), "public", "icon.icns")
case "linux": return path.join(__dirname, "../../../", "public", 'icon.png')
default: return "";
case 'darwin':
return path.join(process.cwd(), 'public', 'icon.icns');
case 'linux':
return path.join(__dirname, '../../../', 'public', 'icon.png');
case 'win32':
return path.join(process.cwd(), 'public', 'icon.ico');
default:
return '';
}
})();

// Create the browser window.
this.mainWindow = new BrowserWindow({
icon: icon,
width: process.platform == "linux" ? 438 : 450,
width: process.platform == 'linux' ? 438 : 450,
height: 700,
resizable: isDev,
autoHideMenuBar: process.platform != 'darwin',
webPreferences: {
zoomFactor: process.platform === 'darwin' ? 0.8 : undefined,
zoomFactor: process.platform !== 'linux' ? 0.8 : undefined,
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY
}
});
Expand Down
10 changes: 5 additions & 5 deletions apps/desktop/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ app.setName('Tonkeeper Desktop');
log.initialize({ preload: true });
log.info('Application start-up');

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
}

const connection = TonConnectSSE.getInstance();
app.on('before-quit', e => {
connection.destroy();
Expand All @@ -33,11 +38,6 @@ switch (process.platform) {
throw new Error('Process platform is undefined');
}

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
Expand Down
Loading

0 comments on commit dc72baa

Please sign in to comment.