Skip to content
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

Feat/binaries fix #32

Merged
merged 10 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
32 changes: 32 additions & 0 deletions .github/workflows/get-versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Extract Versions Workflow
on:
workflow_call:
outputs:
version:
description: "App version"
value: ${{ jobs.extract-versions.outputs.version }}
holochain_version:
description: "Holochain version"
value: ${{ jobs.extract-versions.outputs.holochain_version }}
lair_keystore_version:
description: "Lair keystore version"
value: ${{ jobs.extract-versions.outputs.lair_keystore_version }}

jobs:
extract-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18'
- name: Extract version information
id: packagejson
run: |
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
echo "holochain_version=$(node -p "require('./package.json').binaries.holochain")" >> $GITHUB_OUTPUT
echo "lair_keystore_version=$(node -p "require('./package.json').binaries.lair_keystore")" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.packagejson.outputs.version }}
holochain_version: ${{ steps.packagejson.outputs.holochain_version }}
lair_keystore_version: ${{ steps.packagejson.outputs.lair_keystore_version }}
21 changes: 12 additions & 9 deletions .github/workflows/holochain-binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
- 'holochain-binaries-v*'

jobs:
extract-versions:
uses: ./.github/workflows/get-versions.yaml
publish-holochain-binaries:
needs: extract-versions
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -41,30 +44,30 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo install holochain --version 0.2.5 --locked --features sqlite-encrypted
cargo install holochain --version ${{ needs.extract-versions.outputs.holochain_version }} --locked --features sqlite-encrypted
$HcPath = Get-Command holochain | Select-Object -ExpandProperty Definition
Copy-Item $HcPath -Destination holochain-v0.2.5-x86_64-pc-windows-msvc.exe
Copy-Item $HcPath -Destination holochain-v${{ needs.extract-versions.outputs.holochain_version }}-x86_64-pc-windows-msvc.exe

gh release upload "$($env:GITHUB_REF -replace "refs/tags/")" "holochain-v0.2.5-x86_64-pc-windows-msvc.exe"
gh release upload "$($env:GITHUB_REF -replace "refs/tags/")" "holochain-v${{ needs.extract-versions.outputs.holochain_version }}-x86_64-pc-windows-msvc.exe"

- name: setup binaries (macos only)
if: matrix.platform == 'macos-11'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo install holochain --version 0.2.5 --locked --features sqlite-encrypted
cargo install holochain --version ${{ needs.extract-versions.outputs.holochain_version }} --locked --features sqlite-encrypted
HOLOCHAIN_PATH=$(which holochain)
cp $HOLOCHAIN_PATH holochain-v0.2.5-x86_64-apple-darwin
cp $HOLOCHAIN_PATH holochain-v${{ needs.extract-versions.outputs.holochain_version }}-x86_64-apple-darwin

gh release upload "${GITHUB_REF#refs/tags/}" "holochain-v0.2.5-x86_64-apple-darwin"
gh release upload "${GITHUB_REF#refs/tags/}" "holochain-v${{ needs.extract-versions.outputs.holochain_version }}-x86_64-apple-darwin"

- name: setup binaries (ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo install holochain --version 0.2.5 --locked --features sqlite-encrypted
cargo install holochain --version ${{ needs.extract-versions.outputs.holochain_version }} --locked --features sqlite-encrypted
HOLOCHAIN_PATH=$(which holochain)
cp $HOLOCHAIN_PATH holochain-v0.2.5-x86_64-unknown-linux-gnu
cp $HOLOCHAIN_PATH holochain-v${{ needs.extract-versions.outputs.holochain_version }}-x86_64-unknown-linux-gnu

gh release upload "${GITHUB_REF#refs/tags/}" "holochain-v0.2.5-x86_64-unknown-linux-gnu"
gh release upload "${GITHUB_REF#refs/tags/}" "holochain-v${{ needs.extract-versions.outputs.holochain_version }}-x86_64-unknown-linux-gnu"
21 changes: 12 additions & 9 deletions .github/workflows/lair-binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
- 'lair-binaries-v*'

jobs:
extract-versions:
uses: ./.github/workflows/get-versions.yaml
publish-lair-binaries:
needs: extract-versions
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -41,30 +44,30 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo install --version 0.4.2 lair_keystore
cargo install --version ${{ needs.extract-versions.outputs.lair_keystore }} lair_keystore
$LkPath = Get-Command lair-keystore | Select-Object -ExpandProperty Definition
Copy-Item $LkPath -Destination "lair-keystore-v0.4.2-x86_64-pc-windows-msvc.exe"
Copy-Item $LkPath -Destination "lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}-x86_64-pc-windows-msvc.exe"

gh release upload "$($env:GITHUB_REF -replace "refs/tags/")" "lair-keystore-v0.4.2-x86_64-pc-windows-msvc.exe"
gh release upload "$($env:GITHUB_REF -replace "refs/tags/")" "lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}-x86_64-pc-windows-msvc.exe"

- name: setup binaries (macos only)
if: matrix.platform == 'macos-11'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo install --version 0.4.2 lair_keystore
cargo install --version ${{ needs.extract-versions.outputs.lair_keystore }} lair_keystore
LAIR_PATH=$(which lair-keystore)
cp $LAIR_PATH lair-keystore-v0.4.2-x86_64-apple-darwin
cp $LAIR_PATH lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}-x86_64-apple-darwin

gh release upload "${GITHUB_REF#refs/tags/}" "lair-keystore-v0.4.2-x86_64-apple-darwin"
gh release upload "${GITHUB_REF#refs/tags/}" "lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}-x86_64-apple-darwin"

- name: setup binaries (ubuntu only)
if: matrix.platform == 'ubuntu-20.04'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo install --version 0.4.2 lair_keystore
cargo install --version ${{ needs.extract-versions.outputs.lair_keystore }} lair_keystore
LAIR_PATH=$(which lair-keystore)
cp $LAIR_PATH lair-keystore-v0.4.2-x86_64-unknown-linux-gnu
cp $LAIR_PATH lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}-x86_64-unknown-linux-gnu

gh release upload "${GITHUB_REF#refs/tags/}" "lair-keystore-v0.4.2-x86_64-unknown-linux-gnu"
gh release upload "${GITHUB_REF#refs/tags/}" "lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}-x86_64-unknown-linux-gnu"
55 changes: 27 additions & 28 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
- release

jobs:
extract-versions:
uses: ./.github/workflows/get-versions.yaml
create-draft-release:
needs: extract-versions
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create_release.outputs.id }}
Expand All @@ -14,16 +17,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: '18'
- name: Get version
id: packagejson
run: |
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Create Draft Release
id: create_release
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.packagejson.outputs.version }}
name: v${{ steps.packagejson.outputs.version }}
tag: v${{ needs.extract-versions.outputs.version }}
name: v${{ needs.extract-versions.outputs.version }} (Holochain v${{ needs.extract-versions.outputs.holochain_version }})
draft: true
generateReleaseNotes: true
allowUpdates: true
Expand Down Expand Up @@ -89,17 +88,17 @@ jobs:
run: |
mkdir resources/bins

# cargo install --version 0.4.2 lair_keystore
# cargo install --version ${{ needs.extract-versions.outputs.lair_keystore }} lair_keystore
# $LkPath = Get-Command lair-keystore | Select-Object -ExpandProperty Definition
# Copy-Item $LkPath -Destination resources/bins/lair-keystore-v0.4.2.exe
# Copy-Item $LkPath -Destination resources/bins/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}.exe

curl -L --output resources/bins/lair-keystore-v0.4.2.exe https://github.com/holochain/launcher-electron/releases/download/lair-binaries-v0.4.2/lair-keystore-v0.4.2-x86_64-pc-windows-msvc.exe
curl -L --output resources/bins/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}.exe https://github.com/holochain/launcher-electron/releases/download/lair-binaries-v${{ needs.extract-versions.outputs.lair_keystore }}/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}-x86_64-pc-windows-msvc.exe

# cargo install holochain --version 0.2.5-rc.1 --locked --features sqlite-encrypted
# cargo install holochain --version ${{ needs.extract-versions.outputs.holochain_version }} --locked --features sqlite-encrypted
# $HcPath = Get-Command holochain | Select-Object -ExpandProperty Definition
# Copy-Item $HcPath -Destination resources/bins/holochain-v0.2.5-rc.1.exe
# Copy-Item $HcPath -Destination resources/bins/holochain-v${{ needs.extract-versions.outputs.holochain_version }}.exe

curl -L --output resources/bins/holochain-v0.2.5-rc.1-8613839.exe https://github.com/holochain/launcher-electron/releases/download/holochain-binaries-v0.2.5-rc.1-8613839/holochain-v0.2.5-rc.1-8613839-x86_64-pc-windows-msvc.exe
curl -L --output resources/bins/holochain-v${{ needs.extract-versions.outputs.holochain_version }}.exe https://github.com/holochain/launcher-electron/releases/download/holochain-binaries-v${{ needs.extract-versions.outputs.holochain_version }}/holochain-v${{ needs.extract-versions.outputs.holochain_version }}-x86_64-pc-windows-msvc.exe

# NEW_VERSION: install new holochain version and copy its binary to the tauri path

Expand All @@ -108,19 +107,19 @@ jobs:
run: |
mkdir resources/bins

# cargo install --version 0.4.2 lair_keystore
# cargo install --version ${{ needs.extract-versions.outputs.lair_keystore }} lair_keystore
# LAIR_PATH=$(which lair-keystore)
# cp $LAIR_PATH resources/bins/lair-keystore-v0.4.2
# cp $LAIR_PATH resources/bins/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}

curl -L --output resources/bins/lair-keystore-v0.4.2 https://github.com/holochain/launcher-electron/releases/download/lair-binaries-v0.4.2/lair-keystore-v0.4.2-x86_64-apple-darwin
chmod +x ./resources/bins/lair-keystore-v0.4.2
curl -L --output resources/bins/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }} https://github.com/holochain/launcher-electron/releases/download/lair-binaries-v${{ needs.extract-versions.outputs.lair_keystore }}/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}-x86_64-apple-darwin
chmod +x ./resources/bins/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}

# cargo install holochain --version 0.2.5-rc.1 --locked --features sqlite-encrypted
# cargo install holochain --version ${{ needs.extract-versions.outputs.holochain_version }} --locked --features sqlite-encrypted
# HOLOCHAIN_PATH=$(which holochain)
# cp $HOLOCHAIN_PATH resources/bins/holochain-v0.2.5-rc.1
# cp $HOLOCHAIN_PATH resources/bins/holochain-v${{ needs.extract-versions.outputs.holochain_version }}

curl -L --output resources/bins/holochain-v0.2.5-rc.1-8613839 https://github.com/holochain/launcher-electron/releases/download/holochain-binaries-v0.2.5-rc.1-8613839/holochain-v0.2.5-rc.1-8613839-x86_64-apple-darwin
chmod +x ./resources/bins/holochain-v0.2.5-rc.1-8613839
curl -L --output resources/bins/holochain-v${{ needs.extract-versions.outputs.holochain_version }} https://github.com/holochain/launcher-electron/releases/download/holochain-binaries-v${{ needs.extract-versions.outputs.holochain_version }}/holochain-v${{ needs.extract-versions.outputs.holochain_version }}-x86_64-apple-darwin
chmod +x ./resources/bins/holochain-v${{ needs.extract-versions.outputs.holochain_version }}

# NEW_VERSION: install new holochain version and copy its binary to the tauri path

Expand All @@ -129,19 +128,19 @@ jobs:
run: |
mkdir resources/bins

# cargo install --version 0.4.2 lair_keystore
# cargo install --version ${{ needs.extract-versions.outputs.lair_keystore }} lair_keystore
# LAIR_PATH=$(which lair-keystore)
# cp $LAIR_PATH resources/bins/lair-keystore-v0.4.2
# cp $LAIR_PATH resources/bins/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}

curl -L --output resources/bins/lair-keystore-v0.4.2 https://github.com/holochain/launcher-electron/releases/download/lair-binaries-v0.4.2/lair-keystore-v0.4.2-x86_64-unknown-linux-gnu
chmod +x ./resources/bins/lair-keystore-v0.4.2
curl -L --output resources/bins/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }} https://github.com/holochain/launcher-electron/releases/download/lair-binaries-v${{ needs.extract-versions.outputs.lair_keystore }}/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}-x86_64-unknown-linux-gnu
chmod +x ./resources/bins/lair-keystore-v${{ needs.extract-versions.outputs.lair_keystore }}

# cargo install holochain --version 0.2.5-rc.1 --locked --features sqlite-encrypted
# cargo install holochain --version ${{ needs.extract-versions.outputs.holochain_version }} --locked --features sqlite-encrypted
# HOLOCHAIN_PATH=$(which holochain)
# cp $HOLOCHAIN_PATH resources/bins/holochain-v0.2.5-rc.1
# cp $HOLOCHAIN_PATH resources/bins/holochain-v${{ needs.extract-versions.outputs.holochain_version }}

curl -L --output resources/bins/holochain-v0.2.5-rc.1-8613839 https://github.com/holochain/launcher-electron/releases/download/holochain-binaries-v0.2.5-rc.1-8613839/holochain-v0.2.5-rc.1-8613839-x86_64-unknown-linux-gnu
chmod +x ./resources/bins/holochain-v0.2.5-rc.1-8613839
curl -L --output resources/bins/holochain-v${{ needs.extract-versions.outputs.holochain_version }} https://github.com/holochain/launcher-electron/releases/download/holochain-binaries-v${{ needs.extract-versions.outputs.holochain_version }}/holochain-v${{ needs.extract-versions.outputs.holochain_version }}-x86_64-unknown-linux-gnu
chmod +x ./resources/bins/holochain-v${{ needs.extract-versions.outputs.holochain_version }}

# NEW_VERSION: install new holochain version and copy its binary to the tauri path

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"author": "Holochain Foundation <[email protected]> (http://holochain.org)",
"license": "CAL-1.0",
"main": "./out/main/index.js",
"binaries": {
"holochain": "0.2.5",
"lair_keystore": "0.4.2"
},
"workspaces": [
"src/renderer"
],
Expand Down Expand Up @@ -50,6 +54,7 @@
"@electron-toolkit/tsconfig": "^1.0.1",
"@napi-rs/cli": "^2.16.3",
"@types/node": "^20.10.5",
"@types/split": "^1.0.5",
"concurrently": "^8.2.2",
"electron": "^28.1.1",
"electron-builder": "^24.9.1",
Expand Down
4 changes: 2 additions & 2 deletions scripts/setup-binaries.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

REQUIRED_HOLOCHAIN_VERSION="0.2.5-rc.1"
REQUIRED_LAIR_VERSION="0.4.1"
REQUIRED_HOLOCHAIN_VERSION=$(node -p "require('./package.json').binaries.holochain")
REQUIRED_LAIR_VERSION=$(node -p "require('./package.json').binaries.lair_keystore")

# Check that this script is being run from the right location
if [ ! -f "package.json" ] || [ ! -f "electron-builder.yml" ];
Expand Down
31 changes: 25 additions & 6 deletions src/main/binaries.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
import { app } from 'electron';
import fs from 'fs';
import { readFileSync } from 'fs';
import * as path from 'path';

export const DEFAULT_HOLOCHAIN_VERSION = '0.2.5-rc.1-8613839';
import { HolochainLairVersionSchema } from '../types';

const BINARIES_DIRECTORY = app.isPackaged
? path.join(app.getAppPath(), '../app.asar.unpacked/resources/bins')
: path.join(app.getAppPath(), './resources/bins');
const getFilePath = (relativePath) => path.join(app.getAppPath(), relativePath);

const getPackageJSONPath = () =>
getFilePath(app.isPackaged ? '../app.asar.unpacked/package.json' : './package.json');

const readJSONFile = (filePath) => JSON.parse(readFileSync(filePath, 'utf8'));

const packageJSON = readJSONFile(getPackageJSONPath());

const HolochainLairVersion = HolochainLairVersionSchema.parse(packageJSON);

export const DEFAULT_HOLOCHAIN_VERSION = HolochainLairVersion.binaries.holochain;
export const DEFAULT_LAIR_KEYSTORE_VERSION = HolochainLairVersion.binaries.lair_keystore;

const BINARIES_DIRECTORY = getFilePath(
app.isPackaged ? '../app.asar.unpacked/resources/bins' : './resources/bins',
);

const HOLOCHAIN_BINARIES = {
'0.2.5-rc.1-8613839': path.join(
DEFAULT_HOLOCHAIN_VERSION: path.join(
BINARIES_DIRECTORY,
`holochain-v${DEFAULT_HOLOCHAIN_VERSION}${process.platform === 'win32' ? '.exe' : ''}`,
),
};

const LAIR_BINARY = path.join(
BINARIES_DIRECTORY,
`lair-keystore-v0.4.2${process.platform === 'win32' ? '.exe' : ''}`,
`lair-keystore-v${DEFAULT_LAIR_KEYSTORE_VERSION}${process.platform === 'win32' ? '.exe' : ''}`,
);

export const checkHolochainLairBinariesExist = () =>
[...Object.values(HOLOCHAIN_BINARIES), LAIR_BINARY].every(fs.existsSync);

export { HOLOCHAIN_BINARIES, LAIR_BINARY };
11 changes: 11 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ import {
InstallKandoSchema,
LOADING_PROGRESS_UPDATE,
mainScreen,
MISSING_BINARIES,
NO_RUNNING_HOLOCHAIN_MANAGER_ERROR,
settingsScreen,
WRONG_INSTALLED_APP_STRUCTURE,
} from '../types';
import { checkHolochainLairBinariesExist } from './binaries';
import { validateArgs } from './cli';
import { LauncherFileSystem } from './filesystem';
import { HolochainManager } from './holochainManager';
Expand Down Expand Up @@ -364,6 +366,15 @@ const router = t.router({
await holochainManager.installWebHapp(filePath, appId, networkSeed);
}),
lairSetupRequired: t.procedure.query(() => {
const holochainLairBinariesExist = checkHolochainLairBinariesExist();

if (!holochainLairBinariesExist) {
console.log('error');
return throwTRPCErrorError({
message: MISSING_BINARIES,
});
}

const isInitialized =
LAUNCHER_FILE_SYSTEM.keystoreInitialized() ||
VALIDATED_CLI_ARGS.holochainVersion.type === 'running-external';
Expand Down
2 changes: 1 addition & 1 deletion src/main/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function isHappAlreadyOpened({
return true;
}

export function breakingVersion(version) {
export function breakingVersion(version: string) {
if (!semver.valid(version)) {
throw new Error('Version is not valid semver.');
}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/lib/locale/en/common.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"addApps": "Add Apps",
"appError": "App Error",
"back": "Back",
"chooseAPassword": "Choose a password",
"chooseCarefullyPasswordsCanNotBeRecovered": "Choose carefully! Passwords can not be recovered.",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/lib/locale/en/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"fileUndefinedError": "File undefined",
"initializeLairKeystoreError": "Error initializing lair keystore",
"launchLairKeystoreError": "Error launching lair keystore",
"missingBinaries": "There are missing holochain or lair keystore binaries",
"noRunningHolochainManagerError": "No running Holochain manager",
"unknownError": "Unknown error",
"wrongInstalledAppStructure": "Wrong installed app structure",
Expand Down
Loading