Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
55 changes: 53 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,44 @@ jobs:
${{ matrix.binary }}-${{ matrix.arch }}.sha256
retention-days: 7

build-frontend:
name: Build frontend
runs-on: ubuntu-latest
needs: prepare
if: needs.prepare.outputs.should_build == 'true'
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: app/package-lock.json

- name: Install dependencies
working-directory: app
run: npm ci

- name: Build
working-directory: app
env:
VITE_API_URL: ""
run: npm run build

- name: Archive
run: tar -czf csfx-frontend.tar.gz -C app/build .

- name: Checksum
run: sha256sum csfx-frontend.tar.gz > csfx-frontend.tar.gz.sha256

- uses: actions/upload-artifact@v4
with:
name: csfx-frontend
path: |
csfx-frontend.tar.gz
csfx-frontend.tar.gz.sha256
retention-days: 7

build-cp-binaries:
name: Build CP ${{ matrix.binary }} (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
Expand Down Expand Up @@ -184,7 +222,7 @@ jobs:
attach-binaries-release:
name: Attach binaries to release
runs-on: ubuntu-latest
needs: [prepare, build-binaries, build-cp-binaries]
needs: [prepare, build-binaries, build-cp-binaries, build-frontend]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -214,6 +252,8 @@ jobs:
csfx-agent-amd64.sha256 \
csfx-agent-arm64 \
csfx-agent-arm64.sha256 \
csfx-frontend.tar.gz \
csfx-frontend.tar.gz.sha256 \
${CP_BINS} \
--clobber
env:
Expand All @@ -222,7 +262,7 @@ jobs:
update-infra:
name: Update CSFX-Infra versions.nix
runs-on: ubuntu-latest
needs: [prepare, build-binaries, build-cp-binaries, attach-binaries-release]
needs: [prepare, build-binaries, build-cp-binaries, build-frontend, attach-binaries-release]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -248,6 +288,11 @@ jobs:
path: /tmp/cp-binaries
merge-multiple: true

- uses: actions/download-artifact@v4
with:
name: csfx-frontend
path: /tmp/frontend

- name: Write versions.nix
run: |
VERSION="${{ needs.prepare.outputs.version }}"
Expand All @@ -264,6 +309,8 @@ jobs:
awk '{print $1}' "/tmp/cp-binaries/${file}.sha256" 2>/dev/null
}

FRONTEND_SHA256=$(awk '{print $1}' /tmp/frontend/csfx-frontend.tar.gz.sha256 2>/dev/null)

cat > infra/versions.nix <<EOF
{
csfx = {
Expand Down Expand Up @@ -360,6 +407,10 @@ jobs:
};
};
};
frontend = {
url = "${RELEASE_BASE}/csfx-frontend.tar.gz";
sha256 = "${FRONTEND_SHA256}";
};
};
}
EOF
Expand Down
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sea-orm-migration = { version = "1.1.0", features = ["runtime-tokio-rustls", "sq

# Web framework
axum = "0.7.5"
tower-http = { version = "0.5.2", features = ["cors", "trace"] }
tower-http = { version = "0.5.2", features = ["cors", "trace", "fs"] }
hyper = "1.5"
hyper-util = { version = "0.1", features = ["client", "client-legacy", "http1", "http2", "tokio"] }
http = "1.1"
Expand Down
11 changes: 11 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@internationalized/date": "^3.12.1",
"@lucide/svelte": "^1.17.0",
"@sveltejs/adapter-auto": "^7.0.1",
"@sveltejs/adapter-static": "^3.0.10",
"@sveltejs/kit": "^2.57.0",
"@sveltejs/vite-plugin-svelte": "^7.0.0",
"@tailwindcss/vite": "^4.2.2",
Expand Down
73 changes: 73 additions & 0 deletions app/src/lib/api/system.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const API_BASE = (import.meta.env.VITE_API_URL ?? 'http://localhost:8000') + '/api';

export interface UpdateStatus {
current_version: string;
desired_version: string | null;
available_flake_rev: string | null;
desired_flake_rev: string | null;
build_status: string | null;
last_result: string | null;
paused: boolean;
}

export async function getUpdateStatus(token: string): Promise<UpdateStatus> {
const res = await fetch(`${API_BASE}/system/update/status`, {
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) throw new Error(`update status fetch failed: ${res.status}`);
return res.json();
}

export async function triggerUpdate(token: string, version: string): Promise<void> {
const res = await fetch(`${API_BASE}/system/update`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ version }),
});
if (!res.ok) throw new Error(`trigger update failed: ${res.status}`);
}

export async function pauseUpdate(token: string): Promise<void> {
const res = await fetch(`${API_BASE}/system/update/pause`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) throw new Error(`pause update failed: ${res.status}`);
}

export async function resumeUpdate(token: string): Promise<void> {
const res = await fetch(`${API_BASE}/system/update/resume`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) throw new Error(`resume update failed: ${res.status}`);
}

export interface ReleaseEntry {
version: string;
tag: string;
prerelease: boolean;
html_url: string;
name: string | null;
is_current: boolean;
is_newer: boolean;
}

export interface ReleasesResponse {
current_version: string;
update_available: boolean;
latest_stable: string | null;
releases: ReleaseEntry[];
}

export async function getReleases(token: string, includePre = false): Promise<ReleasesResponse> {
const url = `${API_BASE}/system/releases${includePre ? '?include_pre=true' : ''}`;
const res = await fetch(url, {
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) throw new Error(`releases fetch failed: ${res.status}`);
return res.json();
}
Loading
Loading