Skip to content

Commit

Permalink
tauri
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaRickli committed Dec 8, 2024
1 parent 06c6050 commit 8f1d585
Show file tree
Hide file tree
Showing 34 changed files with 5,553 additions and 41 deletions.
169 changes: 141 additions & 28 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,80 +6,132 @@ on:
- published

jobs:
build:
build-static:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

# Required for version patching
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: deno install

- name: Patch version
run: npm version ${{ github.ref_name }} --no-commit-hooks --no-git-tag-version
run: npm version ${{ github.event.release.tag_name }} --no-commit-hooks --no-git-tag-version

- name: Build static app
- name: Build app
run: deno task build
env:
BUILD_TARGET: static

- name: Release static build
- name: Release build
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
run: |
cd ${{github.workspace}}
cp LICENSE build/LICENSE
zip -r headnet-static-${{github.event.release.tag_name}}.zip build
gh release upload ${{github.event.release.tag_name}} headnet-static-${{github.event.release.tag_name}}.zip
zip -r headnet-static-${{ github.event.release.tag_name }}.zip build
gh release upload ${{ github.event.release.tag_name }} headnet-static-${{ github.event.release.tag_name }}.zip
build-node:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'

- name: Build node app
- name: Install dependencies
run: deno install

- name: Patch version
run: npm version ${{ github.event.release.tag_name }} --no-commit-hooks --no-git-tag-version

- name: Build app
run: deno task build

- name: Release node build
- name: Release build
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
run: |
cd ${{github.workspace}}
cp LICENSE build/LICENSE
zip -r headnet-node-${{github.event.release.tag_name}}.zip build
gh release upload ${{github.event.release.tag_name}} headnet-node-${{github.event.release.tag_name}}.zip
zip -r headnet-node-${{ github.event.release.tag_name }}.zip build
gh release upload ${{ github.event.release.tag_name }} headnet-node-${{ github.event.release.tag_name }}.zip
build-docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: deno install

- name: Patch version
run: npm version ${{ github.event.release.tag_name }} --no-commit-hooks --no-git-tag-version

- name: Build app
run: deno task build

- name: Build versioned docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ghcr.io/rickli-cloud/headnet:${{ github.ref_name }}
tags: ghcr.io/rickli-cloud/headnet:${{ github.event.release.tag_name }}
push: true

- name: Build latest docker image
Expand All @@ -90,3 +142,64 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ghcr.io/rickli-cloud/headnet:latest
push: true

build-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest' # for Arm based macs (M1 and above).
args: '--target aarch64-apple-darwin'
- platform: 'macos-latest' # for Intel based macs.
args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
args: ''
- platform: 'windows-latest'
args: ''
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Setup deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: install frontend dependencies
run: deno install

- name: Patch version
run: npm version ${{ github.event.release.tag_name }} --no-commit-hooks --no-git-tag-version

- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_TARGET: static
BASE_PATH: /
with:
tagName: headnet-v__VERSION__
releaseName: 'Headnet v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: ${{ github.event.release.prerelease }}
args: ${{ matrix.args }}
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ For all [releases](https://github.com/rickli-cloud/headnet/releases) there are z

> The node server **is not capable of TLS** and is best used in combination with a reverse proxy. This does not pose a big security risk (assuming the internal network is somewhat secure) as no sensitive data is directly transmitted to this server.
### Desktop application

For all [releases](https://github.com/rickli-cloud/headnet/releases) there are standalone executables or installers provided for different platforms. Thanks to a special client integration it is possible to completely circumvent any CORS restrictions

## Environment configuration

> [!NOTE]
Expand Down Expand Up @@ -128,6 +132,8 @@ deno install

## Building

### Node / Static

Create a production build:

```sh
Expand All @@ -141,6 +147,17 @@ deno task build
> docker run -it --rm --workdir /app -v ${PWD}:/app:rw --entrypoint /bin/sh denoland/deno:latest
> ```
### Tauri
Needs specific configuration to work properly:
- `BASE_PATH = "/"`
- `BUILD_TARGET = "static"`
```sh
deno task tauri build
```
## Developing

Start a development server:
Expand All @@ -153,9 +170,10 @@ deno task dev

Some of the major projects used:

- [Deno 2](https://deno.com/)
- [Svelte 5](https://svelte.dev/)
- [Shadcn](https://www.shadcn-svelte.com/)
- [deno 2](https://deno.com/)
- [tauri 2](https://v2.tauri.app/)
- [svelte 5](https://svelte.dev/)
- [shadcn](https://www.shadcn-svelte.com/)
- [3d-force-graph](https://github.com/vasturiano/3d-force-graph)
- [json-ast-comments](https://github.com/2betop/json-ast-comments)
- [openapi-typescript](https://openapi-ts.dev/)
Expand Down
60 changes: 60 additions & 0 deletions deno.lock

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

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"test": "npm run test:unit -- --run && npm run test:e2e",
"test:e2e": "playwright test",
"gen:openapi:latest": "openapi-typescript https://converter.swagger.io/api/convert?url=https://raw.githubusercontent.com/juanfont/headscale/refs/heads/main/gen/openapiv2/headscale/v1/headscale.swagger.json -o ./src/lib/api/headscale.d.ts",
"msw:init": "msw init"
"msw:init": "msw init",
"tauri": "tauri",
"tauri:build": "tauri build"
},
"devDependencies": {
"3d-force-graph": "^1.73.4",
Expand All @@ -27,6 +29,8 @@
"@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@tauri-apps/api": "^2.1.1",
"@tauri-apps/cli": "^2.1.0",
"@types/eslint": "^9.6.0",
"@types/node": "^22.8.5",
"autoprefixer": "^10.4.20",
Expand Down Expand Up @@ -63,6 +67,7 @@
"zod": "^3.23.8"
},
"dependencies": {
"@tauri-apps/plugin-http": "~2.0.1",
"dotenv": "^16.4.5"
},
"msw": {
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/gen/schemas
Loading

0 comments on commit 8f1d585

Please sign in to comment.