diff --git a/.changeset/fast-crabs-fly.md b/.changeset/fast-crabs-fly.md new file mode 100644 index 0000000..63a7891 --- /dev/null +++ b/.changeset/fast-crabs-fly.md @@ -0,0 +1,6 @@ +--- +'renterd': patch +'hostd': patch +--- + +Fixed an issue with the binary embedding. diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 7f445fb..c6eaf2d 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -21,6 +21,8 @@ runs: node-version: ${{ inputs.node_version }} registry-url: https://registry.npmjs.org cache: 'yarn' + cache-dependency-path: '**/yarn.lock' + cache-key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - name: Install run: yarn shell: bash diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a3f2a06..f9d79ea 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -56,6 +56,11 @@ jobs: - name: Build run: yarn workspace ${{ matrix.app }} build shell: bash + - name: Download daemon binary + run: yarn workspace ${{ matrix.app }} download:binary + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Package executable bundles, sign and notarize, make distributables env: APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} @@ -78,6 +83,11 @@ jobs: - name: Build run: yarn workspace ${{ matrix.app }} build shell: bash + - name: Download daemon binary + run: yarn workspace ${{ matrix.app }} download:binary + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Package executable bundles, make distributables run: yarn workspace ${{ matrix.app }} make --arch=arm64,x64 shell: bash @@ -101,6 +111,8 @@ jobs: - name: Download daemon binary run: yarn workspace ${{ matrix.app }} download:binary shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Package executable bundles, sign and notarize, make distributables run: | yarn workspace ${{ matrix.app }} make --arch=x64 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fe3c85b..279898d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -56,6 +56,8 @@ jobs: - name: Download daemon binary run: yarn workspace ${{ matrix.app }} download:binary shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Package executable bundles, sign and notarize, make and publish distributables env: APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} @@ -84,6 +86,8 @@ jobs: - name: Download daemon binary run: yarn workspace ${{ matrix.app }} download:binary shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Package executable bundles, make and publish distributables env: BUCKET_ACCESS_KEY_ID: ${{ secrets.BUCKET_ACCESS_KEY_ID }} @@ -111,6 +115,8 @@ jobs: - name: Download daemon binary run: yarn workspace ${{ matrix.app }} download:binary shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Package executable bundles, sign and notarize, make and publish distributables env: BUCKET_ACCESS_KEY_ID: ${{ secrets.BUCKET_ACCESS_KEY_ID }} diff --git a/hostd/forge.config.js b/hostd/forge.config.js index 5f63f98..70b333a 100644 --- a/hostd/forge.config.js +++ b/hostd/forge.config.js @@ -8,6 +8,7 @@ module.exports = { appleApiKeyId: process.env.APPLE_API_KEY, appleApiIssuer: process.env.APPLE_API_ISSUER, }, + extraResource: ['bin'], icon: './assets/icons/icon', }, rebuildConfig: {}, diff --git a/hostd/main/asset.ts b/hostd/main/asset.ts index 1b192f4..2038db2 100644 --- a/hostd/main/asset.ts +++ b/hostd/main/asset.ts @@ -1,8 +1,17 @@ import path from 'path' -import { env } from './env' + +export function getResourcePath(name: string) { + return path.join(process.resourcesPath, name) +} + +export function getResourceAsarPath(name: string) { + return getResourcePath(path.join('app.asar', name)) +} + +export function getResourceAsarUnpackedPath(name: string) { + return getResourcePath(path.join('app.asar.unpacked', name)) +} export function getAsset(name: string) { - return env.isDev - ? path.join(process.cwd(), 'assets', name) - : path.join(__dirname, '../assets', name) + return getResourceAsarPath(path.join('assets', name)) } diff --git a/hostd/main/binary.ts b/hostd/main/binary.ts index 08c3f35..79d918e 100644 --- a/hostd/main/binary.ts +++ b/hostd/main/binary.ts @@ -1,10 +1,8 @@ import * as path from 'path' -import { env } from './env' +import { getResourcePath } from './asset' export function getBinaryDirectoryPath(): string { - return env.isDev - ? path.join(process.cwd(), 'bin') - : path.join(__dirname, '../bin') + return getResourcePath('bin') } export function getBinaryFilePath(): string { diff --git a/hostd/main/window.ts b/hostd/main/window.ts index cae3758..16d7190 100644 --- a/hostd/main/window.ts +++ b/hostd/main/window.ts @@ -1,9 +1,9 @@ -import path, { join } from 'path' +import { join } from 'path' import { BrowserWindow, app } from 'electron' import { format } from 'url' import { state } from './state' import { system } from './system' -import { getAsset } from './asset' +import { getAsset, getResourceAsarPath } from './asset' import { env } from './env' export function initWindow() { @@ -30,7 +30,7 @@ export function initWindow() { const url = env.isDev ? 'http://localhost:8000/' : format({ - pathname: path.join(__dirname, '../../renderer/out/index.html'), + pathname: getResourceAsarPath('renderer/out/index.html'), protocol: 'file:', slashes: true, }) diff --git a/hostd/package.json b/hostd/package.json index eea977b..4e697bb 100644 --- a/hostd/package.json +++ b/hostd/package.json @@ -82,14 +82,5 @@ "postcss": "^8.4.31", "rimraf": "^3.0.2", "typescript": "5.0.3" - }, - "build": { - "icon": "assets/appicon.png", - "asar": true, - "files": [ - "dist", - "assets", - "bin" - ] } } diff --git a/hostd/scripts/download.ts b/hostd/scripts/download.ts index 935f100..30708cb 100644 --- a/hostd/scripts/download.ts +++ b/hostd/scripts/download.ts @@ -24,7 +24,9 @@ downloadRelease() async function downloadRelease(): Promise { try { - const octokit = new Octokit() + const octokit = new Octokit({ + auth: process.env.GITHUB_TOKEN, + }) const releaseData = await octokit.repos.getLatestRelease({ owner: 'SiaFoundation', repo: 'hostd', @@ -138,7 +140,7 @@ function releaseAsset(): string { } } - return `renterd_${goos}_${goarch}.zip` + return `hostd_${goos}_${goarch}.zip` } function getBinaryDirectoryPath(): string { diff --git a/renterd/forge.config.js b/renterd/forge.config.js index a3f7832..fb33297 100644 --- a/renterd/forge.config.js +++ b/renterd/forge.config.js @@ -8,6 +8,7 @@ module.exports = { appleApiKeyId: process.env.APPLE_API_KEY, appleApiIssuer: process.env.APPLE_API_ISSUER, }, + extraResource: ['bin'], icon: './assets/icons/icon', }, rebuildConfig: {}, diff --git a/renterd/main/asset.ts b/renterd/main/asset.ts index 1b192f4..2038db2 100644 --- a/renterd/main/asset.ts +++ b/renterd/main/asset.ts @@ -1,8 +1,17 @@ import path from 'path' -import { env } from './env' + +export function getResourcePath(name: string) { + return path.join(process.resourcesPath, name) +} + +export function getResourceAsarPath(name: string) { + return getResourcePath(path.join('app.asar', name)) +} + +export function getResourceAsarUnpackedPath(name: string) { + return getResourcePath(path.join('app.asar.unpacked', name)) +} export function getAsset(name: string) { - return env.isDev - ? path.join(process.cwd(), 'assets', name) - : path.join(__dirname, '../assets', name) + return getResourceAsarPath(path.join('assets', name)) } diff --git a/renterd/main/binary.ts b/renterd/main/binary.ts index 581d9e1..bb50723 100644 --- a/renterd/main/binary.ts +++ b/renterd/main/binary.ts @@ -1,10 +1,8 @@ import * as path from 'path' -import { env } from './env' +import { getResourcePath } from './asset' export function getBinaryDirectoryPath(): string { - return env.isDev - ? path.join(process.cwd(), 'bin') - : path.join(__dirname, '../bin') + return getResourcePath('bin') } export function getBinaryFilePath(): string { diff --git a/renterd/main/daemon.ts b/renterd/main/daemon.ts index ae30464..2cd4893 100644 --- a/renterd/main/daemon.ts +++ b/renterd/main/daemon.ts @@ -10,6 +10,7 @@ export async function startDaemon(): Promise { await stopDaemon() const config = getConfig() const binaryFilePath = getBinaryFilePath() + state.daemon = spawn(binaryFilePath, [], { env: { ...process.env, RENTERD_CONFIG_FILE: getConfigFilePath() }, cwd: config.directory, diff --git a/renterd/main/window.ts b/renterd/main/window.ts index cae3758..16d7190 100644 --- a/renterd/main/window.ts +++ b/renterd/main/window.ts @@ -1,9 +1,9 @@ -import path, { join } from 'path' +import { join } from 'path' import { BrowserWindow, app } from 'electron' import { format } from 'url' import { state } from './state' import { system } from './system' -import { getAsset } from './asset' +import { getAsset, getResourceAsarPath } from './asset' import { env } from './env' export function initWindow() { @@ -30,7 +30,7 @@ export function initWindow() { const url = env.isDev ? 'http://localhost:8000/' : format({ - pathname: path.join(__dirname, '../../renderer/out/index.html'), + pathname: getResourceAsarPath('renderer/out/index.html'), protocol: 'file:', slashes: true, }) diff --git a/renterd/package.json b/renterd/package.json index 7936b35..3264f1a 100644 --- a/renterd/package.json +++ b/renterd/package.json @@ -82,14 +82,5 @@ "postcss": "^8.4.31", "rimraf": "^3.0.2", "typescript": "5.0.3" - }, - "build": { - "icon": "assets/appicon.png", - "asar": true, - "files": [ - "dist", - "assets", - "bin" - ] } } diff --git a/renterd/scripts/download.ts b/renterd/scripts/download.ts index 11bf53c..9e3f634 100644 --- a/renterd/scripts/download.ts +++ b/renterd/scripts/download.ts @@ -24,7 +24,9 @@ downloadRelease() async function downloadRelease(): Promise { try { - const octokit = new Octokit() + const octokit = new Octokit({ + auth: process.env.GITHUB_TOKEN, + }) const releaseData = await octokit.repos.getLatestRelease({ owner: 'SiaFoundation', repo: 'renterd',