Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 47 additions & 26 deletions .github/workflows/build-python-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ env:
PYTHON_VERSION: ${{ inputs.python_version || github.event.inputs.python_version }}
PYTHON_DIST_RELEASE: 20260203 # https://github.com/astral-sh/python-build-standalone/releases

permissions:
contents: read

Comment thread
ndonkoHenri marked this conversation as resolved.
jobs:
build-darwin:
name: Build Python for iOS and macOS
runs-on: macos-15
permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Derive short Python version
shell: bash
run: |
Expand All @@ -42,9 +43,6 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION_SHORT }}

- name: Show Python version
run: python --version

- name: Build Python for iOS and macOS
working-directory: darwin
shell: bash
Expand All @@ -71,18 +69,27 @@ jobs:
build-android:
name: Build Python for Android
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- 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"
- uses: actions/setup-python@v6

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: 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: |
Expand All @@ -96,7 +103,17 @@ jobs:
if [ $version_int -lt 313 ]; then
bash ./package-for-dart.sh install "$PYTHON_VERSION" armeabi-v7a
fi
- uses: actions/upload-artifact@v4

- 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
Expand All @@ -105,24 +122,28 @@ jobs:
build-linux:
name: Build Python for Linux
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- 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"
- uses: actions/setup-python@v6

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: python --version

- working-directory: linux
shell: bash
run: |
bash ./package-for-linux.sh x86_64 "_v2"
bash ./package-for-linux.sh aarch64 ""
- uses: actions/upload-artifact@v4

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: python-linux-${{ env.PYTHON_VERSION_SHORT }}
path: linux/python-linux-dart-*.tar.gz
Expand All @@ -131,31 +152,29 @@ jobs:
build-windows:
name: Build Python for Windows
runs-on: windows-2022
permissions:
contents: write
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: Show Python version
shell: pwsh
run: |
python --version
python -c "import sys; print(sys.executable)"

- 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 }}"
- uses: actions/upload-artifact@v4

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: python-windows-${{ env.PYTHON_VERSION_SHORT }}
path: windows/python-windows-for-dart-*.zip
Expand All @@ -169,13 +188,15 @@ jobs:
- build-android
- build-linux
- build-windows
if: github.ref == 'refs/heads/main'
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:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ name: Build Python Packages

on:
push:
branches:
- '**'
pull_request:
workflow_dispatch:
Comment thread
ndonkoHenri marked this conversation as resolved.

# Cancel in-flight runs when a newer event arrives for the same logical branch.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
build-matrix:
name: Build Python ${{ matrix.python_version }}
Expand Down
Loading
Loading