Code signing + auto updater (#122)

* Code signing + auto updater

* remove dist

* update actions

* fixes

* fix more

* commit

* fix cache dir

* quotes

* fix hopefully?

* why yaml

* Fix cache dep path

* Fix updating artifacts

* fix ubuntu ver

* enable autoupdater

* fix pubkey

* fix invalid config

* pass in signing vars

* update pubkey

* Improve compile times
This commit is contained in:
Geometrically 2023-05-23 11:14:22 -07:00 committed by GitHub
parent 1b47eb71e1
commit 8ff1b0d108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 148 additions and 75 deletions

View File

@ -13,28 +13,30 @@ jobs:
run: run:
working-directory: ./theseus_cli working-directory: ./theseus_cli
steps: steps:
- uses: actions/checkout@v2 - name: Checkout
- name: install dependencies (ubuntu only) uses: actions/checkout@v3
- name: install dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: Get build cache
id: cache-build - name: Rust setup
uses: actions/cache@v2 uses: dtolnay/rust-toolchain@stable
with: with:
path: ../target/**
key: ${{ runner.os }}-theseus
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy components: rustfmt, clippy
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
name: Build program name: Build program
with: with:
command: build command: build
args: --bin theseus_cli args: --bin theseus_cli
- name: Run Lint - name: Run Lint
uses: actions-rs/clippy-check@v1 uses: actions-rs/clippy-check@v1
with: with:

View File

@ -13,22 +13,19 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Use Node.js
- name: Sync node version and setup cache
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 18.x node-version: 16
- name: Get yarn cache cache: 'yarn'
id: yarn-cache cache-dependency-path: "theseus_gui"
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies - name: Install dependencies
run: yarn install --immutable --immutable-cache --check-cache run: yarn install --immutable --immutable-cache --check-cache
- name: Run Lint - name: Run Lint
run: yarn run lint run: yarn run lint
- name: Build - name: Build
run: yarn run build run: yarn run build

View File

@ -14,46 +14,80 @@ jobs:
defaults: defaults:
run: run:
working-directory: ./theseus_gui working-directory: ./theseus_gui
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: setup node
- name: Rust setup (mac)
if: startsWith(matrix.platform, 'macos')
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
targets: aarch64-apple-darwin
- name: Rust setup
if: "!startsWith(matrix.platform, 'macos')"
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
- name: Sync node version and setup cache
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 16
- name: Install toolchain cache: 'yarn'
uses: actions-rs/toolchain@v1 cache-dependency-path: "theseus_gui"
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: install dependencies (ubuntu only) - name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-20.04' if: startsWith(matrix.platform, 'ubuntu')
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: Get build cache
id: cache-build
uses: actions/cache@v2
with:
path: ../target/**
key: ${{ runner.os }}-theseus
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: install frontend dependencies - name: install frontend dependencies
run: yarn install --immutable --immutable-cache --check-cache run: yarn install --immutable --immutable-cache --check-cache
- uses: tauri-apps/tauri-action@v0
- name: build app (macos)
uses: tauri-apps/tauri-action@v0
id: build_os_mac
if: startsWith(matrix.platform, 'macos')
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run Lint ENABLE_CODE_SIGNING: ${{ secrets.APPLE_CERTIFICATE }}
if: matrix.platform == 'ubuntu-20.04' APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
uses: actions-rs/clippy-check@v1 APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with: with:
token: ${{ secrets.GITHUB_TOKEN }} args: --target universal-apple-darwin
args: --bin theseus_cli
- name: build app
uses: tauri-apps/tauri-action@v0
id: build_os
if: "!startsWith(matrix.platform, 'macos')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
- name: upload ${{ matrix.platform }}
uses: actions/upload-artifact@v3
if: startsWith(matrix.platform, 'macos')
with:
name: ${{ matrix.platform }}
path: "${{ join(fromJSON(steps.build_os_mac.outputs.artifactPaths), '\n') }}"
- name: upload ${{ matrix.platform }}
uses: actions/upload-artifact@v3
if: "!startsWith(matrix.platform, 'macos')"
with:
name: ${{ matrix.platform }}
path: "${{ join(fromJSON(steps.build_os.outputs.artifactPaths), '\n') }}"

27
Cargo.lock generated
View File

@ -179,6 +179,22 @@ dependencies = [
"system-deps 6.0.4", "system-deps 6.0.4",
] ]
[[package]]
name = "attohttpc"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fcf00bc6d5abb29b5f97e3c61a90b6d3caa12f3faf897d4a3e3607c050a35a7"
dependencies = [
"flate2",
"http",
"log",
"native-tls",
"serde",
"serde_json",
"serde_urlencoded",
"url",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.1.0" version = "1.1.0"
@ -2048,6 +2064,12 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "minisign-verify"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "933dca44d65cdd53b355d0b73d380a2ff5da71f87f036053188bf1eab6a19881"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.6.2" version = "0.6.2"
@ -3540,6 +3562,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe7e0f1d535e7cbbbab43c82be4fc992b84f9156c16c160955617e0260ebc449" checksum = "fe7e0f1d535e7cbbbab43c82be4fc992b84f9156c16c160955617e0260ebc449"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"attohttpc",
"base64 0.13.1",
"cocoa", "cocoa",
"dirs-next", "dirs-next",
"embed_plist", "embed_plist",
@ -3552,6 +3576,7 @@ dependencies = [
"heck 0.4.1", "heck 0.4.1",
"http", "http",
"ignore", "ignore",
"minisign-verify",
"objc", "objc",
"once_cell", "once_cell",
"open", "open",
@ -3573,12 +3598,14 @@ dependencies = [
"tauri-utils", "tauri-utils",
"tempfile", "tempfile",
"thiserror", "thiserror",
"time 0.3.20",
"tokio", "tokio",
"url", "url",
"uuid 1.3.0", "uuid 1.3.0",
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
"windows 0.39.0", "windows 0.39.0",
"zip",
] ]
[[package]] [[package]]

View File

@ -8,8 +8,21 @@ members = [
"theseus_macros" "theseus_macros"
] ]
[profile.dev]
opt-level = 0
debug = true
debug-assertions = true
overflow-checks = true
lto = false
panic = 'unwind'
incremental = true
codegen-units = 256
rpath = false
# Optimize for speed and reduce size on release builds # Optimize for speed and reduce size on release builds
[profile.release] [profile.release]
codegen-units = 1 panic = "abort" # Strip expensive panic clean-up logic
lto = true codegen-units = 1 # Compile crates one after another so the compiler can optimize better
strip = true lto = true # Enables link to optimizations
opt-level = "s" # Optimize for binary size
strip = true # Remove debug symbols

View File

@ -6,7 +6,6 @@ use crate::state::ProjectMetadata;
use crate::{ use crate::{
auth::{self, refresh}, auth::{self, refresh},
event::{emit::emit_profile, ProfilePayloadType}, event::{emit::emit_profile, ProfilePayloadType},
profile,
state::MinecraftChild, state::MinecraftChild,
}; };
pub use crate::{ pub use crate::{

View File

@ -22,3 +22,4 @@ node_modules
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
dist

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Modrinth Launcher</title> <title>Modrinth App</title>
</head> </head>
<body> <body>

View File

@ -19,7 +19,7 @@ theseus = { path = "../../theseus", features = ["tauri"] }
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["dialog", "dialog-open", "protocol-asset", "shell-open", "window-close", "window-create"] } tauri = { version = "1.2", features = ["dialog", "dialog-open", "protocol-asset", "shell-open", "updater", "window-close", "window-create"] }
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
thiserror = "1.0" thiserror = "1.0"
tokio-stream = { version = "0.1", features = ["fs"] } tokio-stream = { version = "0.1", features = ["fs"] }

View File

@ -7,8 +7,8 @@
"withGlobalTauri": false "withGlobalTauri": false
}, },
"package": { "package": {
"productName": "theseus", "productName": "Modrinth App",
"version": "0.0.0" "version": "0.0.1"
}, },
"tauri": { "tauri": {
"allowlist": { "allowlist": {
@ -33,7 +33,7 @@
}, },
"bundle": { "bundle": {
"active": true, "active": true,
"category": "DeveloperTool", "category": "Entertainment",
"copyright": "", "copyright": "",
"deb": { "deb": {
"depends": [] "depends": []
@ -68,14 +68,17 @@
"csp": "default-src 'self'; connect-src https://modrinth.com https://*.modrinth.com; font-src https://cdn-raw.modrinth.com/fonts/inter/; img-src tauri: https: data: blob: 'unsafe-inline' asset: https://asset.localhost" "csp": "default-src 'self'; connect-src https://modrinth.com https://*.modrinth.com; font-src https://cdn-raw.modrinth.com/fonts/inter/; img-src tauri: https: data: blob: 'unsafe-inline' asset: https://asset.localhost"
}, },
"updater": { "updater": {
"active": false "active": true,
"endpoints": ["https://launcher-files.modrinth.com/updates.json"],
"dialog": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwMzM5QkE0M0FCOERBMzkKUldRNTJyZzZwSnN6SUdPRGdZREtUUGxMblZqeG9OVHYxRUlRTzJBc2U3MUNJaDMvZDQ1UytZZmYK"
}, },
"windows": [ "windows": [
{ {
"fullscreen": false, "fullscreen": false,
"height": 650, "height": 650,
"resizable": true, "resizable": true,
"title": "Modrinth Launcher", "title": "Modrinth App",
"width": 1140, "width": 1140,
"minHeight": 630, "minHeight": 630,
"minWidth": 1100 "minWidth": 1100

View File

@ -13,22 +13,19 @@ pub fn debug_pin(_attr: TokenStream, item: TokenStream) -> TokenStream {
let sig = &input.sig; let sig = &input.sig;
let body = &input.block; let body = &input.block;
// Generate tokens for the common part #[cfg(debug_assertions)]
let common_tokens = quote! {
#(#attrs)*
#vis #sig
};
let result = quote! { let result = quote! {
#[cfg(debug_assertions)] #(#attrs)*
#common_tokens { #vis #sig {
Box::pin(async move { Box::pin(async move {
#body #body
}).await }).await
} }
};
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
#common_tokens { let result = quote! {
#(#attrs)*
#vis #sig {
#body #body
} }
}; };