mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
refactor: use Electron instead of Tauri
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
name: Electron CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
paths:
|
||||
- "apps/desktop/**"
|
||||
- "apps/web/**"
|
||||
- "packages/**"
|
||||
- "pnpm-lock.yaml"
|
||||
- ".github/workflows/electron-ci.yml"
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
paths:
|
||||
- "apps/desktop/**"
|
||||
- "apps/web/**"
|
||||
- "packages/**"
|
||||
- "pnpm-lock.yaml"
|
||||
- ".github/workflows/electron-ci.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build (${{ matrix.platform }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- platform: macos-latest
|
||||
- platform: ubuntu-22.04
|
||||
- platform: windows-latest
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
timeout-minutes: 45
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: lts/*
|
||||
cache: pnpm
|
||||
|
||||
- name: Install JS dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Typecheck desktop
|
||||
run: pnpm --filter @memohai/desktop typecheck
|
||||
|
||||
- name: Build desktop (unpacked smoke)
|
||||
env:
|
||||
CSC_IDENTITY_AUTO_DISCOVERY: "false"
|
||||
run: pnpm --filter @memohai/desktop build:dir
|
||||
@@ -129,7 +129,7 @@ jobs:
|
||||
gh release upload "$TAG_NAME" "${files[@]}" --clobber --repo "$GH_REPO"
|
||||
|
||||
desktop-build:
|
||||
name: Build desktop ${{ matrix.target }}
|
||||
name: Build desktop (${{ matrix.platform }})
|
||||
runs-on: ${{ matrix.platform }}
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
@@ -137,19 +137,17 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- platform: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
- platform: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
build_cmd: build:mac
|
||||
- platform: ubuntu-22.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
build_cmd: build:linux
|
||||
- platform: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
build_cmd: build:win
|
||||
env:
|
||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Sync desktop version files
|
||||
- name: Sync desktop version
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -159,21 +157,9 @@ jobs:
|
||||
const fs = require('fs');
|
||||
const version = process.env.VERSION;
|
||||
const packageJsonPath = 'apps/desktop/package.json';
|
||||
const tauriConfPath = 'apps/desktop/src-tauri/tauri.conf.json';
|
||||
const cargoTomlPath = 'apps/desktop/src-tauri/Cargo.toml';
|
||||
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
packageJson.version = version;
|
||||
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
|
||||
|
||||
const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8'));
|
||||
tauriConf.version = version;
|
||||
fs.writeFileSync(tauriConfPath, `${JSON.stringify(tauriConf, null, 2)}\n`);
|
||||
|
||||
const cargoToml = fs
|
||||
.readFileSync(cargoTomlPath, 'utf8')
|
||||
.replace(/^version = ".*"$/m, `version = "${version}"`);
|
||||
fs.writeFileSync(cargoTomlPath, cargoToml);
|
||||
EOF
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
@@ -182,31 +168,15 @@ jobs:
|
||||
with:
|
||||
node-version: lts/*
|
||||
cache: pnpm
|
||||
- name: Install Rust stable
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
- name: Rust cache
|
||||
uses: swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: apps/desktop/src-tauri -> target
|
||||
- name: Install Linux dependencies
|
||||
if: matrix.platform == 'ubuntu-22.04'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libwebkit2gtk-4.1-dev \
|
||||
libappindicator3-dev \
|
||||
librsvg2-dev \
|
||||
patchelf
|
||||
- name: Install JS dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Prepare macOS code signing
|
||||
id: mac-signing
|
||||
if: ${{ matrix.platform == 'macos-latest' && env.APPLE_CERTIFICATE != '' && env.APPLE_CERTIFICATE_PASSWORD != '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
KEYCHAIN_PASSWORD="github-actions-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-1}"
|
||||
CSC_PATH="$RUNNER_TEMP/certificate.p12"
|
||||
python3 - <<'EOF'
|
||||
import base64
|
||||
import os
|
||||
@@ -215,46 +185,29 @@ jobs:
|
||||
target = Path(os.environ["RUNNER_TEMP"]) / "certificate.p12"
|
||||
target.write_bytes(base64.b64decode(os.environ["APPLE_CERTIFICATE"]))
|
||||
EOF
|
||||
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
|
||||
security default-keychain -s build.keychain
|
||||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
|
||||
security set-keychain-settings -t 3600 -u build.keychain
|
||||
security import "$RUNNER_TEMP/certificate.p12" -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
|
||||
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
|
||||
curl -fsSL -o "$RUNNER_TEMP/DeveloperIDG2CA.cer" https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer
|
||||
security add-certificates -k build.keychain "$RUNNER_TEMP/DeveloperIDG2CA.cer"
|
||||
security find-identity -v -p codesigning build.keychain
|
||||
IDENTITY=$(security find-identity -v -p codesigning build.keychain | awk -F'"' '/Developer ID Application/ { print $2; exit }')
|
||||
if [[ -z "$IDENTITY" ]]; then
|
||||
echo "No Developer ID Application identity in build keychain"
|
||||
exit 1
|
||||
fi
|
||||
echo "APPLE_SIGNING_IDENTITY=$IDENTITY" >> "$GITHUB_ENV"
|
||||
echo "CSC_LINK=$CSC_PATH" >> "$GITHUB_ENV"
|
||||
echo "CSC_KEY_PASSWORD=$APPLE_CERTIFICATE_PASSWORD" >> "$GITHUB_ENV"
|
||||
echo "has_cert=true" >> "$GITHUB_OUTPUT"
|
||||
- name: Build desktop bundles
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ARGS=(build --target "${{ matrix.target }}")
|
||||
if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
|
||||
VERSION="${RELEASE_TAG#v}"
|
||||
NUMERIC_VERSION="${VERSION%%-*}"
|
||||
NUMERIC_VERSION="${NUMERIC_VERSION%%+*}"
|
||||
ARGS+=(--config "{\"bundle\":{\"windows\":{\"wix\":{\"version\":\"${NUMERIC_VERSION}\"}}}}")
|
||||
fi
|
||||
pnpm --filter @memohai/desktop tauri "${ARGS[@]}"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CSC_IDENTITY_AUTO_DISCOVERY: ${{ steps.mac-signing.outputs.has_cert == 'true' && 'true' || 'false' }}
|
||||
run: pnpm --filter @memohai/desktop ${{ matrix.build_cmd }}
|
||||
- name: Upload desktop artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: desktop-${{ matrix.target }}
|
||||
name: desktop-${{ matrix.platform }}
|
||||
path: |
|
||||
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.AppImage
|
||||
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.app.tar.gz
|
||||
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.deb
|
||||
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.dmg
|
||||
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.exe
|
||||
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.msi
|
||||
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.rpm
|
||||
apps/desktop/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.sig
|
||||
apps/desktop/dist/**/*.AppImage
|
||||
apps/desktop/dist/**/*.deb
|
||||
apps/desktop/dist/**/*.rpm
|
||||
apps/desktop/dist/**/*.dmg
|
||||
apps/desktop/dist/**/*.zip
|
||||
apps/desktop/dist/**/*.exe
|
||||
apps/desktop/dist/**/*.msi
|
||||
apps/desktop/dist/**/*.blockmap
|
||||
apps/desktop/dist/**/latest*.yml
|
||||
if-no-files-found: error
|
||||
|
||||
desktop-upload:
|
||||
@@ -280,13 +233,14 @@ jobs:
|
||||
shopt -s nullglob globstar
|
||||
files=(
|
||||
release-artifacts/desktop/**/*.AppImage
|
||||
release-artifacts/desktop/**/*.app.tar.gz
|
||||
release-artifacts/desktop/**/*.deb
|
||||
release-artifacts/desktop/**/*.rpm
|
||||
release-artifacts/desktop/**/*.dmg
|
||||
release-artifacts/desktop/**/*.zip
|
||||
release-artifacts/desktop/**/*.exe
|
||||
release-artifacts/desktop/**/*.msi
|
||||
release-artifacts/desktop/**/*.rpm
|
||||
release-artifacts/desktop/**/*.sig
|
||||
release-artifacts/desktop/**/*.blockmap
|
||||
release-artifacts/desktop/**/latest*.yml
|
||||
)
|
||||
if [[ ${#files[@]} -eq 0 ]]; then
|
||||
echo "No desktop artifacts found" >&2
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
name: Tauri CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
paths:
|
||||
- "apps/desktop/**"
|
||||
- "apps/web/**"
|
||||
- "packages/**"
|
||||
- "pnpm-lock.yaml"
|
||||
- ".github/workflows/tauri-ci.yml"
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
paths:
|
||||
- "apps/desktop/**"
|
||||
- "apps/web/**"
|
||||
- "packages/**"
|
||||
- "pnpm-lock.yaml"
|
||||
- ".github/workflows/tauri-ci.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build (${{ matrix.platform }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- platform: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
- platform: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
- platform: ubuntu-22.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
- platform: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: lts/*
|
||||
cache: pnpm
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Rust cache
|
||||
uses: swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: apps/desktop/src-tauri -> target
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: matrix.platform == 'ubuntu-22.04'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libwebkit2gtk-4.1-dev \
|
||||
libappindicator3-dev \
|
||||
librsvg2-dev \
|
||||
patchelf
|
||||
|
||||
- name: Install JS dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build Tauri app
|
||||
uses: tauri-apps/tauri-action@v0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
projectPath: apps/desktop
|
||||
args: --target ${{ matrix.target }}
|
||||
tauriScript: pnpm tauri
|
||||
Reference in New Issue
Block a user