Skip to content

Commit

Permalink
Merge pull request #186 from greenhat616/fix-build
Browse files Browse the repository at this point in the history
fix: dev build and updater
  • Loading branch information
keiko233 authored Dec 23, 2023
2 parents e0b7520 + 27920de commit ef85b8f
Show file tree
Hide file tree
Showing 15 changed files with 469 additions and 137 deletions.
68 changes: 47 additions & 21 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,19 @@ jobs:
release:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}
targets:
- os: windows-latest
category: nsis # and portable
- os: windows-latest
category: msi
- os: ubuntu-latest
category: all
- os: macos-13
category: amd64
- os: macos-13
category: aarch64

runs-on: ${{ matrix.targets.os }}
if: startsWith(github.repository, 'keiko233')
steps:
- name: Checkout repository
Expand All @@ -32,10 +42,10 @@ jobs:
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
key: ${{ matrix.os }}
key: ${{ matrix.targets.os }}

- name: Install the missing rust target (macOS Only)
if: startsWith(matrix.os, 'macos-')
if: startsWith(matrix.targets.os, 'macos-')
run: |
rustup target add aarch64-apple-darwin
Expand All @@ -51,7 +61,7 @@ jobs:
run_install: false

- name: Delete current release assets
if: startsWith(matrix.os, 'ubuntu-')
if: startsWith(matrix.targets.os, 'ubuntu-')
uses: mknejp/delete-release-assets@v1
with:
token: ${{ secrets.GH_TOKEN }}
Expand All @@ -70,17 +80,32 @@ jobs:
*.json
- name: Install Dependencies (Ubuntu Only)
if: startsWith(matrix.os, 'ubuntu-')
if: startsWith(matrix.targets.os, 'ubuntu-')
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf openssl
- uses: maxim-lobanov/setup-xcode@v1
if: startsWith(matrix.targets.os, 'macos-')
with:
xcode-version: "15.0"
- name: Pnpm install and check
run: |
pnpm i
pnpm check && pnpm prepare:nightly
pnpm check
- name: Nightly Prepare
if: startsWith(matrix.targets.os, 'windows-') == false
run: |
pnpm prepare:nightly
- name: Nightly Prepare (MSI only)
if: startsWith(matrix.targets.os, 'windows-') && matrix.targets.category == 'msi'
run: |
pnpm prepare:nightly --msi
- name: Nightly Prepare (Windows NSIS and Portable)
if: startsWith(matrix.targets.os, 'windows-') && matrix.targets.category == 'nsis'
run: |
pnpm prepare:nightly --nsis
- name: Tauri build
if: startsWith(matrix.targets.os, 'macos-') == false || matrix.targets.category != 'aarch64'
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Expand All @@ -92,11 +117,10 @@ jobs:
releaseBody: "More new features are now supported."
releaseDraft: false
prerelease: true
tauriScript: pnpm
tauriScript: pnpm tauri
args: -f default-meta nightly -c ./backend/tauri/tauri.nightly.conf.json

- name: Portable Bundle (Windows Only)
if: matrix.os == 'windows-latest'
if: startsWith(matrix.targets.os, 'windows-') && matrix.targets.category == 'nsis'
run: |
pnpm portable
env:
Expand All @@ -107,12 +131,12 @@ jobs:
VITE_WIN_PORTABLE: 1

- name: Pnpm check (macOS aarch64)
if: startsWith(matrix.os, 'macos-')
if: startsWith(matrix.targets.os, 'macos-') && matrix.targets.category == 'aarch64'
run: |
pnpm check --arch arm64 --sidecar-host aarch64-apple-darwin
- name: Tauri build with Upload (macOS aarch64)
if: startsWith(matrix.os, 'macos-')
if: startsWith(matrix.targets.os, 'macos-') && matrix.targets.category == 'aarch64'
env:
TAG_NAME: pre-release
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Expand Down Expand Up @@ -146,20 +170,22 @@ jobs:
cat > release.txt << 'EOF'
## Clash Nyanpasu Nightly Build
Release created at ${{ env.BUILDTIME }}.
Daily build of Clash Nyanpasu Dev branch.
[See the development log here](https://t.me/keikolog/462)
Daily build of **Clash Nyanpasu** on *dev* branch.
***[See the development log here](https://t.me/keikolog/462)***
EOF
- name: Update Release
uses: ncipollo/release-action@v1
uses: softprops/action-gh-release@v1
with:
name: Clash Nyanpasu Dev
tag: pre-release
bodyFile: release.txt
tag_name: pre-release
body_path: release.txt
prerelease: true
generate_release_notes: true
target_commitish: dev
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
updater:
name: Update Nigthly Updater
name: Update Nightly Updater
runs-on: ubuntu-latest
needs: [release, update_tag]
if: startsWith(github.repository, 'keiko233')
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
release:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
os: [windows-latest, ubuntu-latest, macos-13]

runs-on: ${{ matrix.os }}
if: startsWith(github.repository, 'keiko233')
Expand Down Expand Up @@ -52,7 +52,10 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf openssl
- uses: maxim-lobanov/setup-xcode@v1
if: startsWith(matrix.os, 'macos-')
with:
xcode-version: "15.0"
- name: Pnpm install and check
run: |
pnpm i
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ scripts/_env.sh

.eslintcache
.stylelintcache

tauri.nightly.conf.json

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist/
**/node_modules/
pnpm-lock.yaml
*.lock
*.wxs
2 changes: 2 additions & 0 deletions backend/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ build = "build.rs"

[build-dependencies]
tauri-build = { version = "1", features = [] }
serde = "1"
simd-json = "0.13"

[dependencies]
warp = "0.3"
Expand Down
10 changes: 10 additions & 0 deletions backend/tauri/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
use serde::Deserialize;
use std::fs::read;
#[derive(Deserialize)]
struct PackageJson {
version: String, // we only need the version
}

fn main() {
let mut pkg_json = read("../../package.json").unwrap();
let pkg_json: PackageJson = simd_json::from_slice(&mut pkg_json).unwrap();
println!("cargo:rustc-env=NYANPASU_VERSION={}", pkg_json.version);
tauri_build::build()
}
15 changes: 15 additions & 0 deletions backend/tauri/overrides/nightly.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/1.x/tooling/cli/schema.json",
"package": {
"version": "1.4.2"
},
"tauri": {
"updater": {
"endpoints": [
"https://mirror.ghproxy.com/https://github.com/keiko233/clash-nyanpasu/releases/download/updater/update-nightly-proxy.json",
"https://ghproxy.com/https://github.com/keiko233/clash-nyanpasu/releases/download/updater/update-nightly-proxy.json",
"https://github.com/keiko233/clash-nyanpasu/releases/download/updater/update-nightly.json"
]
}
}
}
2 changes: 1 addition & 1 deletion backend/tauri/src/config/prfitem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl PrfItem {
}

let version = unsafe { dirs::APP_VERSION };
let version = format!("clash-verge/{version}");
let version = format!("clash-verge/v{version}");
builder = builder.user_agent(user_agent.unwrap_or(version));

let resp = builder.build()?.get(url).send().await?;
Expand Down
2 changes: 1 addition & 1 deletion backend/tauri/src/core/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Tray {
pub fn tray_menu(app_handle: &AppHandle) -> SystemTrayMenu {
let zh = { Config::verge().latest().language == Some("zh".into()) };

let version = app_handle.package_info().version.to_string();
let version = env!("NYANPASU_VERSION");

macro_rules! t {
($en: expr, $zh: expr) => {
Expand Down
6 changes: 1 addition & 5 deletions backend/tauri/src/utils/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static mut RESOURCE_DIR: Option<PathBuf> = None;
#[allow(unused)]
static mut PORTABLE_FLAG: bool = false;

pub static mut APP_VERSION: &str = "v1.2.0";
pub static mut APP_VERSION: &str = env!("NYANPASU_VERSION");

/// initialize portable flag
#[cfg(target_os = "windows")]
Expand Down Expand Up @@ -77,10 +77,6 @@ pub fn app_resources_dir(package_info: &PackageInfo) -> Result<PathBuf> {

unsafe {
RESOURCE_DIR = Some(res_dir.clone());

let ver = package_info.version.to_string();
let ver_str = format!("v{ver}");
APP_VERSION = Box::leak(Box::new(ver_str));
}

Ok(res_dir)
Expand Down
93 changes: 0 additions & 93 deletions backend/tauri/tauri.nightly.conf.json

This file was deleted.

Loading

0 comments on commit ef85b8f

Please sign in to comment.