From 1dcfe661e9ca6c15ca32274592cc14188ca30efd Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Mon, 30 Dec 2024 18:16:07 +0800
Subject: [PATCH] Modify the build script
When NotStoreConfigHere.txt file exists, the configs not stored in the current folder
---
.github/workflows/build-linux.yml | 2 ++
.github/workflows/build-osx.yml | 18 ++++++++++++++++++
.github/workflows/build-windows.yml | 4 ++++
package-debian.sh | 2 ++
package-osx.sh | 8 ++------
v2rayN/ServiceLib/Common/Utils.cs | 8 +++++++-
6 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml
index d0383ebe..88b89d2a 100644
--- a/.github/workflows/build-linux.yml
+++ b/.github/workflows/build-linux.yml
@@ -33,6 +33,8 @@ jobs:
cd v2rayN
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-x64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o $OutputPath64
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-arm64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o $OutputPathArm64
+ dotnet publish ./AmazTool/AmazTool.csproj -c Release -r linux-x64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:PublishTrimmed=true -o $OutputPath64
+ dotnet publish ./AmazTool/AmazTool.csproj -c Release -r linux-arm64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:PublishTrimmed=true -o $OutputPathArm64
- name: Upload build artifacts
uses: actions/upload-artifact@v4
diff --git a/.github/workflows/build-osx.yml b/.github/workflows/build-osx.yml
index f2635519..369faabe 100644
--- a/.github/workflows/build-osx.yml
+++ b/.github/workflows/build-osx.yml
@@ -33,6 +33,8 @@ jobs:
cd v2rayN
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-x64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o $OutputPath64
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-arm64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -o $OutputPathArm64
+ dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-x64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:PublishTrimmed=true -o $OutputPath64
+ dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-arm64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:PublishTrimmed=true -o $OutputPathArm64
- name: Upload build artifacts
uses: actions/upload-artifact@v4
@@ -56,4 +58,20 @@ jobs:
with:
file: ${{ github.workspace }}/v2rayN*.dmg
tag: ${{ github.event.inputs.release_tag }}
+ file_glob: true
+
+ # release zip archive
+ - name: Package release zip archive
+ if: github.event.inputs.release_tag != ''
+ run: |
+ chmod 755 package-release-zip.sh
+ ./package-release-zip.sh $OutputArch $OutputPath64
+ ./package-release-zip.sh $OutputArchArm $OutputPathArm64
+
+ - name: Upload zip archive to release
+ uses: svenstaro/upload-release-action@v2
+ if: github.event.inputs.release_tag != ''
+ with:
+ file: ${{ github.workspace }}/v2rayN*.zip
+ tag: ${{ github.event.inputs.release_tag }}
file_glob: true
\ No newline at end of file
diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml
index 0baa8939..2b19e646 100644
--- a/.github/workflows/build-windows.yml
+++ b/.github/workflows/build-windows.yml
@@ -35,6 +35,10 @@ jobs:
dotnet publish ./v2rayN/v2rayN.csproj -c Release -r win-x64 --self-contained false -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:EnableWindowsTargeting=true -o $OutputPath64
dotnet publish ./v2rayN/v2rayN.csproj -c Release -r win-arm64 --self-contained false -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:EnableWindowsTargeting=true -o $OutputPathArm64
dotnet publish ./v2rayN/v2rayN.csproj -c Release -r win-x64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:EnableWindowsTargeting=true -o $OutputPath64Sc
+ dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-x64 --self-contained false -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:EnableWindowsTargeting=true -o $OutputPath64
+ dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-arm64 --self-contained false -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:EnableWindowsTargeting=true -o $OutputPathArm64
+ dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-x64 --self-contained true -p:PublishReadyToRun=false -p:PublishSingleFile=true -p:PublishTrimmed=true -p:EnableWindowsTargeting=true -o $OutputPath64Sc
+
- name: Upload build artifacts
uses: actions/upload-artifact@v4
diff --git a/package-debian.sh b/package-debian.sh
index 0e7eab8e..98afec98 100644
--- a/package-debian.sh
+++ b/package-debian.sh
@@ -8,6 +8,7 @@ PackagePath="v2rayN-Package-${Arch}"
mkdir -p "${PackagePath}/DEBIAN"
mkdir -p "${PackagePath}/opt"
cp -rf $OutputPath "${PackagePath}/opt/v2rayN"
+echo "When this file exists, app will not store configs under this folder" > "${PackagePath}/opt/v2rayN/NotStoreConfigHere.txt"
if [ $Arch = "linux-64" ]; then
Arch2="amd64"
@@ -44,6 +45,7 @@ EOF
sudo chmod 0755 "${PackagePath}/DEBIAN/postinst"
sudo chmod 0755 "${PackagePath}/opt/v2rayN/v2rayN"
+sudo chmod 0755 "${PackagePath}/opt/v2rayN/AmazTool"
# desktop && PATH
diff --git a/package-osx.sh b/package-osx.sh
index d656b91f..cfbd8359 100755
--- a/package-osx.sh
+++ b/package-osx.sh
@@ -4,14 +4,10 @@ Arch="$1"
OutputPath="$2"
Version="$3"
-FileName="v2rayN-${Arch}.zip"
-wget -nv -O $FileName "https://github.com/2dust/v2rayN-core-bin/raw/refs/heads/master/$FileName"
-7z x $FileName
-cp -rf v2rayN-${Arch}/* $OutputPath
-
PackagePath="v2rayN-Package-${Arch}"
mkdir -p "$PackagePath/v2rayN.app/Contents/Resources"
cp -rf "$OutputPath" "$PackagePath/v2rayN.app/Contents/MacOS"
+echo "When this file exists, app will not store configs under this folder" > "$PackagePath/v2rayN.app/Contents/MacOS/NotStoreConfigHere.txt"
chmod +x "$PackagePath/v2rayN.app/Contents/MacOS/v2rayN"
mkdir -p "$PackagePath/icons.iconset"
@@ -43,7 +39,7 @@ cat >"$PackagePath/v2rayN.app/Contents/Info.plist" <<-EOF
CFBundleIconName
AppIcon
CFBundleIdentifier
- v2rayN.desktop
+ 2dust.v2rayN
CFBundleName
v2rayN
CFBundlePackageType
diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs
index 585951bb..31495e4a 100644
--- a/v2rayN/ServiceLib/Common/Utils.cs
+++ b/v2rayN/ServiceLib/Common/Utils.cs
@@ -517,7 +517,7 @@ namespace ServiceLib.Common
public static bool UpgradeAppExists(out string fileName)
{
- fileName = Path.Combine(Utils.StartupPath(), GetExeName("AmazTool"));
+ fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, GetExeName("AmazTool"));
return File.Exists(fileName);
}
@@ -675,6 +675,12 @@ namespace ServiceLib.Common
{
try
{
+ //When this file exists, it is equivalent to having no permission to read and write
+ if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NotStoreConfigHere.txt")))
+ {
+ return false;
+ }
+
var tempPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "guiTemps");
if (!Directory.Exists(tempPath))
{