mirror of
https://github.com/blw1138/Zordon.git
synced 2026-06-09 13:39:24 -05:00
Fix create-executables.yml workflow to upload output to release page
This commit is contained in:
@@ -5,6 +5,9 @@ on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build executables (${{ matrix.os }})
|
||||
@@ -45,22 +48,57 @@ jobs:
|
||||
- name: Build server
|
||||
run: pyinstaller --clean server.spec
|
||||
|
||||
- name: Upload client artifact
|
||||
- name: Package build outputs
|
||||
shell: bash
|
||||
env:
|
||||
ARTIFACT_SUFFIX: ${{ matrix.artifact_suffix }}
|
||||
run: |
|
||||
python - <<'PY'
|
||||
from pathlib import Path
|
||||
import os
|
||||
import zipfile
|
||||
|
||||
suffix = os.environ['ARTIFACT_SUFFIX']
|
||||
dist_dir = Path('dist')
|
||||
asset_dir = Path('release-assets')
|
||||
asset_dir.mkdir(exist_ok=True)
|
||||
|
||||
for app_name in ('Zordon-client', 'Zordon-server'):
|
||||
source = next(
|
||||
(
|
||||
path for path in (
|
||||
dist_dir / f'{app_name}.exe',
|
||||
dist_dir / f'{app_name}.app',
|
||||
dist_dir / app_name,
|
||||
)
|
||||
if path.exists()
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
||||
if source is None:
|
||||
raise FileNotFoundError(f'Could not find PyInstaller output for {app_name}')
|
||||
|
||||
zip_path = asset_dir / f'{app_name}-{suffix}.zip'
|
||||
with zipfile.ZipFile(zip_path, 'w', compression=zipfile.ZIP_DEFLATED) as zip_file:
|
||||
if source.is_dir():
|
||||
for file_path in source.rglob('*'):
|
||||
if file_path.is_file():
|
||||
zip_file.write(file_path, source.name / file_path.relative_to(source))
|
||||
else:
|
||||
zip_file.write(source, source.name)
|
||||
PY
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Zordon-client-${{ matrix.artifact_suffix }}
|
||||
path: |
|
||||
dist/Zordon-client
|
||||
dist/Zordon-client.exe
|
||||
dist/Zordon-client.app
|
||||
name: Zordon-build-${{ matrix.artifact_suffix }}
|
||||
path: release-assets/*.zip
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload server artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Zordon-server-${{ matrix.artifact_suffix }}
|
||||
path: |
|
||||
dist/Zordon-server
|
||||
dist/Zordon-server.exe
|
||||
dist/Zordon-server.app
|
||||
if-no-files-found: error
|
||||
- name: Attach assets to release
|
||||
if: github.event_name == 'release'
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: gh release upload "${{ github.event.release.tag_name }}" release-assets/*.zip --clobber
|
||||
|
||||
Reference in New Issue
Block a user