This commit is contained in:
130
.github/workflows/build-exe.yml
vendored
130
.github/workflows/build-exe.yml
vendored
@@ -4,10 +4,9 @@ on:
|
|||||||
push:
|
push:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
APP_NAME: Shortcut_Sync_PotPlayer
|
||||||
|
PACKAGE_NAME: shortcut-sync-potplayer
|
||||||
PYTHON_VERSION: "3.9.1"
|
PYTHON_VERSION: "3.9.1"
|
||||||
PYTHON_DIR: 'C:\Python391'
|
PYTHON_DIR: 'C:\Python391'
|
||||||
PYTHON_EXE: 'C:\Python391\python.exe'
|
PYTHON_EXE: 'C:\Python391\python.exe'
|
||||||
@@ -15,12 +14,18 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
outputs:
|
|
||||||
archive_name: ${{ steps.archive.outputs.archive_name }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Verify workspace
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Setup Wine
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -38,6 +43,7 @@ jobs:
|
|||||||
wine32 \
|
wine32 \
|
||||||
curl \
|
curl \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
|
jq \
|
||||||
xvfb \
|
xvfb \
|
||||||
zip
|
zip
|
||||||
|
|
||||||
@@ -65,7 +71,7 @@ jobs:
|
|||||||
rm -f /tmp/python-installer.exe
|
rm -f /tmp/python-installer.exe
|
||||||
xvfb-run -a wine64 "${PYTHON_EXE}" --version
|
xvfb-run -a wine64 "${PYTHON_EXE}" --version
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --upgrade pip setuptools wheel
|
xvfb-run -a wine64 "${PYTHON_EXE}" -m pip install --upgrade pip setuptools wheel
|
||||||
@@ -89,47 +95,97 @@ jobs:
|
|||||||
--clean \
|
--clean \
|
||||||
--onefile \
|
--onefile \
|
||||||
--windowed \
|
--windowed \
|
||||||
--name Shortcut_Sync_PotPlayer \
|
--name "${APP_NAME}" \
|
||||||
main.py
|
main.py
|
||||||
|
|
||||||
test -f dist/Shortcut_Sync_PotPlayer.exe
|
test -f "dist/${APP_NAME}.exe"
|
||||||
|
|
||||||
- name: Package artifact
|
- name: Package build
|
||||||
id: archive
|
id: package
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
||||||
version="$GITHUB_REF_NAME"
|
version="$GITHUB_REF_NAME"
|
||||||
else
|
else
|
||||||
version="run-${GITHUB_RUN_NUMBER}"
|
version="run-${GITHUB_RUN_NUMBER}-${GITHUB_SHA::7}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
archive_name="Shortcut_Sync_PotPlayer-${version}-windows-x64.zip"
|
archive_name="${APP_NAME}-${version}-windows-x64.zip"
|
||||||
zip -j "dist/${archive_name}" "dist/Shortcut_Sync_PotPlayer.exe"
|
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_name=${archive_name}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "archive_path=${archive_path}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload package to Gitea Packages
|
||||||
uses: actions/upload-artifact@v4
|
id: publish_package
|
||||||
with:
|
shell: bash
|
||||||
name: windows-exe-package
|
env:
|
||||||
path: dist/${{ steps.archive.outputs.archive_name }}
|
ACTIONS_TOKEN: ${{ github.token }}
|
||||||
retention-days: 30
|
run: |
|
||||||
if-no-files-found: error
|
owner="${GITHUB_REPOSITORY%%/*}"
|
||||||
|
package_url="${GITHUB_SERVER_URL}/api/packages/${owner}/generic/${PACKAGE_NAME}/${{ steps.package.outputs.version }}/${{ steps.package.outputs.archive_name }}"
|
||||||
|
|
||||||
release:
|
curl --fail-with-body --silent --show-error \
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
-X PUT \
|
||||||
needs: build
|
-H "Authorization: token ${ACTIONS_TOKEN}" \
|
||||||
runs-on: ubuntu-22.04
|
-H "Content-Type: application/zip" \
|
||||||
|
--upload-file "${{ steps.package.outputs.archive_path }}" \
|
||||||
|
"$package_url"
|
||||||
|
|
||||||
steps:
|
echo "package_url=${package_url}" >> "$GITHUB_OUTPUT"
|
||||||
- name: Download packaged artifact
|
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
|
||||||
uses: actions/download-artifact@v4
|
echo "Built package: ${package_url}" >> "$GITHUB_STEP_SUMMARY"
|
||||||
with:
|
fi
|
||||||
name: windows-exe-package
|
|
||||||
path: release-assets
|
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create release on tag
|
||||||
uses: softprops/action-gh-release@v2
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
shell: bash
|
||||||
files: release-assets/${{ needs.build.outputs.archive_name }}
|
env:
|
||||||
generate_release_notes: true
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user