-
Notifications
You must be signed in to change notification settings - Fork 4
227 lines (195 loc) · 7.39 KB
/
build-python-version.yml
File metadata and controls
227 lines (195 loc) · 7.39 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: Build Python Version
on:
workflow_call:
inputs:
python_version:
description: Full Python version (e.g. 3.13.12)
required: true
type: string
workflow_dispatch:
inputs:
python_version:
description: Full Python version (e.g. 3.13.12)
required: true
type: choice
options:
- 3.12.13
- 3.13.13
- 3.14.5
env:
PYTHON_VERSION: ${{ inputs.python_version || github.event.inputs.python_version }}
# Optional override: pin a specific python-build-standalone release date
# (https://github.com/astral-sh/python-build-standalone/releases). When empty,
# linux/package-for-linux.sh auto-resolves the newest release for PYTHON_VERSION.
PYTHON_DIST_RELEASE: ""
permissions:
contents: read
jobs:
build-darwin:
name: Build Python for iOS and macOS
runs-on: macos-26
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Derive short Python version
shell: bash
run: |
echo "PYTHON_VERSION_SHORT=$(echo "$PYTHON_VERSION" | cut -d. -f1,2)" >> "$GITHUB_ENV"
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION_SHORT }}
- name: Build Python for iOS and macOS
working-directory: darwin
shell: bash
run: |
mkdir -p dist
# iOS: 3.14+ uses CPython's in-tree Apple tooling, 3.13 builds from source per
# iOS/README.rst, 3.12 uses beeware. Emits normalized ./install + ./support.
python build_ios.py "$PYTHON_VERSION"
# mobile-forge artifact: iOS-only install+support tree (same structure as before).
# Captured before the macOS build also writes into ./support / ./install.
tar -czf dist/python-ios-mobile-forge-$PYTHON_VERSION_SHORT.tar.gz install support
# macOS: universal2 framework built from source (all versions).
python build_macos.py "$PYTHON_VERSION"
bash ./package-ios-for-dart.sh . "$PYTHON_VERSION_SHORT"
bash ./package-macos-for-dart.sh . "$PYTHON_VERSION_SHORT"
- name: Upload Darwin build artifacts
uses: actions/upload-artifact@v4
with:
name: python-darwin-${{ env.PYTHON_VERSION_SHORT }}
path: darwin/dist/python-*.tar.gz
if-no-files-found: error
build-android:
name: Build Python for Android
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Derive short Python version
shell: bash
run: |
echo "PYTHON_VERSION_SHORT=$(echo "$PYTHON_VERSION" | cut -d. -f1,2)" >> "$GITHUB_ENV"
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Run pre-build tests
shell: bash
env:
PYTHON_VERSION_SHORT: ${{ env.PYTHON_VERSION_SHORT }}
MOBILE_FORGE_TEST_PHASE: pre_build
run: python3 -m unittest discover -s android/tests -t android/tests -v
- working-directory: android
shell: bash
run: |
bash ./build-all.sh "$PYTHON_VERSION"
mkdir -p dist
tar -czf dist/python-android-mobile-forge-$PYTHON_VERSION_SHORT.tar.gz install support
bash ./package-for-dart.sh install "$PYTHON_VERSION" arm64-v8a
bash ./package-for-dart.sh install "$PYTHON_VERSION" x86_64
read version_major version_minor < <(echo "$PYTHON_VERSION" | sed -E 's/^([0-9]+)\.([0-9]+).*/\1 \2/')
version_int=$((version_major * 100 + version_minor))
if [ $version_int -lt 313 ]; then
bash ./package-for-dart.sh install "$PYTHON_VERSION" armeabi-v7a
fi
- name: Run post-build tests
shell: bash
env:
PYTHON_VERSION_SHORT: ${{ env.PYTHON_VERSION_SHORT }}
MOBILE_FORGE_TEST_PHASE: post_build
MOBILE_FORGE_INSTALL_TREE: ${{ github.workspace }}/android/install
run: python3 -m unittest discover -s android/tests -t android/tests -v
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: python-android-${{ env.PYTHON_VERSION_SHORT }}
path: android/dist/python-android-*.tar.gz
if-no-files-found: error
build-linux:
name: Build Python for Linux
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Derive short Python version
shell: bash
run: |
echo "PYTHON_VERSION_SHORT=$(echo "$PYTHON_VERSION" | cut -d. -f1,2)" >> "$GITHUB_ENV"
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- working-directory: linux
shell: bash
env:
# Lets resolve_pbs.py authenticate to the GitHub API and avoid rate limits.
GITHUB_TOKEN: ${{ github.token }}
run: |
bash ./package-for-linux.sh x86_64 "_v2"
bash ./package-for-linux.sh aarch64 ""
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: python-linux-${{ env.PYTHON_VERSION_SHORT }}
path: linux/python-linux-dart-*.tar.gz
if-no-files-found: error
build-windows:
name: Build Python for Windows
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Derive short Python version
shell: pwsh
run: |
$parts = "${{ env.PYTHON_VERSION }}".Split(".")
"PYTHON_VERSION_SHORT=$($parts[0]).$($parts[1])" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION_SHORT }}
- name: Build CPython from sources and package for Dart
shell: pwsh
run: |
.\windows\package-for-dart.ps1 `
-PythonVersion "${{ env.PYTHON_VERSION }}" `
-PythonVersionShort "${{ env.PYTHON_VERSION_SHORT }}"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: python-windows-${{ env.PYTHON_VERSION_SHORT }}
path: windows/python-windows-for-dart-*.zip
if-no-files-found: error
publish-release:
name: Publish Release Assets
runs-on: ubuntu-latest
# Only publish GitHub release assets from the main branch; other branches still
# build (and upload per-job artifacts) but don't touch releases.
if: github.ref == 'refs/heads/main'
needs:
- build-darwin
- build-android
- build-linux
- build-windows
permissions:
contents: write
steps:
- name: Derive short Python version
shell: bash
run: |
echo "PYTHON_VERSION_SHORT=$(echo "$PYTHON_VERSION" | cut -d. -f1,2)" >> "$GITHUB_ENV"
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
pattern: python-*-${{ env.PYTHON_VERSION_SHORT }}
path: release-artifacts
merge-multiple: true
- name: Publish all artifacts to release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.PYTHON_VERSION_SHORT }}
files: release-artifacts/*
fail_on_unmatched_files: true
generate_release_notes: false
draft: false
prerelease: false