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:
working-directory: ./theseus_cli
steps:
- uses: actions/checkout@v2
- name: install dependencies (ubuntu only)
- name: Checkout
uses: actions/checkout@v3
- name: install dependencies
run: |
sudo apt-get update
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
- name: Rust setup
uses: dtolnay/rust-toolchain@stable
with:
path: ../target/**
key: ${{ runner.os }}-theseus
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
- uses: actions-rs/cargo@v1
name: Build program
with:
command: build
args: --bin theseus_cli
- name: Run Lint
uses: actions-rs/clippy-check@v1
with:

View File

@ -13,22 +13,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
- name: Sync node version and setup cache
uses: actions/setup-node@v3
with:
node-version: 18.x
- 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-
node-version: 16
cache: 'yarn'
cache-dependency-path: "theseus_gui"
- name: Install dependencies
run: yarn install --immutable --immutable-cache --check-cache
- name: Run Lint
run: yarn run lint
- name: Build
run: yarn run build
run: yarn run build

View File

@ -14,46 +14,80 @@ jobs:
defaults:
run:
working-directory: ./theseus_gui
steps:
- 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
with:
node-version: 16
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
cache: 'yarn'
cache-dependency-path: "theseus_gui"
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-20.04'
if: startsWith(matrix.platform, 'ubuntu')
run: |
sudo apt-get update
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
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:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run Lint
if: matrix.platform == 'ubuntu-20.04'
uses: actions-rs/clippy-check@v1
ENABLE_CODE_SIGNING: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
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:
token: ${{ secrets.GITHUB_TOKEN }}
args: --bin theseus_cli
args: --target universal-apple-darwin
- 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",
]
[[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]]
name = "autocfg"
version = "1.1.0"
@ -2048,6 +2064,12 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "minisign-verify"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "933dca44d65cdd53b355d0b73d380a2ff5da71f87f036053188bf1eab6a19881"
[[package]]
name = "miniz_oxide"
version = "0.6.2"
@ -3540,6 +3562,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe7e0f1d535e7cbbbab43c82be4fc992b84f9156c16c160955617e0260ebc449"
dependencies = [
"anyhow",
"attohttpc",
"base64 0.13.1",
"cocoa",
"dirs-next",
"embed_plist",
@ -3552,6 +3576,7 @@ dependencies = [
"heck 0.4.1",
"http",
"ignore",
"minisign-verify",
"objc",
"once_cell",
"open",
@ -3573,12 +3598,14 @@ dependencies = [
"tauri-utils",
"tempfile",
"thiserror",
"time 0.3.20",
"tokio",
"url",
"uuid 1.3.0",
"webkit2gtk",
"webview2-com",
"windows 0.39.0",
"zip",
]
[[package]]

View File

@ -8,8 +8,21 @@ members = [
"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
[profile.release]
codegen-units = 1
lto = true
strip = true
panic = "abort" # Strip expensive panic clean-up logic
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
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::{
auth::{self, refresh},
event::{emit::emit_profile, ProfilePayloadType},
profile,
state::MinecraftChild,
};
pub use crate::{

View File

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

View File

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

View File

@ -19,7 +19,7 @@ theseus = { path = "../../theseus", features = ["tauri"] }
serde_json = "1.0"
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"] }
thiserror = "1.0"
tokio-stream = { version = "0.1", features = ["fs"] }

View File

@ -7,8 +7,8 @@
"withGlobalTauri": false
},
"package": {
"productName": "theseus",
"version": "0.0.0"
"productName": "Modrinth App",
"version": "0.0.1"
},
"tauri": {
"allowlist": {
@ -33,7 +33,7 @@
},
"bundle": {
"active": true,
"category": "DeveloperTool",
"category": "Entertainment",
"copyright": "",
"deb": {
"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"
},
"updater": {
"active": false
"active": true,
"endpoints": ["https://launcher-files.modrinth.com/updates.json"],
"dialog": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwMzM5QkE0M0FCOERBMzkKUldRNTJyZzZwSnN6SUdPRGdZREtUUGxMblZqeG9OVHYxRUlRTzJBc2U3MUNJaDMvZDQ1UytZZmYK"
},
"windows": [
{
"fullscreen": false,
"height": 650,
"resizable": true,
"title": "Modrinth Launcher",
"title": "Modrinth App",
"width": 1140,
"minHeight": 630,
"minWidth": 1100

View File

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