Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches: ["master"]
workflow_dispatch:

permissions:
contents: write

jobs:
build:
runs-on: windows-latest
Expand All @@ -24,6 +27,46 @@ jobs:
$version = (Get-Content VERSION -TotalCount 1).Trim()
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding ascii

- name: Prepare release metadata
id: release_meta
if: github.event_name == 'push'
run: |
$version = "${{ steps.version.outputs.version }}"
$tag = "V$version"
$before = "${{ github.event.before }}"
$after = "${{ github.sha }}"
$files = @()
if ($before -and ($before -notmatch '^[0]+$')) {
$files = git diff --name-only $before $after
} else {
$files = git show --name-only --pretty="" $after
}
$versionChanged = $files -contains "VERSION"
$tagExists = $false
if ($versionChanged) {
git show-ref --tags --verify --quiet "refs/tags/$tag"
if ($LASTEXITCODE -eq 0) {
$tagExists = $true
}
}
"version_changed=$($versionChanged.ToString().ToLower())" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding ascii
"tag_name=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding ascii
"tag_exists=$($tagExists.ToString().ToLower())" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding ascii
$notes = ""
if ($versionChanged -and -not $tagExists) {
$prevTag = git tag --list "V*" --sort=-v:refname | Select-Object -First 1
if ([string]::IsNullOrWhiteSpace($prevTag)) {
$log = git log -n 20 --pretty=format:"- %s (%h)"
} else {
$log = git log "$prevTag..HEAD" --pretty=format:"- %s (%h)"
}
$logText = ($log | ForEach-Object { $_ }) -join "`n"
$notes = "Release $tag`n`nChanges:`n$logText"
}
"release_notes<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
$notes | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
Expand All @@ -40,6 +83,33 @@ jobs:
- name: Build release (Flutter + Backend)
run: .\build.ps1 -Action release

- name: Package release
if: steps.release_meta.outputs.version_changed == 'true' && steps.release_meta.outputs.tag_exists != 'true' && github.event_name == 'push'
run: |
$version = "${{ steps.version.outputs.version }}"
$src = "release/varManager_$version"
$zip = "release/varManager_$version.zip"
if (Test-Path $zip) { Remove-Item $zip }
Compress-Archive -Path $src -DestinationPath $zip

- name: Create tag
if: steps.release_meta.outputs.version_changed == 'true' && steps.release_meta.outputs.tag_exists != 'true' && github.event_name == 'push'
run: |
$tag = "${{ steps.release_meta.outputs.tag_name }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a $tag -m "Release $tag"
git push origin $tag

- name: Create GitHub release
if: steps.release_meta.outputs.version_changed == 'true' && steps.release_meta.outputs.tag_exists != 'true' && github.event_name == 'push'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_meta.outputs.tag_name }}
name: ${{ steps.release_meta.outputs.tag_name }}
generate_release_notes: true
files: release/varManager_${{ steps.version.outputs.version }}.zip

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ The varManager backend has built-in support for downloading var packages directl

**Configuration Tips:**
- Proxy support: configure HTTP proxy in Settings (system auto-detect or manual) for Hub downloads
- Paths: `varspath` is your VaM `AddonPackages` directory; `vampath` is your main VaM install path
- Paths: `vampath` is your main VaM install path; `varspath` defaults to the same path (only set it separately if your .var files live on another folder/drive)

**Known Issues:**
- Windows first: macOS and Linux builds are not yet available in this release
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ varManager 后端内置了从 VaM Hub 下载 var 包的支持:

**配置贴士:**
- **代理支持:** 在设置中配置 HTTP 代理(系统自动检测或手动设置),以加速 Hub 资源下载
- **路径说明:** `varspath` 为 VaM `AddonPackages` 目录;`vampath` VaM 主安装目录
- **路径说明:** `vampath` 为 VaM 主安装目录;`varspath` 默认与 `vampath` 相同(仅当 var 文件与 VaM 分开放置时单独设置)

**已知问题:**
- **Windows 优先:** 本次发布暂不包含 macOS 和 Linux 版本
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
2 changes: 1 addition & 1 deletion varManager_backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion varManager_backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "varManager_backend"
version = "2.0.1"
version = "2.0.2"
edition = "2021"

[dependencies]
Expand Down
27 changes: 21 additions & 6 deletions varManager_backend/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1892,12 +1892,27 @@ pub async fn list_packswitch(
switches.sort_by_key(|a| a.to_ascii_lowercase());

let addon_path = crate::infra::paths::addon_packages_dir(&vampath);
let current = if let Ok(target) = crate::infra::winfs::read_link_target(&addon_path) {
target
.file_name()
.and_then(|s| s.to_str())
.unwrap_or("default")
.to_string()
let link_root = addon_path.join(crate::infra::paths::INSTALL_LINK_DIR);
let current = if let Ok(target) = crate::infra::winfs::read_link_target(&link_root) {
let resolved = if target.is_absolute() {
target
} else {
link_root
.parent()
.unwrap_or(&addon_path)
.join(target)
};
let switch_root = crate::infra::paths::addon_switch_root(&vampath);
if resolved.starts_with(&switch_root) {
resolved
.parent()
.and_then(|p| p.file_name())
.and_then(|s| s.to_str())
.unwrap_or("default")
.to_string()
} else {
"default".to_string()
}
} else {
"default".to_string()
};
Expand Down
21 changes: 20 additions & 1 deletion varManager_backend/src/infra/fs_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ pub fn collect_symlink_vars(root: &Path, recursive: bool) -> Vec<PathBuf> {
if !root.exists() {
return Vec::new();
}
let scan_root = resolve_symlink_root(root);
if !scan_root.exists() {
return Vec::new();
}
let mut files = Vec::new();
let walker = WalkDir::new(root)
let walker = WalkDir::new(&scan_root)
.follow_links(false)
.max_depth(if recursive { usize::MAX } else { 1 })
.into_iter();
Expand All @@ -35,6 +39,21 @@ pub fn collect_symlink_vars(root: &Path, recursive: bool) -> Vec<PathBuf> {
files
}

fn resolve_symlink_root(root: &Path) -> PathBuf {
if !is_symlink(root) {
return root.to_path_buf();
}
if let Ok(target) = fs::read_link(root) {
if target.is_absolute() {
return target;
}
if let Some(parent) = root.parent() {
return parent.join(target);
}
}
root.to_path_buf()
}

pub fn collect_installed_links(vampath: &Path) -> HashMap<String, PathBuf> {
let mut installed = HashMap::new();
let install_dir = vampath.join("AddonPackages").join(INSTALL_LINK_DIR);
Expand Down
Loading