From 479fc155f75dc7ec2a6c1137f0b6e5f920c54dd0 Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 11:15:17 +0800 Subject: [PATCH 1/5] =?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 2/5] =?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 3/5] 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 4/5] 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 5/5] 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: |