From e85e2c7aa9b641dfeba45753bdfaffedd8fe8f1a Mon Sep 17 00:00:00 2001 From: miu <205594122@qq.com> Date: Sun, 15 Mar 2026 02:44:53 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.github/workflows/bu?= =?UTF-8?q?ild-exe.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix --- .github/workflows/build-exe.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index ec4aeea..b82722b 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -10,6 +10,10 @@ jobs: runs-on: windows-latest steps: + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 - name: Checkout code uses: actions/checkout@v4 From 190a08805bfe70322652dd42e9d3bc225c1d3c14 Mon Sep 17 00:00:00 2001 From: miu <205594122@qq.com> Date: Sun, 15 Mar 2026 02:54:15 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.github/workflows/bu?= =?UTF-8?q?ild-exe.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index b82722b..8f579b9 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -2,31 +2,35 @@ name: Build Windows EXE on: push: - branches: [ "main" ] - workflow_dispatch: # 允许手动触发 + branches: ["main"] + workflow_dispatch: jobs: build: runs-on: windows-latest steps: - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Checkout code + - name: Checkout uses: actions/checkout@v4 - - name: Set up Python + - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.9.1' # 建议指定版本,确保稳定性 - cache: 'pip' # 自动缓存依赖,加快下次构建速度 + python-version: "3.9" - - name: Install dependencies + - name: Install deps run: | - python -m pip install --upgrade pip - python -m pip install pyinstaller keyboard pywin32 + pip install pyinstaller keyboard pywin32 + + - name: Build EXE + run: | + pyinstaller --onefile --windowed --name Shortcut_Sync_PotPlayer main.py + + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: exe + path: dist/Shortcut_Sync_PotPlayer.exe - name: Build with PyInstaller run: | From 18b5ba9c43636cb9bf01c6d301d7a2f180158e0c Mon Sep 17 00:00:00 2001 From: miu <205594122@qq.com> Date: Sun, 15 Mar 2026 02:55:44 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.github/workflows/bu?= =?UTF-8?q?ild-exe.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index 8f579b9..a8e316e 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -30,17 +30,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: exe - path: dist/Shortcut_Sync_PotPlayer.exe - - - name: Build with PyInstaller - run: | - # --clean 确保清理旧缓存 - # --admin-access 如果你的程序需要监听全局钩子,有时需要此权限 - python -m PyInstaller --noconfirm --onefile --windowed --name "Shortcut_Sync_PotPlayer" main.py - - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: PotPlayer-Sync-Tool - path: dist/Shortcut_Sync_PotPlayer.exe - retention-days: 7 # 临时文件保存7天 \ No newline at end of file + path: dist/Shortcut_Sync_PotPlayer.exe \ No newline at end of file From 789b02ee2775f8c1ae755154da336837534d7e78 Mon Sep 17 00:00:00 2001 From: miu <205594122@qq.com> Date: Sun, 15 Mar 2026 02:55:44 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.github/workflows/bu?= =?UTF-8?q?ild-exe.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index 8f579b9..a8e316e 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -30,17 +30,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: exe - path: dist/Shortcut_Sync_PotPlayer.exe - - - name: Build with PyInstaller - run: | - # --clean 确保清理旧缓存 - # --admin-access 如果你的程序需要监听全局钩子,有时需要此权限 - python -m PyInstaller --noconfirm --onefile --windowed --name "Shortcut_Sync_PotPlayer" main.py - - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: PotPlayer-Sync-Tool - path: dist/Shortcut_Sync_PotPlayer.exe - retention-days: 7 # 临时文件保存7天 \ No newline at end of file + path: dist/Shortcut_Sync_PotPlayer.exe \ No newline at end of file From cf93a1ce5934ed2c6d97c2a616f901d8381995a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9B=9B=E6=9C=88?= Date: Sun, 15 Mar 2026 03:05:46 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E5=88=A0=E9=99=A4=20.github/workflows/bu?= =?UTF-8?q?ild-exe.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/build-exe.yml diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml deleted file mode 100644 index a8e316e..0000000 --- a/.github/workflows/build-exe.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Build Windows EXE - -on: - push: - branches: ["main"] - workflow_dispatch: - -jobs: - build: - runs-on: windows-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.9" - - - name: Install deps - run: | - pip install pyinstaller keyboard pywin32 - - - name: Build EXE - run: | - pyinstaller --onefile --windowed --name Shortcut_Sync_PotPlayer main.py - - - name: Upload - uses: actions/upload-artifact@v4 - with: - name: exe - path: dist/Shortcut_Sync_PotPlayer.exe \ No newline at end of file From 84de76c853ac844363fc28c05f30b44f50edfbf7 Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 03:36:40 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E4=B8=AD=E7=9A=84=E5=85=A8=E5=B1=80=E7=BB=84?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index a8bf42c..195d206 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -8,7 +8,6 @@ on: jobs: build: runs-on: - group: 全局 labels: windows steps: From 38c3bf33ab7f2583b4851a4f5fa7dbce9c69b65f Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 03:52:27 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=EF=BC=8C=E4=BC=98=E5=8C=96Python?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=92=8C=E4=BB=93=E5=BA=93=E5=85=8B=E9=9A=86?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 193 +++++++++++++++++++++++++++++--- 1 file changed, 175 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index 195d206..f0f965e 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -7,31 +7,188 @@ on: jobs: build: - runs-on: - labels: windows + runs-on: windows + defaults: + run: + shell: powershell + env: + REPO_URL: https://git.hsdi.cc/Hsdi/Shortcut_Sync_PotPlayer.git + PYTHON_DIRNAME: python-3.9.1 + SOURCE_DIRNAME: Shortcut_Sync_PotPlayer-src + OUTPUT_SUBDIR: gitea-builds\Shortcut_Sync_PotPlayer + CI_USER: ${{ secrets.CI_USER }} + CI_TOKEN: ${{ secrets.CI_TOKEN }} steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository without Node + run: | + $ErrorActionPreference = "Stop" - - name: Set up Python 3.9.1 - uses: actions/setup-python@v5 - with: - python-version: "3.9.1" - architecture: "x64" + $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } + $sourceDir = Join-Path $tempRoot $env:SOURCE_DIRNAME + $repoUrl = $env:REPO_URL + $refName = "${{ gitea.ref_name }}" + $ref = "${{ gitea.ref }}" + + if (-not $refName) { + if ($ref -match "^refs/heads/(.+)$") { + $refName = $Matches[1] + } elseif ($ref -match "^refs/tags/(.+)$") { + $refName = $Matches[1] + } else { + $refName = "main" + } + } + + if (Test-Path $sourceDir) { + Remove-Item -Path $sourceDir -Recurse -Force + } + + New-Item -ItemType Directory -Path $sourceDir | Out-Null + + $cloneAttempts = @() + $cloneAttempts += @{ + Name = "anonymous" + Args = @("clone", "--depth", "1", "--branch", $refName, $repoUrl, $sourceDir) + } + + if ($env:CI_USER -and $env:CI_TOKEN) { + $basicAuth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $env:CI_USER, $env:CI_TOKEN))) + $cloneAttempts += @{ + Name = "basic-auth" + Args = @( + "-c", + "http.extraHeader=Authorization: Basic $basicAuth", + "clone", + "--depth", + "1", + "--branch", + $refName, + $repoUrl, + $sourceDir + ) + } + } + + $cloned = $false + foreach ($attempt in $cloneAttempts) { + Write-Host "Trying clone mode: $($attempt.Name)" + try { + & git @($attempt.Args) + if ($LASTEXITCODE -eq 0) { + $cloned = $true + break + } + } catch { + Write-Warning $_ + } + + if (Test-Path $sourceDir) { + Remove-Item -Path $sourceDir -Recurse -Force + } + New-Item -ItemType Directory -Path $sourceDir | Out-Null + } + + if (-not $cloned) { + throw "Repository checkout failed. If this repository is private, add Actions secrets CI_USER and CI_TOKEN." + } + + & git -C $sourceDir rev-parse HEAD + + - name: Install Python 3.9.1 without Node + run: | + $ErrorActionPreference = "Stop" + + $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } + $pythonRoot = Join-Path $tempRoot $env:PYTHON_DIRNAME + $pythonExe = Join-Path $pythonRoot "python.exe" + $installerPath = Join-Path $tempRoot "python-3.9.1-amd64.exe" + + $needsInstall = $true + if (Test-Path $pythonExe) { + $versionOutput = & $pythonExe --version 2>&1 + if ($versionOutput -match "^Python 3\.9\.1$") { + $needsInstall = $false + } + } + + if ($needsInstall) { + if (Test-Path $pythonRoot) { + Remove-Item -Path $pythonRoot -Recurse -Force + } + + Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.9.1/python-3.9.1-amd64.exe" -OutFile $installerPath + + Start-Process -FilePath $installerPath -ArgumentList @( + "/quiet", + "InstallAllUsers=0", + "PrependPath=0", + "Include_test=0", + "Include_pip=1", + "Shortcuts=0", + "AssociateFiles=0", + "CompileAll=0", + "TargetDir=$pythonRoot" + ) -Wait -NoNewWindow + } + + if (-not (Test-Path $pythonExe)) { + throw "Python 3.9.1 install failed: python.exe not found." + } + + $versionOutput = & $pythonExe --version 2>&1 + if ($versionOutput -notmatch "^Python 3\.9\.1$") { + throw "Expected Python 3.9.1, got: $versionOutput" + } + + Write-Host $versionOutput - name: Install dependencies run: | - python -m pip install --upgrade pip - python -m pip install pyinstaller keyboard pywin32 + $ErrorActionPreference = "Stop" + $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } + $pythonRoot = Join-Path $tempRoot $env:PYTHON_DIRNAME + $pythonExe = Join-Path $pythonRoot "python.exe" + + & $pythonExe -m pip install --upgrade pip + & $pythonExe -m pip install pyinstaller keyboard pywin32 - name: Build EXE run: | - python -m PyInstaller --clean --noconfirm --onefile --windowed --name Shortcut_Sync_PotPlayer main.py + $ErrorActionPreference = "Stop" + $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } + $pythonRoot = Join-Path $tempRoot $env:PYTHON_DIRNAME + $sourceDir = Join-Path $tempRoot $env:SOURCE_DIRNAME + $pythonExe = Join-Path $pythonRoot "python.exe" - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: Shortcut_Sync_PotPlayer-windows - path: dist/Shortcut_Sync_PotPlayer.exe - if-no-files-found: error + Set-Location $sourceDir + & $pythonExe -m PyInstaller --clean --noconfirm --onefile --windowed --name Shortcut_Sync_PotPlayer main.py + + - name: Save build output on runner + run: | + $ErrorActionPreference = "Stop" + + $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } + $sourceDir = Join-Path $tempRoot $env:SOURCE_DIRNAME + $outputRoot = Join-Path $env:USERPROFILE $env:OUTPUT_SUBDIR + $distExe = Join-Path $sourceDir "dist\Shortcut_Sync_PotPlayer.exe" + if (-not (Test-Path $distExe)) { + throw "Build output not found: $distExe" + } + + $runId = "${{ gitea.run_number }}" + if (-not $runId) { + $runId = (Get-Date -Format "yyyyMMdd-HHmmss") + } + + $outputDir = Join-Path $outputRoot ("run-" + $runId) + New-Item -ItemType Directory -Path $outputDir -Force | Out-Null + + $exePath = Join-Path $outputDir "Shortcut_Sync_PotPlayer.exe" + $zipPath = Join-Path $outputDir "Shortcut_Sync_PotPlayer.zip" + + Copy-Item -Path $distExe -Destination $exePath -Force + Compress-Archive -Path $distExe -DestinationPath $zipPath -Force + + Write-Host "EXE saved to: $exePath" + Write-Host "ZIP saved to: $zipPath" From 4973716368977cfc23251dd54ccf0beab033083a Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 04:02:31 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E9=87=8D=E6=9E=84=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 187 +++----------------------------- 1 file changed, 16 insertions(+), 171 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index f0f965e..3a87994 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -11,184 +11,29 @@ jobs: defaults: run: shell: powershell - env: - REPO_URL: https://git.hsdi.cc/Hsdi/Shortcut_Sync_PotPlayer.git - PYTHON_DIRNAME: python-3.9.1 - SOURCE_DIRNAME: Shortcut_Sync_PotPlayer-src - OUTPUT_SUBDIR: gitea-builds\Shortcut_Sync_PotPlayer - CI_USER: ${{ secrets.CI_USER }} - CI_TOKEN: ${{ secrets.CI_TOKEN }} steps: - - name: Checkout repository without Node - run: | - $ErrorActionPreference = "Stop" + - name: Checkout repository + uses: https://github.com/actions/checkout@v4 - $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } - $sourceDir = Join-Path $tempRoot $env:SOURCE_DIRNAME - $repoUrl = $env:REPO_URL - $refName = "${{ gitea.ref_name }}" - $ref = "${{ gitea.ref }}" - - if (-not $refName) { - if ($ref -match "^refs/heads/(.+)$") { - $refName = $Matches[1] - } elseif ($ref -match "^refs/tags/(.+)$") { - $refName = $Matches[1] - } else { - $refName = "main" - } - } - - if (Test-Path $sourceDir) { - Remove-Item -Path $sourceDir -Recurse -Force - } - - New-Item -ItemType Directory -Path $sourceDir | Out-Null - - $cloneAttempts = @() - $cloneAttempts += @{ - Name = "anonymous" - Args = @("clone", "--depth", "1", "--branch", $refName, $repoUrl, $sourceDir) - } - - if ($env:CI_USER -and $env:CI_TOKEN) { - $basicAuth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $env:CI_USER, $env:CI_TOKEN))) - $cloneAttempts += @{ - Name = "basic-auth" - Args = @( - "-c", - "http.extraHeader=Authorization: Basic $basicAuth", - "clone", - "--depth", - "1", - "--branch", - $refName, - $repoUrl, - $sourceDir - ) - } - } - - $cloned = $false - foreach ($attempt in $cloneAttempts) { - Write-Host "Trying clone mode: $($attempt.Name)" - try { - & git @($attempt.Args) - if ($LASTEXITCODE -eq 0) { - $cloned = $true - break - } - } catch { - Write-Warning $_ - } - - if (Test-Path $sourceDir) { - Remove-Item -Path $sourceDir -Recurse -Force - } - New-Item -ItemType Directory -Path $sourceDir | Out-Null - } - - if (-not $cloned) { - throw "Repository checkout failed. If this repository is private, add Actions secrets CI_USER and CI_TOKEN." - } - - & git -C $sourceDir rev-parse HEAD - - - name: Install Python 3.9.1 without Node - run: | - $ErrorActionPreference = "Stop" - - $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } - $pythonRoot = Join-Path $tempRoot $env:PYTHON_DIRNAME - $pythonExe = Join-Path $pythonRoot "python.exe" - $installerPath = Join-Path $tempRoot "python-3.9.1-amd64.exe" - - $needsInstall = $true - if (Test-Path $pythonExe) { - $versionOutput = & $pythonExe --version 2>&1 - if ($versionOutput -match "^Python 3\.9\.1$") { - $needsInstall = $false - } - } - - if ($needsInstall) { - if (Test-Path $pythonRoot) { - Remove-Item -Path $pythonRoot -Recurse -Force - } - - Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.9.1/python-3.9.1-amd64.exe" -OutFile $installerPath - - Start-Process -FilePath $installerPath -ArgumentList @( - "/quiet", - "InstallAllUsers=0", - "PrependPath=0", - "Include_test=0", - "Include_pip=1", - "Shortcuts=0", - "AssociateFiles=0", - "CompileAll=0", - "TargetDir=$pythonRoot" - ) -Wait -NoNewWindow - } - - if (-not (Test-Path $pythonExe)) { - throw "Python 3.9.1 install failed: python.exe not found." - } - - $versionOutput = & $pythonExe --version 2>&1 - if ($versionOutput -notmatch "^Python 3\.9\.1$") { - throw "Expected Python 3.9.1, got: $versionOutput" - } - - Write-Host $versionOutput + - name: Set up Python 3.9.1 + uses: https://github.com/actions/setup-python@v5 + with: + python-version: "3.9.1" + architecture: "x64" - name: Install dependencies run: | - $ErrorActionPreference = "Stop" - $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } - $pythonRoot = Join-Path $tempRoot $env:PYTHON_DIRNAME - $pythonExe = Join-Path $pythonRoot "python.exe" - - & $pythonExe -m pip install --upgrade pip - & $pythonExe -m pip install pyinstaller keyboard pywin32 + python -m pip install --upgrade pip + python -m pip install pyinstaller keyboard pywin32 - name: Build EXE run: | - $ErrorActionPreference = "Stop" - $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } - $pythonRoot = Join-Path $tempRoot $env:PYTHON_DIRNAME - $sourceDir = Join-Path $tempRoot $env:SOURCE_DIRNAME - $pythonExe = Join-Path $pythonRoot "python.exe" + python -m PyInstaller --clean --noconfirm --onefile --windowed --name Shortcut_Sync_PotPlayer main.py - Set-Location $sourceDir - & $pythonExe -m PyInstaller --clean --noconfirm --onefile --windowed --name Shortcut_Sync_PotPlayer main.py - - - name: Save build output on runner - run: | - $ErrorActionPreference = "Stop" - - $tempRoot = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP } - $sourceDir = Join-Path $tempRoot $env:SOURCE_DIRNAME - $outputRoot = Join-Path $env:USERPROFILE $env:OUTPUT_SUBDIR - $distExe = Join-Path $sourceDir "dist\Shortcut_Sync_PotPlayer.exe" - if (-not (Test-Path $distExe)) { - throw "Build output not found: $distExe" - } - - $runId = "${{ gitea.run_number }}" - if (-not $runId) { - $runId = (Get-Date -Format "yyyyMMdd-HHmmss") - } - - $outputDir = Join-Path $outputRoot ("run-" + $runId) - New-Item -ItemType Directory -Path $outputDir -Force | Out-Null - - $exePath = Join-Path $outputDir "Shortcut_Sync_PotPlayer.exe" - $zipPath = Join-Path $outputDir "Shortcut_Sync_PotPlayer.zip" - - Copy-Item -Path $distExe -Destination $exePath -Force - Compress-Archive -Path $distExe -DestinationPath $zipPath -Force - - Write-Host "EXE saved to: $exePath" - Write-Host "ZIP saved to: $zipPath" + - name: Upload artifact + uses: https://github.com/actions/upload-artifact@v4 + with: + name: Shortcut_Sync_PotPlayer-windows + path: dist/Shortcut_Sync_PotPlayer.exe + if-no-files-found: error From 479fc155f75dc7ec2a6c1137f0b6e5f920c54dd0 Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 11:15:17 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 39 --------------------------------- 1 file changed, 39 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index 3a87994..e69de29 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -1,39 +0,0 @@ -name: Build Windows EXE - -on: - push: - branches: ["main"] - workflow_dispatch: - -jobs: - build: - runs-on: windows - defaults: - run: - shell: powershell - - steps: - - name: Checkout repository - uses: https://github.com/actions/checkout@v4 - - - name: Set up Python 3.9.1 - uses: https://github.com/actions/setup-python@v5 - with: - python-version: "3.9.1" - architecture: "x64" - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install pyinstaller keyboard pywin32 - - - name: Build EXE - run: | - python -m PyInstaller --clean --noconfirm --onefile --windowed --name Shortcut_Sync_PotPlayer main.py - - - name: Upload artifact - uses: https://github.com/actions/upload-artifact@v4 - with: - name: Shortcut_Sync_PotPlayer-windows - path: dist/Shortcut_Sync_PotPlayer.exe - if-no-files-found: error From 7f7c172abba2915299b70e02fa360cc744e22698 Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 11:32:35 +0800 Subject: [PATCH 10/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 135 ++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index e69de29..a791d11 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -0,0 +1,135 @@ +name: Build Windows EXE + +on: + push: + workflow_dispatch: + +permissions: + contents: write + +env: + PYTHON_VERSION: "3.11.9" + PYTHON_DIR: 'C:\Python311' + PYTHON_EXE: 'C:\Python311\python.exe' + +jobs: + build: + runs-on: ubuntu-22.04 + outputs: + archive_name: ${{ steps.archive.outputs.archive_name }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Wine + shell: bash + run: | + WINEPREFIX="$RUNNER_TEMP/wine" + echo "WINEPREFIX=$WINEPREFIX" >> "$GITHUB_ENV" + echo "WINEDEBUG=-all" >> "$GITHUB_ENV" + export WINEPREFIX + export WINEDEBUG=-all + + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + wine64 \ + wine32 \ + curl \ + ca-certificates \ + xvfb \ + zip + + xvfb-run -a wine64 wineboot --init + wineserver -w + wine64 --version + + - name: Install Windows Python + shell: bash + run: | + curl -fsSL \ + "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-amd64.exe" \ + -o /tmp/python-installer.exe + + xvfb-run -a wine64 /tmp/python-installer.exe \ + /quiet \ + InstallAllUsers=1 \ + PrependPath=1 \ + Include_pip=1 \ + Include_test=0 \ + SimpleInstall=1 \ + "TargetDir=${PYTHON_DIR}" + + wineserver -w + rm -f /tmp/python-installer.exe + xvfb-run -a wine64 "${PYTHON_EXE}" --version + + - name: Install Dependencies + shell: bash + run: | + xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --upgrade pip setuptools wheel + + if [ -f requirements.txt ]; then + xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --no-cache-dir -r requirements.txt + fi + + xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --no-cache-dir \ + pyinstaller \ + keyboard \ + pywin32 + + xvfb-run -a wine64 "${PYTHON_EXE}" -c "import keyboard, win32api, win32gui; print('dependencies ok')" + + - name: Build EXE + shell: bash + run: | + xvfb-run -a wine64 "${PYTHON_EXE}" -m PyInstaller \ + --noconfirm \ + --clean \ + --onefile \ + --windowed \ + --name Shortcut_Sync_PotPlayer \ + main.py + + test -f dist/Shortcut_Sync_PotPlayer.exe + + - name: Package artifact + id: archive + shell: bash + run: | + if [[ "$GITHUB_REF" == refs/tags/* ]]; then + version="$GITHUB_REF_NAME" + else + version="run-${GITHUB_RUN_NUMBER}" + fi + + archive_name="Shortcut_Sync_PotPlayer-${version}-windows-x64.zip" + zip -j "dist/${archive_name}" "dist/Shortcut_Sync_PotPlayer.exe" + echo "archive_name=${archive_name}" >> "$GITHUB_OUTPUT" + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: windows-exe-package + path: dist/${{ steps.archive.outputs.archive_name }} + retention-days: 30 + if-no-files-found: error + + release: + if: startsWith(github.ref, 'refs/tags/') + needs: build + runs-on: ubuntu-22.04 + + steps: + - name: Download packaged artifact + uses: actions/download-artifact@v4 + with: + name: windows-exe-package + path: release-assets + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: release-assets/${{ needs.build.outputs.archive_name }} + generate_release_notes: true From 14e49f1b19549ad0117faeccb824b15596634677 Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 11:51:04 +0800 Subject: [PATCH 11/15] 3151150 --- .github/workflows/build-exe.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index a791d11..e95b61c 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -8,9 +8,9 @@ permissions: contents: write env: - PYTHON_VERSION: "3.11.9" - PYTHON_DIR: 'C:\Python311' - PYTHON_EXE: 'C:\Python311\python.exe' + PYTHON_VERSION: "3.9.1" + PYTHON_DIR: 'C:\Python391' + PYTHON_EXE: 'C:\Python391\python.exe' jobs: build: From e59bc51fcacc66ef93b11fce30b225dbae9836e2 Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 12:23:41 +0800 Subject: [PATCH 12/15] 3151223 --- .github/workflows/build-exe.yml | 130 +++++++++++++++++++++++--------- 1 file changed, 93 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index e95b61c..a6a2fa4 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -4,10 +4,9 @@ on: push: workflow_dispatch: -permissions: - contents: write - env: + APP_NAME: Shortcut_Sync_PotPlayer + PACKAGE_NAME: shortcut-sync-potplayer PYTHON_VERSION: "3.9.1" PYTHON_DIR: 'C:\Python391' PYTHON_EXE: 'C:\Python391\python.exe' @@ -15,12 +14,18 @@ env: jobs: build: runs-on: ubuntu-22.04 - outputs: - archive_name: ${{ steps.archive.outputs.archive_name }} steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Verify workspace + shell: bash + run: | + pwd + ls -la + test -f main.py || { + echo "main.py not found in workspace." + echo "If your runner does not auto-check out the repository, add a local mirror for checkout or clone the repo before running this workflow." + exit 1 + } - name: Setup Wine shell: bash @@ -38,6 +43,7 @@ jobs: wine32 \ curl \ ca-certificates \ + jq \ xvfb \ zip @@ -65,7 +71,7 @@ jobs: rm -f /tmp/python-installer.exe xvfb-run -a wine64 "${PYTHON_EXE}" --version - - name: Install Dependencies + - name: Install dependencies shell: bash run: | xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --upgrade pip setuptools wheel @@ -89,47 +95,97 @@ jobs: --clean \ --onefile \ --windowed \ - --name Shortcut_Sync_PotPlayer \ + --name "${APP_NAME}" \ main.py - test -f dist/Shortcut_Sync_PotPlayer.exe + test -f "dist/${APP_NAME}.exe" - - name: Package artifact - id: archive + - name: Package build + id: package shell: bash run: | if [[ "$GITHUB_REF" == refs/tags/* ]]; then version="$GITHUB_REF_NAME" else - version="run-${GITHUB_RUN_NUMBER}" + version="run-${GITHUB_RUN_NUMBER}-${GITHUB_SHA::7}" fi - archive_name="Shortcut_Sync_PotPlayer-${version}-windows-x64.zip" - zip -j "dist/${archive_name}" "dist/Shortcut_Sync_PotPlayer.exe" + archive_name="${APP_NAME}-${version}-windows-x64.zip" + archive_path="dist/${archive_name}" + + zip -j "$archive_path" "dist/${APP_NAME}.exe" + + echo "version=${version}" >> "$GITHUB_OUTPUT" echo "archive_name=${archive_name}" >> "$GITHUB_OUTPUT" + echo "archive_path=${archive_path}" >> "$GITHUB_OUTPUT" - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: windows-exe-package - path: dist/${{ steps.archive.outputs.archive_name }} - retention-days: 30 - if-no-files-found: error + - name: Upload package to Gitea Packages + id: publish_package + shell: bash + env: + ACTIONS_TOKEN: ${{ github.token }} + run: | + owner="${GITHUB_REPOSITORY%%/*}" + package_url="${GITHUB_SERVER_URL}/api/packages/${owner}/generic/${PACKAGE_NAME}/${{ steps.package.outputs.version }}/${{ steps.package.outputs.archive_name }}" - release: - if: startsWith(github.ref, 'refs/tags/') - needs: build - runs-on: ubuntu-22.04 + curl --fail-with-body --silent --show-error \ + -X PUT \ + -H "Authorization: token ${ACTIONS_TOKEN}" \ + -H "Content-Type: application/zip" \ + --upload-file "${{ steps.package.outputs.archive_path }}" \ + "$package_url" - steps: - - name: Download packaged artifact - uses: actions/download-artifact@v4 - with: - name: windows-exe-package - path: release-assets + echo "package_url=${package_url}" >> "$GITHUB_OUTPUT" + if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then + echo "Built package: ${package_url}" >> "$GITHUB_STEP_SUMMARY" + fi - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 - with: - files: release-assets/${{ needs.build.outputs.archive_name }} - generate_release_notes: true + - name: Create release on tag + if: startsWith(github.ref, 'refs/tags/') + shell: bash + env: + ACTIONS_TOKEN: ${{ github.token }} + run: | + api_url="${GITHUB_API_URL:-${GITHUB_SERVER_URL}/api/v1}" + releases_url="${api_url}/repos/${GITHUB_REPOSITORY}/releases" + tag_name="${GITHUB_REF_NAME}" + release_name="${tag_name}" + body="Windows build package: ${{ steps.publish_package.outputs.package_url }}" + + existing_release_id="$( + curl --silent \ + -H "Authorization: token ${ACTIONS_TOKEN}" \ + "${releases_url}" | jq -r --arg tag "$tag_name" '.[] | select(.tag_name == $tag) | .id' | head -n 1 + )" + + if [ -n "$existing_release_id" ] && [ "$existing_release_id" != "null" ]; then + echo "Release already exists for ${tag_name}, skipping creation." + exit 0 + fi + + payload="$( + jq -n \ + --arg tag_name "$tag_name" \ + --arg target_commitish "$GITHUB_SHA" \ + --arg name "$release_name" \ + --arg body "$body" \ + '{ + tag_name: $tag_name, + target_commitish: $target_commitish, + name: $name, + body: $body, + draft: false, + prerelease: false + }' + )" + + curl --fail-with-body --silent --show-error \ + -X POST \ + -H "Authorization: token ${ACTIONS_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "$payload" \ + "$releases_url" > /dev/null + + if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then + echo "Release created for ${tag_name}" >> "$GITHUB_STEP_SUMMARY" + fi From d4627c8abacbc24ffbaafb00e9cad730504d727c Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 12:27:15 +0800 Subject: [PATCH 13/15] 3151227 --- .github/workflows/build-exe.yml | 64 ++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index a6a2fa4..43cea70 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -16,17 +16,71 @@ jobs: runs-on: ubuntu-22.04 steps: - - name: Verify workspace + - name: Checkout repository shell: bash + env: + ACTIONS_TOKEN: ${{ github.token }} + GIT_TERMINAL_PROMPT: 0 run: | pwd ls -la - test -f main.py || { - echo "main.py not found in workspace." - echo "If your runner does not auto-check out the repository, add a local mirror for checkout or clone the repo before running this workflow." - exit 1 + + if [ -f main.py ]; then + echo "Repository already available in workspace." + exit 0 + fi + + if ! command -v git >/dev/null 2>&1; then + sudo apt-get update + sudo apt-get install -y --no-install-recommends git ca-certificates + fi + + repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + + if [ ! -d .git ]; then + git init . + fi + + git config --global --add safe.directory "$PWD" + + if git remote get-url origin >/dev/null 2>&1; then + git remote set-url origin "$repo_url" + else + git remote add origin "$repo_url" + fi + + fetch_target() { + local target="$1" + git fetch --depth=1 origin "$target" } + fetch_with_basic_auth() { + local target="$1" + local username="$2" + local auth_header + auth_header="$(printf '%s:%s' "$username" "${ACTIONS_TOKEN}" | base64 -w0)" + git \ + -c http.extraHeader="Authorization: Basic ${auth_header}" \ + fetch --depth=1 origin "$target" + } + + if fetch_target "${GITHUB_SHA}" || fetch_target "${GITHUB_REF}"; then + echo "Fetched repository without authentication." + elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "${GITHUB_ACTOR:-git}" || fetch_with_basic_auth "${GITHUB_REF}" "${GITHUB_ACTOR:-git}"); then + echo "Fetched repository with actor token authentication." + elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "oauth2" || fetch_with_basic_auth "${GITHUB_REF}" "oauth2"); then + echo "Fetched repository with oauth2 token authentication." + elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "git" || fetch_with_basic_auth "${GITHUB_REF}" "git"); then + echo "Fetched repository with git token authentication." + else + echo "Failed to fetch repository contents from ${repo_url}." + exit 1 + fi + + git checkout --force FETCH_HEAD + git log -1 --oneline + test -f main.py + - name: Setup Wine shell: bash run: | From 07c586c1d5e15df02465c9380e9dd7eb80ae92e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9B=9B=E6=9C=88?= Date: Sun, 15 Mar 2026 23:49:27 +0800 Subject: [PATCH 14/15] =?UTF-8?q?=E5=88=A0=E9=99=A4=20.github/workflows/bu?= =?UTF-8?q?ild-exe.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe.yml | 245 -------------------------------- 1 file changed, 245 deletions(-) delete mode 100644 .github/workflows/build-exe.yml diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml deleted file mode 100644 index 43cea70..0000000 --- a/.github/workflows/build-exe.yml +++ /dev/null @@ -1,245 +0,0 @@ -name: Build Windows EXE - -on: - push: - workflow_dispatch: - -env: - APP_NAME: Shortcut_Sync_PotPlayer - PACKAGE_NAME: shortcut-sync-potplayer - PYTHON_VERSION: "3.9.1" - PYTHON_DIR: 'C:\Python391' - PYTHON_EXE: 'C:\Python391\python.exe' - -jobs: - build: - runs-on: ubuntu-22.04 - - steps: - - name: Checkout repository - shell: bash - env: - ACTIONS_TOKEN: ${{ github.token }} - GIT_TERMINAL_PROMPT: 0 - run: | - pwd - ls -la - - if [ -f main.py ]; then - echo "Repository already available in workspace." - exit 0 - fi - - if ! command -v git >/dev/null 2>&1; then - sudo apt-get update - sudo apt-get install -y --no-install-recommends git ca-certificates - fi - - repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" - - if [ ! -d .git ]; then - git init . - fi - - git config --global --add safe.directory "$PWD" - - if git remote get-url origin >/dev/null 2>&1; then - git remote set-url origin "$repo_url" - else - git remote add origin "$repo_url" - fi - - fetch_target() { - local target="$1" - git fetch --depth=1 origin "$target" - } - - fetch_with_basic_auth() { - local target="$1" - local username="$2" - local auth_header - auth_header="$(printf '%s:%s' "$username" "${ACTIONS_TOKEN}" | base64 -w0)" - git \ - -c http.extraHeader="Authorization: Basic ${auth_header}" \ - fetch --depth=1 origin "$target" - } - - if fetch_target "${GITHUB_SHA}" || fetch_target "${GITHUB_REF}"; then - echo "Fetched repository without authentication." - elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "${GITHUB_ACTOR:-git}" || fetch_with_basic_auth "${GITHUB_REF}" "${GITHUB_ACTOR:-git}"); then - echo "Fetched repository with actor token authentication." - elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "oauth2" || fetch_with_basic_auth "${GITHUB_REF}" "oauth2"); then - echo "Fetched repository with oauth2 token authentication." - elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "git" || fetch_with_basic_auth "${GITHUB_REF}" "git"); then - echo "Fetched repository with git token authentication." - else - echo "Failed to fetch repository contents from ${repo_url}." - exit 1 - fi - - git checkout --force FETCH_HEAD - git log -1 --oneline - test -f main.py - - - name: Setup Wine - shell: bash - run: | - WINEPREFIX="$RUNNER_TEMP/wine" - echo "WINEPREFIX=$WINEPREFIX" >> "$GITHUB_ENV" - echo "WINEDEBUG=-all" >> "$GITHUB_ENV" - export WINEPREFIX - export WINEDEBUG=-all - - sudo dpkg --add-architecture i386 - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - wine64 \ - wine32 \ - curl \ - ca-certificates \ - jq \ - xvfb \ - zip - - xvfb-run -a wine64 wineboot --init - wineserver -w - wine64 --version - - - name: Install Windows Python - shell: bash - run: | - curl -fsSL \ - "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-amd64.exe" \ - -o /tmp/python-installer.exe - - xvfb-run -a wine64 /tmp/python-installer.exe \ - /quiet \ - InstallAllUsers=1 \ - PrependPath=1 \ - Include_pip=1 \ - Include_test=0 \ - SimpleInstall=1 \ - "TargetDir=${PYTHON_DIR}" - - wineserver -w - rm -f /tmp/python-installer.exe - xvfb-run -a wine64 "${PYTHON_EXE}" --version - - - name: Install dependencies - shell: bash - run: | - xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --upgrade pip setuptools wheel - - if [ -f requirements.txt ]; then - xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --no-cache-dir -r requirements.txt - fi - - xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --no-cache-dir \ - pyinstaller \ - keyboard \ - pywin32 - - xvfb-run -a wine64 "${PYTHON_EXE}" -c "import keyboard, win32api, win32gui; print('dependencies ok')" - - - name: Build EXE - shell: bash - run: | - xvfb-run -a wine64 "${PYTHON_EXE}" -m PyInstaller \ - --noconfirm \ - --clean \ - --onefile \ - --windowed \ - --name "${APP_NAME}" \ - main.py - - test -f "dist/${APP_NAME}.exe" - - - name: Package build - id: package - shell: bash - run: | - if [[ "$GITHUB_REF" == refs/tags/* ]]; then - version="$GITHUB_REF_NAME" - else - version="run-${GITHUB_RUN_NUMBER}-${GITHUB_SHA::7}" - fi - - archive_name="${APP_NAME}-${version}-windows-x64.zip" - archive_path="dist/${archive_name}" - - zip -j "$archive_path" "dist/${APP_NAME}.exe" - - echo "version=${version}" >> "$GITHUB_OUTPUT" - echo "archive_name=${archive_name}" >> "$GITHUB_OUTPUT" - echo "archive_path=${archive_path}" >> "$GITHUB_OUTPUT" - - - name: Upload package to Gitea Packages - id: publish_package - shell: bash - env: - ACTIONS_TOKEN: ${{ github.token }} - run: | - owner="${GITHUB_REPOSITORY%%/*}" - package_url="${GITHUB_SERVER_URL}/api/packages/${owner}/generic/${PACKAGE_NAME}/${{ steps.package.outputs.version }}/${{ steps.package.outputs.archive_name }}" - - curl --fail-with-body --silent --show-error \ - -X PUT \ - -H "Authorization: token ${ACTIONS_TOKEN}" \ - -H "Content-Type: application/zip" \ - --upload-file "${{ steps.package.outputs.archive_path }}" \ - "$package_url" - - echo "package_url=${package_url}" >> "$GITHUB_OUTPUT" - if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then - echo "Built package: ${package_url}" >> "$GITHUB_STEP_SUMMARY" - fi - - - name: Create release on tag - if: startsWith(github.ref, 'refs/tags/') - shell: bash - env: - ACTIONS_TOKEN: ${{ github.token }} - run: | - api_url="${GITHUB_API_URL:-${GITHUB_SERVER_URL}/api/v1}" - releases_url="${api_url}/repos/${GITHUB_REPOSITORY}/releases" - tag_name="${GITHUB_REF_NAME}" - release_name="${tag_name}" - body="Windows build package: ${{ steps.publish_package.outputs.package_url }}" - - existing_release_id="$( - curl --silent \ - -H "Authorization: token ${ACTIONS_TOKEN}" \ - "${releases_url}" | jq -r --arg tag "$tag_name" '.[] | select(.tag_name == $tag) | .id' | head -n 1 - )" - - if [ -n "$existing_release_id" ] && [ "$existing_release_id" != "null" ]; then - echo "Release already exists for ${tag_name}, skipping creation." - exit 0 - fi - - payload="$( - jq -n \ - --arg tag_name "$tag_name" \ - --arg target_commitish "$GITHUB_SHA" \ - --arg name "$release_name" \ - --arg body "$body" \ - '{ - tag_name: $tag_name, - target_commitish: $target_commitish, - name: $name, - body: $body, - draft: false, - prerelease: false - }' - )" - - curl --fail-with-body --silent --show-error \ - -X POST \ - -H "Authorization: token ${ACTIONS_TOKEN}" \ - -H "Content-Type: application/json" \ - -d "$payload" \ - "$releases_url" > /dev/null - - if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then - echo "Release created for ${tag_name}" >> "$GITHUB_STEP_SUMMARY" - fi From 3646908a0023aa8492a9ecbcc643672257dd9f6c Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 23:51:22 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=86=97=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E6=9E=84=E5=BB=BA=E5=B7=A5=E4=BD=9C=E6=B5=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20build-exe.yml=20=E5=92=8C=20build-exe-Miu.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-exe-Miu.yml | 134 --------------- .github/workflows/build-exe.yml | 245 ---------------------------- 2 files changed, 379 deletions(-) delete mode 100644 .github/workflows/build-exe-Miu.yml delete mode 100644 .github/workflows/build-exe.yml diff --git a/.github/workflows/build-exe-Miu.yml b/.github/workflows/build-exe-Miu.yml deleted file mode 100644 index 8532a49..0000000 --- a/.github/workflows/build-exe-Miu.yml +++ /dev/null @@ -1,134 +0,0 @@ -name: Build Windows EXE with Full Image -on: - push: - # 推荐:只在打标签时触发 Release - tags: - - 'v*' # 例如推送 v1.0.0, v2.1.3 等标签时触发 - # 如果你想在每次推送时都创建,也可以保留 branches,但通常会打 tag - branches: ["main"] - -jobs: - build: - runs-on: Ubuntu_docker_act - steps: - - uses: actions/checkout@v4 - - # 步骤1:下载 Python 3.9.9 安装包(保持文件名一致) - - name: Download Python 3.9.9 installer - run: | - wget https://mirrors.tuna.tsinghua.edu.cn/python/3.9.9/python-3.9.9-amd64.exe - ls -lh python-3.9.9-amd64.exe - # 验证文件完整性 - file python-3.9.9-amd64.exe - - - name: Reset Wine environment (clean slate) - run: | - echo "=== 备份并删除旧的 Wine 配置目录 ===" - # 如果 ~/.wine 目录存在,先重命名备份(或直接删除) - if [ -d "$HOME/.wine" ]; then - mv "$HOME/.wine" "$HOME/.wine.bak.$(date +%s)" - echo "Old .wine directory backed up." - fi - - echo "=== 初始化一个新的干净的Wine环境 ===" - # 初始化Wine环境,使用 xvfb-run 避免任何图形界面问题 - # 设置 WINEARCH 为 win64 以支持64位 - export WINEARCH=win64 - xvfb-run wineboot -u - - echo "=== 验证新环境 ===" - # 等待几秒让环境初始化完成 - sleep 5 - wine --version - xvfb-run wine cmd /c "echo Wine environment is ready" - - # 步骤3:安装 Python(使用正确的文件名) - - name: Install Python in Wine - run: | - echo "Current directory: $(pwd)" - ls -lah - - if [ ! -f python-3.9.9-amd64.exe ]; then - echo "Installer not found!" - exit 1 - fi - - # 直接用 wine 运行 - xvfb-run -a wine python-3.9.9-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 - - # 等待安装 - sleep 20 - - # 步骤4:更彻底地查找 Python - - name: Find and verify Python - run: | - echo "=== Searching all possible Python locations ===" - # 查找所有 python.exe - find /root/.wine/drive_c -name "python.exe" 2>/dev/null | while read path; do - echo "Found: $path" - echo "Version info:" - wine "$path" --version 2>/dev/null || echo "Cannot run $path" - done - - # 尝试常见路径 - COMMON_PATHS=( - "/root/.wine/drive_c/Python39/python.exe" - "/root/.wine/drive_c/Python39-32/python.exe" - "/root/.wine/drive_c/Program Files/Python39/python.exe" - "/root/.wine/drive_c/users/runner/AppData/Local/Programs/Python/Python39/python.exe" - ) - - for path in "${COMMON_PATHS[@]}"; do - if [ -f "$path" ]; then - echo "Found Python at standard location: $path" - PYTHON_EXE="$path" - break - fi - done - - if [ -z "$PYTHON_EXE" ]; then - echo "Python not found in standard locations" - exit 1 - fi - - echo "PYTHON_EXE=$PYTHON_EXE" >> $GITHUB_ENV - wine "$PYTHON_EXE" --version - - # 步骤5:安装依赖 - - name: Install dependencies - run: | - # 先配置 pip 使用清华源(或其他国内源) - wine "$PYTHON_EXE" -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple - wine "$PYTHON_EXE" -m pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn - # 升级 pip - wine "$PYTHON_EXE" -m pip install --upgrade pip - # 安装包 - wine "$PYTHON_EXE" -m pip install pyinstaller keyboard pywin32 - - # 步骤6:构建 EXE - - name: Build EXE - run: | - wine "$PYTHON_EXE" -m PyInstaller --onefile --windowed --name Shortcut_Sync_PotPlayer main.py - - # 步骤7:上传构建产物(修复版本) - - name: Upload Artifact - uses: christopherhx/gitea-upload-artifact@v4 # 关键修复! - with: - name: Shortcut_Sync_PotPlayer - path: dist/Shortcut_Sync_PotPlayer.exe - - - name: Create Release and Upload Asset - # 使用专门为 Gitea 开发的 release action - # 这是一个在 Gitea 生态中广泛使用的版本 [citation:2][citation:5] - uses: https://gitea.com/actions/release-action@main - with: - # 文件路径:指向你 PyInstaller 生成的 EXE 文件 - files: dist/Shortcut_Sync_PotPlayer.exe - # API 密钥:使用 Gitea 自动提供的 token,用于认证 - api_key: '${{ secrets.GITHUB_TOKEN }}' - # 可选:设置 Release 的标题,默认会使用 tag 名称 - name: 'Release ${{ github.ref_name }}' - # 可选:是否为草稿 (true/false) - draft: false - # 可选:是否为预发布 (true/false) - prerelease: false \ No newline at end of file diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml deleted file mode 100644 index 43cea70..0000000 --- a/.github/workflows/build-exe.yml +++ /dev/null @@ -1,245 +0,0 @@ -name: Build Windows EXE - -on: - push: - workflow_dispatch: - -env: - APP_NAME: Shortcut_Sync_PotPlayer - PACKAGE_NAME: shortcut-sync-potplayer - PYTHON_VERSION: "3.9.1" - PYTHON_DIR: 'C:\Python391' - PYTHON_EXE: 'C:\Python391\python.exe' - -jobs: - build: - runs-on: ubuntu-22.04 - - steps: - - name: Checkout repository - shell: bash - env: - ACTIONS_TOKEN: ${{ github.token }} - GIT_TERMINAL_PROMPT: 0 - run: | - pwd - ls -la - - if [ -f main.py ]; then - echo "Repository already available in workspace." - exit 0 - fi - - if ! command -v git >/dev/null 2>&1; then - sudo apt-get update - sudo apt-get install -y --no-install-recommends git ca-certificates - fi - - repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" - - if [ ! -d .git ]; then - git init . - fi - - git config --global --add safe.directory "$PWD" - - if git remote get-url origin >/dev/null 2>&1; then - git remote set-url origin "$repo_url" - else - git remote add origin "$repo_url" - fi - - fetch_target() { - local target="$1" - git fetch --depth=1 origin "$target" - } - - fetch_with_basic_auth() { - local target="$1" - local username="$2" - local auth_header - auth_header="$(printf '%s:%s' "$username" "${ACTIONS_TOKEN}" | base64 -w0)" - git \ - -c http.extraHeader="Authorization: Basic ${auth_header}" \ - fetch --depth=1 origin "$target" - } - - if fetch_target "${GITHUB_SHA}" || fetch_target "${GITHUB_REF}"; then - echo "Fetched repository without authentication." - elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "${GITHUB_ACTOR:-git}" || fetch_with_basic_auth "${GITHUB_REF}" "${GITHUB_ACTOR:-git}"); then - echo "Fetched repository with actor token authentication." - elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "oauth2" || fetch_with_basic_auth "${GITHUB_REF}" "oauth2"); then - echo "Fetched repository with oauth2 token authentication." - elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "git" || fetch_with_basic_auth "${GITHUB_REF}" "git"); then - echo "Fetched repository with git token authentication." - else - echo "Failed to fetch repository contents from ${repo_url}." - exit 1 - fi - - git checkout --force FETCH_HEAD - git log -1 --oneline - test -f main.py - - - name: Setup Wine - shell: bash - run: | - WINEPREFIX="$RUNNER_TEMP/wine" - echo "WINEPREFIX=$WINEPREFIX" >> "$GITHUB_ENV" - echo "WINEDEBUG=-all" >> "$GITHUB_ENV" - export WINEPREFIX - export WINEDEBUG=-all - - sudo dpkg --add-architecture i386 - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - wine64 \ - wine32 \ - curl \ - ca-certificates \ - jq \ - xvfb \ - zip - - xvfb-run -a wine64 wineboot --init - wineserver -w - wine64 --version - - - name: Install Windows Python - shell: bash - run: | - curl -fsSL \ - "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-amd64.exe" \ - -o /tmp/python-installer.exe - - xvfb-run -a wine64 /tmp/python-installer.exe \ - /quiet \ - InstallAllUsers=1 \ - PrependPath=1 \ - Include_pip=1 \ - Include_test=0 \ - SimpleInstall=1 \ - "TargetDir=${PYTHON_DIR}" - - wineserver -w - rm -f /tmp/python-installer.exe - xvfb-run -a wine64 "${PYTHON_EXE}" --version - - - name: Install dependencies - shell: bash - run: | - xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --upgrade pip setuptools wheel - - if [ -f requirements.txt ]; then - xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --no-cache-dir -r requirements.txt - fi - - xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --no-cache-dir \ - pyinstaller \ - keyboard \ - pywin32 - - xvfb-run -a wine64 "${PYTHON_EXE}" -c "import keyboard, win32api, win32gui; print('dependencies ok')" - - - name: Build EXE - shell: bash - run: | - xvfb-run -a wine64 "${PYTHON_EXE}" -m PyInstaller \ - --noconfirm \ - --clean \ - --onefile \ - --windowed \ - --name "${APP_NAME}" \ - main.py - - test -f "dist/${APP_NAME}.exe" - - - name: Package build - id: package - shell: bash - run: | - if [[ "$GITHUB_REF" == refs/tags/* ]]; then - version="$GITHUB_REF_NAME" - else - version="run-${GITHUB_RUN_NUMBER}-${GITHUB_SHA::7}" - fi - - archive_name="${APP_NAME}-${version}-windows-x64.zip" - archive_path="dist/${archive_name}" - - zip -j "$archive_path" "dist/${APP_NAME}.exe" - - echo "version=${version}" >> "$GITHUB_OUTPUT" - echo "archive_name=${archive_name}" >> "$GITHUB_OUTPUT" - echo "archive_path=${archive_path}" >> "$GITHUB_OUTPUT" - - - name: Upload package to Gitea Packages - id: publish_package - shell: bash - env: - ACTIONS_TOKEN: ${{ github.token }} - run: | - owner="${GITHUB_REPOSITORY%%/*}" - package_url="${GITHUB_SERVER_URL}/api/packages/${owner}/generic/${PACKAGE_NAME}/${{ steps.package.outputs.version }}/${{ steps.package.outputs.archive_name }}" - - curl --fail-with-body --silent --show-error \ - -X PUT \ - -H "Authorization: token ${ACTIONS_TOKEN}" \ - -H "Content-Type: application/zip" \ - --upload-file "${{ steps.package.outputs.archive_path }}" \ - "$package_url" - - echo "package_url=${package_url}" >> "$GITHUB_OUTPUT" - if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then - echo "Built package: ${package_url}" >> "$GITHUB_STEP_SUMMARY" - fi - - - name: Create release on tag - if: startsWith(github.ref, 'refs/tags/') - shell: bash - env: - ACTIONS_TOKEN: ${{ github.token }} - run: | - api_url="${GITHUB_API_URL:-${GITHUB_SERVER_URL}/api/v1}" - releases_url="${api_url}/repos/${GITHUB_REPOSITORY}/releases" - tag_name="${GITHUB_REF_NAME}" - release_name="${tag_name}" - body="Windows build package: ${{ steps.publish_package.outputs.package_url }}" - - existing_release_id="$( - curl --silent \ - -H "Authorization: token ${ACTIONS_TOKEN}" \ - "${releases_url}" | jq -r --arg tag "$tag_name" '.[] | select(.tag_name == $tag) | .id' | head -n 1 - )" - - if [ -n "$existing_release_id" ] && [ "$existing_release_id" != "null" ]; then - echo "Release already exists for ${tag_name}, skipping creation." - exit 0 - fi - - payload="$( - jq -n \ - --arg tag_name "$tag_name" \ - --arg target_commitish "$GITHUB_SHA" \ - --arg name "$release_name" \ - --arg body "$body" \ - '{ - tag_name: $tag_name, - target_commitish: $target_commitish, - name: $name, - body: $body, - draft: false, - prerelease: false - }' - )" - - curl --fail-with-body --silent --show-error \ - -X POST \ - -H "Authorization: token ${ACTIONS_TOKEN}" \ - -H "Content-Type: application/json" \ - -d "$payload" \ - "$releases_url" > /dev/null - - if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then - echo "Release created for ${tag_name}" >> "$GITHUB_STEP_SUMMARY" - fi