Skip to content

Commit e2987ca

Browse files
authored
Merge pull request #3 from octra-labs/fix-binaries
Fix assets in binaries
2 parents 3130691 + 9663062 commit e2987ca

File tree

3 files changed

+74
-27
lines changed

3 files changed

+74
-27
lines changed

.github/workflows/build.yml

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@ jobs:
1616
include:
1717
- os: ubuntu-latest
1818
target: linux-x64
19+
bun-target: bun-linux-x64
1920
artifact-name: wallet-generator-linux-x64
2021
executable-ext: ""
2122
- os: windows-latest
2223
target: windows-x64
24+
bun-target: bun-windows-x64
2325
artifact-name: wallet-generator-windows-x64
2426
executable-ext: ".exe"
2527
- os: macos-13
2628
target: macos-x64
29+
bun-target: bun-darwin-x64
2730
artifact-name: wallet-generator-macos-x64
2831
executable-ext: ""
2932
- os: macos-latest
3033
target: macos-arm64
34+
bun-target: bun-darwin-arm64
3135
artifact-name: wallet-generator-macos-arm64
3236
executable-ext: ""
3337

@@ -51,12 +55,12 @@ jobs:
5155
mkdir C:\temp-bun-cache-init
5256
cd C:\temp-bun-cache-init
5357
echo 'console.log("cache init");' > index.js
54-
bun build --compile --outfile=cache-init${{ matrix.executable-ext }} ./index.js
58+
bun build --compile --target=${{ matrix.bun-target }}-baseline --outfile=cache-init${{ matrix.executable-ext }} ./index.js
5559
cd ${{ github.workspace }}
5660
Remove-Item -Recurse -Force C:\temp-bun-cache-init
5761
5862
- name: Build executable
59-
run: bun build --compile --outfile=wallet-generator${{ matrix.executable-ext }} ./wallet_generator.ts
63+
run: bun build --compile --target=${{ matrix.bun-target }}-baseline --outfile=wallet-generator${{ matrix.executable-ext }} ./wallet_generator.ts
6064

6165
- name: Test executable (Linux/macOS)
6266
if: runner.os != 'Windows'
@@ -80,7 +84,7 @@ jobs:
8084
fi
8185
8286
# Test embedded assets
83-
if curl -f http://localhost:8888/logo.svg > /dev/null 2>&1; then
87+
if curl -f http://localhost:8888/assets/logo.svg > /dev/null 2>&1; then
8488
echo "✓ Embedded assets are working"
8589
else
8690
echo "✗ Embedded assets failed"
@@ -119,7 +123,7 @@ jobs:
119123
120124
# Test embedded assets
121125
try {
122-
$response = Invoke-WebRequest -Uri "http://localhost:8888/logo.svg" -TimeoutSec 10
126+
$response = Invoke-WebRequest -Uri "http://localhost:8888/assets/logo.svg" -TimeoutSec 10
123127
if ($response.StatusCode -eq 200) {
124128
Write-Host "✓ Embedded assets are working"
125129
} else {
@@ -143,3 +147,48 @@ jobs:
143147
name: ${{ matrix.artifact-name }}
144148
path: wallet-generator${{ matrix.executable-ext }}
145149
retention-days: 30
150+
151+
release:
152+
name: Create Release
153+
runs-on: ubuntu-latest
154+
needs: build
155+
if: startsWith(github.ref, 'refs/tags/')
156+
157+
steps:
158+
- name: Checkout code
159+
uses: actions/checkout@v4
160+
161+
- name: Download all artifacts
162+
uses: actions/download-artifact@v4
163+
with:
164+
path: ./artifacts
165+
166+
- name: Display structure of downloaded files
167+
run: ls -la ./artifacts/
168+
169+
- name: Create release archives
170+
run: |
171+
cd ./artifacts
172+
for dir in */; do
173+
artifact_name=${dir%/}
174+
cd "$dir"
175+
if [[ "$artifact_name" == *"windows"* ]]; then
176+
zip "../${artifact_name}.zip" wallet-generator.exe
177+
else
178+
tar -czf "../${artifact_name}.tar.gz" wallet-generator
179+
fi
180+
cd ..
181+
done
182+
ls -la
183+
184+
- name: Create Release
185+
uses: softprops/action-gh-release@v1
186+
with:
187+
files: |
188+
./artifacts/*.zip
189+
./artifacts/*.tar.gz
190+
generate_release_notes: true
191+
draft: false
192+
prerelease: false
193+
env:
194+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
6+
<link rel="icon" type="image/svg+xml" href="/assets/logo.svg" />
77
<title>Octra Wallet Generator</title>
88
<style>
99
@font-face {
1010
font-family: 'National';
11-
src: url('/national-regular.woff2') format('woff2');
11+
src: url('/assets/national-regular.woff2') format('woff2');
1212
font-weight: 400;
1313
font-style: normal;
1414
font-display: swap;
1515
}
1616

1717
@font-face {
1818
font-family: 'FoundersGrotesk';
19-
src: url('/founders-grotesk-bold.woff2') format('woff2');
19+
src: url('/assets/founders-grotesk-bold.woff2') format('woff2');
2020
font-weight: 700;
2121
font-style: normal;
2222
font-display: swap;

wallet_generator.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@ import { fileURLToPath } from "url";
55
import nacl from "tweetnacl";
66
import bip39 from "bip39";
77

8+
import indexHtml from "./index.html" with { type: "text" };
9+
import logoSvg from "./assets/logo.svg" with { type: "text" };
10+
import foundersGroteskFontPath from "./assets/founders-grotesk-bold.woff2" with { type: "file" };
11+
import nationalFontPath from "./assets/national-regular.woff2" with { type: "file" };
12+
813
// ESM equivalent of __dirname
914
const __filename: string = fileURLToPath(import.meta.url);
1015
const __dirname: string = path.dirname(__filename);
1116

1217
// Embed static assets for executable builds
13-
let indexHtml: string = "";
14-
let logoSvg: string = "";
1518
let foundersGroteskFont: ArrayBuffer;
1619
let nationalFont: ArrayBuffer;
1720

1821
// Load assets asynchronously
1922
async function loadAssets() {
2023
try {
21-
indexHtml = await Bun.file("index.html").text();
22-
logoSvg = await Bun.file("assets/logo.svg").text();
23-
foundersGroteskFont = await Bun.file("assets/founders-grotesk-bold.woff2").arrayBuffer();
24-
nationalFont = await Bun.file("assets/national-regular.woff2").arrayBuffer();
24+
foundersGroteskFont = await Bun.file(foundersGroteskFontPath).arrayBuffer();
25+
nationalFont = await Bun.file(nationalFontPath).arrayBuffer();
2526
} catch (error) {
2627
console.warn("Could not load embedded assets:", error.message);
2728
// Assets will be served from filesystem instead
@@ -231,13 +232,13 @@ function deriveForNetwork(
231232
const coinType: number = networkType === 0 ? 0 : networkType;
232233

233234
const basePath: number[] = [
234-
0x80000000 | 345, // Purpose
235-
0x80000000 | coinType, // Coin type
236-
0x80000000 | network, // Network
235+
0x80000000 + 345, // Purpose
236+
0x80000000 + coinType, // Coin type
237+
0x80000000 + network, // Network
237238
];
238239

239-
const contractPath: number[] = [0x80000000 | contract, 0x80000000 | account];
240-
const optionalPath: number[] = [0x80000000 | token, 0x80000000 | subnet];
240+
const contractPath: number[] = [0x80000000 + contract, 0x80000000 + account];
241+
const optionalPath: number[] = [0x80000000 + token, 0x80000000 + subnet];
241242
const finalPath: number[] = [index];
242243

243244
const fullPath: number[] = [
@@ -609,41 +610,38 @@ function serveEmbeddedAsset(pathname: string): Response | null {
609610
});
610611
}
611612
break;
612-
613+
613614
case '/assets/logo.svg':
614-
case '/logo.svg':
615615
if (logoSvg) {
616616
return new Response(logoSvg, {
617617
headers: { 'Content-Type': 'image/svg+xml' }
618618
});
619619
}
620620
break;
621-
621+
622622
case '/assets/founders-grotesk-bold.woff2':
623-
case '/founders-grotesk-bold.woff2':
624623
if (foundersGroteskFont) {
625624
return new Response(foundersGroteskFont, {
626-
headers: {
625+
headers: {
627626
'Content-Type': 'font/woff2',
628627
'Cache-Control': 'public, max-age=31536000'
629628
}
630629
});
631630
}
632631
break;
633-
632+
634633
case '/assets/national-regular.woff2':
635-
case '/national-regular.woff2':
636634
if (nationalFont) {
637635
return new Response(nationalFont, {
638-
headers: {
636+
headers: {
639637
'Content-Type': 'font/woff2',
640638
'Cache-Control': 'public, max-age=31536000'
641639
}
642640
});
643641
}
644642
break;
645643
}
646-
644+
647645
return null;
648646
}
649647

0 commit comments

Comments
 (0)