Repository navigation
87 lines (71 loc) · 2.9 KB
/
Copy pathcreate_windows_binary.yml
File metadata and controls
87 lines (71 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Checks BiaPy code consistency
name: Create Windows binary
on:
workflow_dispatch:
release:
types: [published]
jobs:
run:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip" # caching pip dependencies
- name: Installing BiaPy-GUI dependencies
run: pip install -r requirements.txt
- name: Creating Windows binary
run: |
cp dist-win/main.spec main.spec
pyinstaller.exe main.spec
- name: Check dist folder contents
run: |
echo "== dist tree =="
ls -R dist || true
- name: Exclude dist/temp from Windows Defender scanning
shell: pwsh
run: |
# Onefile PyInstaller builds self-extract their whole dependency tree
# (torch, numpy, PySide6, ...) into %TEMP% on first run; with Defender's
# real-time scan active this can take minutes and looks like a hang.
Add-MpPreference -ExclusionPath "$env:TEMP"
Add-MpPreference -ExclusionPath "${{ github.workspace }}\dist"
- name: Smoke test Windows binary
shell: bash
env:
PYTHONUNBUFFERED: "1"
run: python -u scripts/smoke_test_binary.py "dist/BiaPy.exe" --timeout 300
- name: Upload dist/BiaPy to Google Drive (Python method)
shell: bash
env:
FOLDER_ID: ${{ secrets.FOLDER_FOR_NEW_BINARIES }}
PYTHONUTF8: "1" # or PYTHONIOENCODING: "utf-8"
run: |
# Install Google API client
python -m pip install --quiet google-api-python-client google-auth google-auth-httplib2 google-auth-oauthlib
# Decode your base64 credentials into a JSON file
echo "${{ secrets.DRIVE_CREDENTIALS }}" | base64 -d > sa.json
# Run the upload script
python - <<'PY'
import os, mimetypes
from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
FOLDER_ID = os.environ["FOLDER_ID"]
PATH = "dist/BiaPy.exe"
# Authorize with service account
creds = Credentials.from_service_account_file(
"sa.json",
scopes=["https://www.googleapis.com/auth/drive"]
)
service = build("drive", "v3", credentials=creds, cache_discovery=False)
# Upload file (or folder as zip)
name = os.path.basename(PATH.rstrip("/"))
mime_type = mimetypes.guess_type(PATH)[0] or "application/octet-stream"
media = MediaFileUpload(PATH, mimetype=mime_type, resumable=True)
file_metadata = {"name": name, "parents": [FOLDER_ID]}
print(f"Uploading {PATH} to folder {FOLDER_ID} ...")
file = service.files().create(body=file_metadata, media_body=media, fields="id,name").execute()
print(f"✅ Uploaded {file['name']} with id {file['id']}")
PY