mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-14 21:31:30 +08:00
fix: tauri npm scripts (#955)
This commit is contained in:
@@ -16,24 +16,66 @@ on:
|
|||||||
- 'README.md'
|
- 'README.md'
|
||||||
- '.vscode'
|
- '.vscode'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: write
|
||||||
|
contents: write
|
||||||
|
security-events: write
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: release-ci-group
|
group: release-ci-group
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
MacOS:
|
create-release:
|
||||||
runs-on: macos-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Query version number
|
||||||
|
id: get_version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "using version tag ${GITHUB_REF:10}"
|
||||||
|
echo "version=${GITHUB_REF:10}" >> $GITHUB_ENV
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
draft: true
|
||||||
|
tag_name: '${{ env.version }}'
|
||||||
|
release_name: 'AFFiNE ${{ env.version }}'
|
||||||
|
body: 'See the assets to download this version and install.'
|
||||||
|
|
||||||
|
build-tauri:
|
||||||
|
needs: create-release
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform: [macos-latest, ubuntu-latest, windows-latest]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: 'true'
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: install dependencies (ubuntu only)
|
||||||
|
if: matrix.platform == 'ubuntu-latest'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 18.x
|
||||||
|
- name: install Rust stable
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v2
|
uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
@@ -55,7 +97,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm i -r
|
run: pnpm i -r
|
||||||
|
|
||||||
- name: Make macOS (x64)
|
- name: Make App Binary
|
||||||
run: pnpm build:app
|
run: pnpm build:app
|
||||||
working-directory: apps/desktop
|
working-directory: apps/desktop
|
||||||
env:
|
env:
|
||||||
@@ -63,12 +105,8 @@ jobs:
|
|||||||
CI_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
|
CI_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Create Release
|
- uses: tauri-apps/tauri-action@v0
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
with:
|
|
||||||
draft: true
|
|
||||||
generate_release_notes: true
|
|
||||||
files: apps/desktop/src-tauri/target/release/bundle/dmg/*.dmg
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<link rel="stylesheet" href="/src/style.css" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>AFFiNE</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="react-root" />
|
|
||||||
<script type="module" src="/src/main.tsx"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -6,9 +6,8 @@
|
|||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"module": "true",
|
"module": "true",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:app": "pnpm build:preload && cross-env NODE_ENV=development tauri dev",
|
"dev:app": "cross-env NODE_ENV=development tauri dev",
|
||||||
"dev:prerequisite": "concurrently \"cd ../packages/data-center && pnpm dev\" \"cd ../apps/web && pnpm dev\"",
|
"dev:prerequisite": "cd ../../ && pnpm build && concurrently \"cd packages/data-center && pnpm dev\" \"cd apps/web && pnpm dev\"",
|
||||||
"build:prerequisite": "pnpm build:submodules && pnpm build:rs-types && pnpm build:affine && pnpm build:preload",
|
|
||||||
"build:rs-types": "zx scripts/generateTsTypingsFromJsonSchema.mjs",
|
"build:rs-types": "zx scripts/generateTsTypingsFromJsonSchema.mjs",
|
||||||
"build:submodules": "zx scripts/buildSubModules.mjs",
|
"build:submodules": "zx scripts/buildSubModules.mjs",
|
||||||
"build:affine": "zx scripts/buildAffine.mjs",
|
"build:affine": "zx scripts/buildAffine.mjs",
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ const publicAffineOutDirectory = path.join(
|
|||||||
'affine-out'
|
'affine-out'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (process.platform === 'win32') $.shell = 'pwsh';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build affine dist html
|
* Build affine dist html
|
||||||
*/
|
*/
|
||||||
@@ -21,7 +23,7 @@ cd(repoDirectory);
|
|||||||
await $`pnpm i -r`;
|
await $`pnpm i -r`;
|
||||||
await $`pnpm build`;
|
await $`pnpm build`;
|
||||||
cd(affineSrcDirectory);
|
cd(affineSrcDirectory);
|
||||||
$.env.BASE_PATH = '/affine-out';
|
$.env.NEXT_BASE_PATH = '/affine-out';
|
||||||
await $`pnpm build`;
|
await $`pnpm build`;
|
||||||
await $`pnpm export`;
|
await $`pnpm export`;
|
||||||
await fs.remove(publicAffineOutDirectory);
|
await fs.remove(publicAffineOutDirectory);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ mod state;
|
|||||||
use dotenvy::dotenv;
|
use dotenvy::dotenv;
|
||||||
use state::AppState;
|
use state::AppState;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
use tauri::TitleBarStyle;
|
use tauri::TitleBarStyle;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
@@ -17,7 +18,9 @@ async fn main() {
|
|||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
let preload = include_str!("../../public/preload/index.js");
|
let preload = include_str!("../../public/preload/index.js");
|
||||||
let is_dev = env::var("NODE_ENV").unwrap_or_default() == "development";
|
let is_dev = env::var("NODE_ENV").unwrap_or_default() == "development";
|
||||||
|
// this only work in production mode, in dev mode, we load `devPath` in tauri.conf.json
|
||||||
let initial_path = if is_dev {
|
let initial_path = if is_dev {
|
||||||
|
// just a place holder here
|
||||||
"index.html"
|
"index.html"
|
||||||
} else {
|
} else {
|
||||||
"affine-out/index.html"
|
"affine-out/index.html"
|
||||||
@@ -32,10 +35,13 @@ async fn main() {
|
|||||||
tauri::WindowBuilder::new(app, "label", tauri::WindowUrl::App(initial_path.into()))
|
tauri::WindowBuilder::new(app, "label", tauri::WindowUrl::App(initial_path.into()))
|
||||||
.title("AFFiNE")
|
.title("AFFiNE")
|
||||||
.inner_size(1000.0, 800.0)
|
.inner_size(1000.0, 800.0)
|
||||||
.title_bar_style(TitleBarStyle::Overlay)
|
.initialization_script(&preload);
|
||||||
.hidden_title(true)
|
// fix `title_bar_style` found for struct `WindowBuilder` in the current scope
|
||||||
.initialization_script(&preload)
|
#[cfg(target_os = "macos")]
|
||||||
.build()?;
|
let _window = _window
|
||||||
|
.hidden_title(true)
|
||||||
|
.title_bar_style(TitleBarStyle::Overlay);
|
||||||
|
let _window = _window.build()?;
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
_window.open_devtools();
|
_window.open_devtools();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm dev:prerequisite",
|
"beforeDevCommand": "pnpm build:preload && pnpm dev:prerequisite",
|
||||||
"beforeBuildCommand": "pnpm build:preload && pnpm build:affine",
|
"beforeBuildCommand": "pnpm build:preload && pnpm build:affine",
|
||||||
"devPath": "http://localhost:8080",
|
"devPath": "http://localhost:8080",
|
||||||
"distDir": "../public",
|
"distDir": "../public",
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const nextConfig = {
|
|||||||
printer.info(`API request proxy to [${desc} Server]: ` + target);
|
printer.info(`API request proxy to [${desc} Server]: ` + target);
|
||||||
return profile;
|
return profile;
|
||||||
},
|
},
|
||||||
basePath: process.env.BASE_PATH,
|
basePath: process.env.NEXT_BASE_PATH,
|
||||||
experimental: {
|
experimental: {
|
||||||
forceSwcTransforms: true,
|
forceSwcTransforms: true,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user