Add Tauri auto-updates

Closes #365

Still unfinished, I need to learn where are the build signatures stored.
This commit is contained in:
Bruno Bernardino 2021-12-31 12:45:52 +00:00
parent e7b048f73f
commit 680ed9b79d
No known key found for this signature in database
GPG Key ID: D1B0A69ADD114ECE
9 changed files with 118 additions and 8 deletions

View File

@ -5,6 +5,7 @@ on:
inputs:
environment:
type: environment
default: "Local"
targets:
type: choice
description: "Targets to build"

View File

@ -5,6 +5,7 @@ on:
inputs:
environment:
type: environment
default: "Local"
targets:
type: choice
description: "Targets to build"

View File

@ -5,6 +5,7 @@ on:
inputs:
environment:
type: environment
default: "Local"
push:
branches:

View File

@ -5,6 +5,7 @@ on:
inputs:
environment:
type: environment
default: "Local"
push:
branches:

58
.github/workflows/release-tauri.yml vendored Normal file
View File

@ -0,0 +1,58 @@
name: Release Tauri
on:
workflow_dispatch:
inputs:
environment:
type: environment
default: "Beta"
jobs:
release:
environment: ${{ github.event.inputs.environment || 'Beta' }}
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version-file: ".nvmrc"
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install tauri bundler
run: cargo install tauri-bundler --force
- name: Install webkit2gtk (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0
- name: Install dependencies
run: |
npm i -g npm@8.2.0
npm ci
- uses: tauri-apps/tauri-action@v0.2.0
env:
PL_SERVER_URL: ${{ secrets.PL_SERVER_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
tagName: tauri-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: "Padloc (Tauri Edition) v__VERSION__"
releaseBody: "WARNING: The builds in this release are experimental. Use at your own risk!"
releaseDraft: true
prerelease: true
projectPath: packages/tauri
- name: Build tauri-update.json
run: cd packages/tauri && node generate-tauri-update-file.js
- name: Add tauri-update.json
uses: softprops/action-gh-release@v1
with:
files: packages/tauri/tauri-update.json

View File

@ -0,0 +1,45 @@
const { resolve } = require("path");
const { readFileSync, writeFileSync } = require("fs");
const tauriUpdateFilePath = resolve(__dirname, "tauri-update.json");
const packageFilePath = resolve(__dirname, "package.json");
const tauriUpdate = {
name: "v[VERSION]",
pub_date: "[DATE]",
platforms: {
darwin: {
signature: "[MACOS_SIGNATURE]",
url: "https://github.com/padloc/padloc/releases/download/v[VERSION]/Padloc.app.tar.gz",
},
linux: {
signature: "[LINUX_SIGNATURE]",
url: "https://github.com/padloc/padloc/releases/download/v[VERSION]/Padloc.AppImage.tar.gz",
},
win64: {
signature: "[WINDOWS_SIGNATURE]",
url: "https://github.com/padloc/padloc/releases/download/v[VERSION]/Padloc.x64.msi.zip",
},
},
};
const packageFileContents = readFileSync(packageFilePath, "utf-8");
const package = JSON.parse(packageFileContents);
const { version } = package;
const now = new Date().toISOString();
// TODO: Will know where these are set once we sign a release
const darwinSignature = "";
const linuxSignature = "";
const windowsSignature = "";
tauriUpdate.name = `v${version}`;
tauriUpdate.pub_date = now;
tauriUpdate.platforms.darwin.signature = darwinSignature;
tauriUpdate.platforms.darwin.url = `https://github.com/padloc/padloc/releases/download/v${version}/Padloc.app.tar.gz`;
tauriUpdate.platforms.linux.signature = linuxSignature;
tauriUpdate.platforms.linux.url = `https://github.com/padloc/padloc/releases/download/v${version}/Padloc.AppImage.tar.gz`;
tauriUpdate.platforms.win64.signature = windowsSignature;
tauriUpdate.platforms.win64.url = `https://github.com/padloc/padloc/releases/download/v${version}/Padloc.x64.msi.zip`;
writeFileSync(tauriUpdateFilePath, JSON.stringify(tauriUpdate, null, 4), "utf-8");

View File

@ -1,7 +1,7 @@
{
"name": "@padloc/tauri",
"version": "4.0.0",
"description": "Tauri Wrapper for packaging native apps",
"description": "Tauri Wrapper for Padloc",
"main": "index.js",
"scripts": {
"tauri": "tauri",
@ -11,8 +11,8 @@
"update": "tauri deps update",
"setup-tauri": "cd src-tauri && cargo build"
},
"author": "",
"license": "ISC",
"author": "Martin Kleinschrodt <martin@maklesoft.com>",
"license": "GPL-3.0",
"devDependencies": {
"clean-webpack-plugin": "3.0.0",
"css-loader": "5.2.6",

View File

@ -1,12 +1,12 @@
[package]
name = "Padloc"
version = "0.1.0"
version = "4.0.0"
description = "Padloc"
authors = [ "you" ]
license = ""
authors = [ "Martin Kleinschrodt <martin@maklesoft.com>" ]
license = "GPL-3.0"
repository = "https://github.com/padloc/padloc"
default-run = "Padloc"
edition = "2018"
edition = "2021"
build = "src/build.rs"
[build-dependencies]

View File

@ -57,7 +57,10 @@
]
},
"updater": {
"active": false
"active": true,
"endpoints": ["https://github.com/padloc/padloc/releases/download/latest/tauri-update.json"],
"dialog": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDM5NDMxQ0I3MTA3NDU3RjIKUldUeVYzUVF0eHhET1ZpNUZDYWY3Zlk1aUN1ZkpXcU5wS0pSTERSay91ODBpWlBIcTViNk11RHgK"
},
"allowlist": {
"all": true