forked from Xingshu/Shortcut_Sync_PotPlayer
修改工作流
This commit is contained in:
135
.github/workflows/build-exe.yml
vendored
135
.github/workflows/build-exe.yml
vendored
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user