mirror of https://github.com/jetkvm/kvm.git
Compare commits
12 Commits
1ebc9e07ee
...
0e000f1784
| Author | SHA1 | Date |
|---|---|---|
|
|
0e000f1784 | |
|
|
83caa8f82d | |
|
|
57fbee1490 | |
|
|
0e65c0a9a9 | |
|
|
2dafb5c9c1 | |
|
|
566305549f | |
|
|
1505c37e4c | |
|
|
564eee9b00 | |
|
|
fab575dbe0 | |
|
|
97958e7b86 | |
|
|
2f7042df18 | |
|
|
2cadda4e00 |
|
|
@ -0,0 +1,126 @@
|
|||
name: Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-22.04]
|
||||
go: [1.21, 1.23.4]
|
||||
node: [21]
|
||||
goos: [linux]
|
||||
goarch: [arm]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
- name: Install Dependencies
|
||||
working-directory: ui
|
||||
run: npm ci
|
||||
|
||||
- name: Build UI
|
||||
working-directory: ui
|
||||
run: npm run build:device
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
|
||||
- name: Install Go Dependencies
|
||||
run: |
|
||||
go mod download
|
||||
|
||||
- name: Build Binaries
|
||||
env:
|
||||
GOOS: ${{ matrix.goos }}
|
||||
GOARCH: ${{ matrix.goarch }}
|
||||
run: |
|
||||
GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="-s -w -X kvm.builtAppVersion=dev-${GIT_COMMIT:0:7}" -o bin/jetkvm_app cmd/main.go
|
||||
chmod 755 bin/jetkvm_app
|
||||
|
||||
- name: Upload Debug Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ (github.ref == 'refs/heads/main' || github.event_name == 'pull_request') && matrix.go == '1.21' }}
|
||||
with:
|
||||
name: jetkvm_app_debug
|
||||
path: bin/jetkvm_app
|
||||
|
||||
comment:
|
||||
name: Comment
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Generate Links
|
||||
id: linksa
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
ARTIFACT_ID=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --jq '.artifacts[0].id')
|
||||
echo "ARTIFACT_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/$ARTIFACT_ID" >> $GITHUB_ENV
|
||||
echo "LATEST_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Comment on PR
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
TITLE="${{ github.event.pull_request.title }}"
|
||||
PR_NUMBER=${{ github.event.pull_request.number }}
|
||||
else
|
||||
TITLE="main branch"
|
||||
fi
|
||||
|
||||
COMMENT=$(cat << EOF
|
||||
✅ **Build successfully for $TITLE!**
|
||||
|
||||
| Name | Link |
|
||||
|------------------|----------------------------------------------------------------------|
|
||||
| 🔗 Debug Binary | [Download](${{ env.ARTIFACT_URL }}) |
|
||||
| 🔗 Latest commit | [${{ env.LATEST_COMMIT }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
|
||||
EOF
|
||||
)
|
||||
|
||||
# Post Comment
|
||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||
# Look for an existing comment
|
||||
COMMENT_ID=$(gh api repos/${{ github.repository }}/issues/$PR_NUMBER/comments \
|
||||
--jq '.[] | select(.body | contains("✅ **Build successfully for")) | .id')
|
||||
|
||||
if [ -z "$COMMENT_ID" ]; then
|
||||
# Create a new comment if none exists
|
||||
gh pr comment $PR_NUMBER --body "$COMMENT"
|
||||
else
|
||||
# Update the existing comment
|
||||
gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID \
|
||||
--method PATCH \
|
||||
-f body="$COMMENT"
|
||||
fi
|
||||
else
|
||||
# Log the comment for main branch
|
||||
echo "$COMMENT"
|
||||
fi
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 21
|
||||
|
||||
- name: Install Dependencies
|
||||
working-directory: ui
|
||||
run: npm ci
|
||||
|
||||
- name: Build UI
|
||||
working-directory: ui
|
||||
run: npm run build:device
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 1.21
|
||||
|
||||
- name: Build Release Binaries
|
||||
env:
|
||||
REF: ${{ github.ref }}
|
||||
run: |
|
||||
GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="-s -w -X kvm.builtAppVersion=${REF:11}" -o bin/jetkvm_app cmd/main.go
|
||||
chmod 755 bin/jetkvm_app
|
||||
|
||||
- name: Create checksum
|
||||
env:
|
||||
REF: ${{ github.ref }}
|
||||
run: |
|
||||
SUM=$(shasum -a 256 bin/jetkvm_app | cut -d ' ' -f 1)
|
||||
echo -e "\n#### SHA256 Checksum\n\`\`\`\n$SUM bin/jetkvm_app\n\`\`\`\n" >> ./RELEASE_CHANGELOG
|
||||
echo -e "$SUM bin/jetkvm_app\n" > checksums.txt
|
||||
|
||||
- name: Create Release Branch
|
||||
env:
|
||||
REF: ${{ github.ref }}
|
||||
run: |
|
||||
BRANCH=release/${REF:10}
|
||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
git checkout -b ${BRANCH}
|
||||
git push -u origin ${BRANCH}
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: softprops/action-gh-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
draft: true
|
||||
prerelease: ${{ contains(github.ref, 'rc') || contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
|
||||
body_path: ./RELEASE_CHANGELOG
|
||||
|
||||
- name: Upload JetKVM binary
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: bin/jetkvm_app
|
||||
asset_name: jetkvm_app
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
- name: Upload checksum
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./checksums.txt
|
||||
asset_name: checksums.txt
|
||||
asset_content_type: text/plain
|
||||
12
jsonrpc.go
12
jsonrpc.go
|
|
@ -282,6 +282,17 @@ func rpcGetUpdateStatus() (*UpdateStatus, error) {
|
|||
return updateStatus, nil
|
||||
}
|
||||
|
||||
func rpcGetLocalVersion() (*LocalMetadata, error) {
|
||||
systemVersion, appVersion, err := GetLocalVersion()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting local version: %w", err)
|
||||
}
|
||||
return &LocalMetadata{
|
||||
AppVersion: appVersion.String(),
|
||||
SystemVersion: systemVersion.String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func rpcTryUpdate() error {
|
||||
includePreRelease := config.IncludePreRelease
|
||||
go func() {
|
||||
|
|
@ -1191,6 +1202,7 @@ var rpcHandlers = map[string]RPCHandler{
|
|||
"setEDID": {Func: rpcSetEDID, Params: []string{"edid"}},
|
||||
"getDevChannelState": {Func: rpcGetDevChannelState},
|
||||
"setDevChannelState": {Func: rpcSetDevChannelState, Params: []string{"enabled"}},
|
||||
"getLocalVersion": {Func: rpcGetLocalVersion},
|
||||
"getUpdateStatus": {Func: rpcGetUpdateStatus},
|
||||
"tryUpdate": {Func: rpcTryUpdate},
|
||||
"getDevModeState": {Func: rpcGetDevModeState},
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ export interface JsonRpcErrorResponse {
|
|||
|
||||
export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
||||
|
||||
export const RpcMethodNotFound = -32601;
|
||||
|
||||
const callbackStore = new Map<number | string, (resp: JsonRpcResponse) => void>();
|
||||
let requestCounter = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
import { useCallback } from "react";
|
||||
|
||||
import { useDeviceStore } from "@/hooks/stores";
|
||||
import { type JsonRpcResponse, RpcMethodNotFound, useJsonRpc } from "@/hooks/useJsonRpc";
|
||||
import notifications from "@/notifications";
|
||||
|
||||
export interface VersionInfo {
|
||||
appVersion: string;
|
||||
systemVersion: string;
|
||||
}
|
||||
|
||||
export interface SystemVersionInfo {
|
||||
local: VersionInfo;
|
||||
remote?: VersionInfo;
|
||||
systemUpdateAvailable: boolean;
|
||||
appUpdateAvailable: boolean;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export function useVersion() {
|
||||
const {
|
||||
appVersion,
|
||||
systemVersion,
|
||||
setAppVersion,
|
||||
setSystemVersion,
|
||||
} = useDeviceStore();
|
||||
const { send } = useJsonRpc();
|
||||
const getVersionInfo = useCallback(() => {
|
||||
return new Promise<SystemVersionInfo>((resolve, reject) => {
|
||||
send("getUpdateStatus", {}, (resp: JsonRpcResponse) => {
|
||||
if ("error" in resp) {
|
||||
notifications.error(`Failed to check for updates: ${resp.error}`);
|
||||
reject(new Error("Failed to check for updates"));
|
||||
} else {
|
||||
const result = resp.result as SystemVersionInfo;
|
||||
setAppVersion(result.local.appVersion);
|
||||
setSystemVersion(result.local.systemVersion);
|
||||
|
||||
if (result.error) {
|
||||
notifications.error(`Failed to check for updates: ${result.error}`);
|
||||
reject(new Error("Failed to check for updates"));
|
||||
} else {
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}, [send, setAppVersion, setSystemVersion]);
|
||||
|
||||
const getLocalVersion = useCallback(() => {
|
||||
return new Promise<VersionInfo>((resolve, reject) => {
|
||||
send("getLocalVersion", {}, (resp: JsonRpcResponse) => {
|
||||
if ("error" in resp) {
|
||||
console.log(resp.error)
|
||||
if (resp.error.code === RpcMethodNotFound) {
|
||||
console.warn("Failed to get device version, using legacy version");
|
||||
return getVersionInfo().then(result => resolve(result.local)).catch(reject);
|
||||
}
|
||||
console.error("Failed to get device version N", resp.error);
|
||||
notifications.error(`Failed to get device version: ${resp.error}`);
|
||||
reject(new Error("Failed to get device version"));
|
||||
} else {
|
||||
const result = resp.result as VersionInfo;
|
||||
|
||||
setAppVersion(result.appVersion);
|
||||
setSystemVersion(result.systemVersion);
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, [send, setAppVersion, setSystemVersion, getVersionInfo]);
|
||||
|
||||
return {
|
||||
getVersionInfo,
|
||||
getLocalVersion,
|
||||
appVersion,
|
||||
systemVersion,
|
||||
};
|
||||
}
|
||||
|
|
@ -3,12 +3,12 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|||
import { CheckCircleIcon } from "@heroicons/react/20/solid";
|
||||
|
||||
import Card from "@/components/Card";
|
||||
import { JsonRpcResponse, useJsonRpc } from "@/hooks/useJsonRpc";
|
||||
import { useJsonRpc } from "@/hooks/useJsonRpc";
|
||||
import { Button } from "@components/Button";
|
||||
import { UpdateState, useDeviceStore, useUpdateStore } from "@/hooks/stores";
|
||||
import notifications from "@/notifications";
|
||||
import { UpdateState, useUpdateStore } from "@/hooks/stores";
|
||||
import LoadingSpinner from "@/components/LoadingSpinner";
|
||||
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation";
|
||||
import { SystemVersionInfo, useVersion } from "@/hooks/useVersion";
|
||||
|
||||
export default function SettingsGeneralUpdateRoute() {
|
||||
const navigate = useNavigate();
|
||||
|
|
@ -41,13 +41,7 @@ export default function SettingsGeneralUpdateRoute() {
|
|||
return <Dialog onClose={() => navigate("..")} onConfirmUpdate={onConfirmUpdate} />;
|
||||
}
|
||||
|
||||
export interface SystemVersionInfo {
|
||||
local: { appVersion: string; systemVersion: string };
|
||||
remote?: { appVersion: string; systemVersion: string };
|
||||
systemUpdateAvailable: boolean;
|
||||
appUpdateAvailable: boolean;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
|
||||
export function Dialog({
|
||||
onClose,
|
||||
|
|
@ -134,30 +128,8 @@ function LoadingState({
|
|||
}) {
|
||||
const [progressWidth, setProgressWidth] = useState("0%");
|
||||
const abortControllerRef = useRef<AbortController | null>(null);
|
||||
const { setAppVersion, setSystemVersion } = useDeviceStore();
|
||||
const { send } = useJsonRpc();
|
||||
|
||||
const getVersionInfo = useCallback(() => {
|
||||
return new Promise<SystemVersionInfo>((resolve, reject) => {
|
||||
send("getUpdateStatus", {}, (resp: JsonRpcResponse) => {
|
||||
if ("error" in resp) {
|
||||
notifications.error(`Failed to check for updates: ${resp.error}`);
|
||||
reject(new Error("Failed to check for updates"));
|
||||
} else {
|
||||
const result = resp.result as SystemVersionInfo;
|
||||
setAppVersion(result.local.appVersion);
|
||||
setSystemVersion(result.local.systemVersion);
|
||||
|
||||
if (result.error) {
|
||||
notifications.error(`Failed to check for updates: ${result.error}`);
|
||||
reject(new Error("Failed to check for updates"));
|
||||
} else {
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}, [send, setAppVersion, setSystemVersion]);
|
||||
const { getVersionInfo } = useVersion();
|
||||
|
||||
const progressBarRef = useRef<HTMLDivElement>(null);
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -19,14 +19,12 @@ import { CLOUD_API, DEVICE_API } from "@/ui.config";
|
|||
import api from "@/api";
|
||||
import { checkAuth, isInCloud, isOnDevice } from "@/main";
|
||||
import { cx } from "@/cva.config";
|
||||
import notifications from "@/notifications";
|
||||
import {
|
||||
KeyboardLedState,
|
||||
KeysDownState,
|
||||
NetworkState,
|
||||
OtaState,
|
||||
USBStates,
|
||||
useDeviceStore,
|
||||
useHidStore,
|
||||
useNetworkStateStore,
|
||||
User,
|
||||
|
|
@ -42,7 +40,7 @@ const ConnectionStatsSidebar = lazy(() => import('@/components/sidebar/connectio
|
|||
const Terminal = lazy(() => import('@components/Terminal'));
|
||||
const UpdateInProgressStatusCard = lazy(() => import("@/components/UpdateInProgressStatusCard"));
|
||||
import Modal from "@/components/Modal";
|
||||
import { JsonRpcRequest, JsonRpcResponse, useJsonRpc } from "@/hooks/useJsonRpc";
|
||||
import { JsonRpcRequest, JsonRpcResponse, RpcMethodNotFound, useJsonRpc } from "@/hooks/useJsonRpc";
|
||||
import {
|
||||
ConnectionFailedOverlay,
|
||||
LoadingConnectionOverlay,
|
||||
|
|
@ -51,7 +49,7 @@ import {
|
|||
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation";
|
||||
import { FeatureFlagProvider } from "@/providers/FeatureFlagProvider";
|
||||
import { DeviceStatus } from "@routes/welcome-local";
|
||||
import { SystemVersionInfo } from "@routes/devices.$id.settings.general.update";
|
||||
import { useVersion } from "@/hooks/useVersion";
|
||||
|
||||
interface LocalLoaderResp {
|
||||
authMode: "password" | "noPassword" | null;
|
||||
|
|
@ -715,7 +713,7 @@ export default function KvmIdRoute() {
|
|||
send("getKeyDownState", {}, (resp: JsonRpcResponse) => {
|
||||
if ("error" in resp) {
|
||||
// -32601 means the method is not supported
|
||||
if (resp.error.code === -32601) {
|
||||
if (resp.error.code === RpcMethodNotFound) {
|
||||
// if we don't support key down state, we know key press is also not available
|
||||
console.warn("Failed to get key down state, switching to old-school", resp.error);
|
||||
setHidRpcDisabled(true);
|
||||
|
|
@ -758,26 +756,13 @@ export default function KvmIdRoute() {
|
|||
if (location.pathname !== "/other-session") navigateTo("/");
|
||||
}, [navigateTo, location.pathname]);
|
||||
|
||||
const { appVersion, setAppVersion, setSystemVersion} = useDeviceStore();
|
||||
const { appVersion, getLocalVersion} = useVersion();
|
||||
|
||||
useEffect(() => {
|
||||
if (appVersion) return;
|
||||
|
||||
send("getUpdateStatus", {}, (resp: JsonRpcResponse) => {
|
||||
if ("error" in resp) {
|
||||
notifications.error(`Failed to get device version: ${resp.error}`);
|
||||
return
|
||||
}
|
||||
|
||||
const result = resp.result as SystemVersionInfo;
|
||||
if (result.error) {
|
||||
notifications.error(`Failed to get device version: ${result.error}`);
|
||||
}
|
||||
|
||||
setAppVersion(result.local.appVersion);
|
||||
setSystemVersion(result.local.systemVersion);
|
||||
});
|
||||
}, [appVersion, send, setAppVersion, setSystemVersion]);
|
||||
getLocalVersion();
|
||||
}, [appVersion, getLocalVersion]);
|
||||
|
||||
const ConnectionStatusElement = useMemo(() => {
|
||||
const hasConnectionFailed =
|
||||
|
|
|
|||
Loading…
Reference in New Issue