-
Notifications
You must be signed in to change notification settings - Fork 55
165 lines (143 loc) · 5.61 KB
/
Copy pathbuild-app.yml
File metadata and controls
165 lines (143 loc) · 5.61 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Build standalone app
on:
push:
tags: ['v*']
workflow_dispatch:
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-14
artifact: Raytracing-macOS-arm64
- os: windows-latest
artifact: Raytracing-Windows
- os: ubuntu-22.04
artifact: Raytracing-Linux
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # setuptools_scm needs full history + tags
- uses: actions/setup-python@v5
with:
# 3.12 (not 3.11) — mytk warns about a UI quirk in the Tk
# bindings shipped with python.org's 3.11 build on macOS
# Sonoma. 3.12 ships a Tk that doesn't trip it.
python-version: '3.12'
- name: Install Tk (Linux only)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y python3-tk
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[gui]"
pip install pyperclip pillow pyinstaller
- name: Build with PyInstaller
# --collect-submodules PIL: mytk loads PIL.ImageDraw / PIL.ImageTk
# via importlib.import_module(), which PyInstaller's static analyzer
# cannot follow. Without this flag the bundled app prompts the user
# to "install the missing module 'ImageDraw'" on first launch.
run: pyinstaller --windowed --name Raytracing --noconfirm
--collect-submodules PIL
--distpath packaging/dist --workpath packaging/build
raytracing/ui/raytracing_app.py
- name: Sign and notarize (macOS)
if: runner.os == 'macOS'
env:
CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.MACOS_NOTARY_APPLE_ID }}
TEAM_ID: ${{ secrets.MACOS_NOTARY_TEAMID }}
APP_PWD: ${{ secrets.MACOS_NOTARY_PWD }}
run: |
# Import certificate into a temporary keychain
KEYCHAIN=build.keychain
KEYCHAIN_PWD=$(uuidgen)
security create-keychain -p "$KEYCHAIN_PWD" "$KEYCHAIN"
security default-keychain -s "$KEYCHAIN"
security unlock-keychain -p "$KEYCHAIN_PWD" "$KEYCHAIN"
echo "$CERTIFICATE" | base64 --decode > cert.p12
security import cert.p12 -k "$KEYCHAIN" -P "$CERTIFICATE_PWD" \
-T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: \
-s -k "$KEYCHAIN_PWD" "$KEYCHAIN"
rm cert.p12
# Sign the .app bundle
codesign --deep --force --options runtime --timestamp \
--sign "$IDENTITY" packaging/dist/Raytracing.app
# Notarize (Apple checks the binary, typically 1-5 min)
ditto -c -k --keepParent packaging/dist/Raytracing.app \
/tmp/Raytracing-notarize.zip
xcrun notarytool submit /tmp/Raytracing-notarize.zip \
--apple-id "$APPLE_ID" --team-id "$TEAM_ID" \
--password "$APP_PWD" --wait
# Staple the ticket so Gatekeeper works offline
xcrun stapler staple packaging/dist/Raytracing.app
- name: Package macOS .app as zip
if: runner.os == 'macOS'
working-directory: packaging/dist
run: ditto -c -k --keepParent Raytracing.app Raytracing-macOS.zip
- name: Package Windows folder as zip
if: runner.os == 'Windows'
working-directory: packaging/dist
run: Compress-Archive -Path Raytracing -DestinationPath Raytracing-Windows.zip
- name: Package Linux folder as tar.gz
if: runner.os == 'Linux'
working-directory: packaging/dist
run: tar -czf Raytracing-Linux.tar.gz Raytracing
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
packaging/dist/Raytracing-macOS.zip
packaging/dist/Raytracing-Windows.zip
packaging/dist/Raytracing-Linux.tar.gz
if-no-files-found: ignore
release:
name: Attach to GitHub Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- uses: softprops/action-gh-release@v2
with:
files: artifacts/*
fail_on_unmatched_files: false
pypi:
# Done here (not in pythonpublish.yml) because GitHub does not fire
# downstream `release` events for releases created with GITHUB_TOKEN,
# so the softprops action above can't trigger a separate publish
# workflow. Keeping everything in one workflow side-steps that.
name: Publish to PyPI
needs: release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # setuptools_scm needs full history + tags
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build sdist and wheel
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*