forked from beeware/mobile-forge
-
Notifications
You must be signed in to change notification settings - Fork 6
154 lines (132 loc) · 5.41 KB
/
build-wheels.yml
File metadata and controls
154 lines (132 loc) · 5.41 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
name: Build wheels
on:
push:
pull_request:
workflow_dispatch:
inputs:
archs:
description: "Architectures (comma-separated, e.g. android,iOS)"
required: false
default: "android,iOS"
packages:
description: "Packages (comma-separated, e.g. pillow:11.1.0,pydantic-core:2.33.2)"
required: false
default: "pydantic-core:2.33.2"
build_number:
description: "Build number"
required: false
default: "1"
env:
PYTHON_VERSION: "3.12.12"
PYTHON_SHORT_VERSION: "3.12"
MOBILE_FORGE_CACHE_DOWNLOADS_OFF: "1"
NDK_VERSION: r27d
jobs:
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
shell: bash
run: |
ARCHS="${{ inputs.archs || 'android,iOS' }}"
PACKAGES="${{ inputs.packages || 'pydantic-core:2.33.2' }}"
BUILD_NUMBER="${{ inputs.build_number || '1' }}"
matrix='{"include":['
first=true
for arch in $(echo "$ARCHS" | tr ',' ' '); do
for pkg in $(echo "$PACKAGES" | tr ',' ' '); do
pkg_name="${pkg%%:*}"
if [ "$first" = true ]; then first=false; else matrix+=','; fi
if [[ "$arch" == "android" ]]; then
runner="ubuntu-latest"
platform="android"
else
runner="macos-latest"
platform="ios"
fi
matrix+="{\"job_name\":\"${platform}: ${pkg_name}\",\"artifact_name\":\"${platform}-${pkg_name}\",\"runner\":\"$runner\",\"platform\":\"$platform\",\"forge_arch\":\"$arch\",\"forge_packages\":\"$pkg\",\"build_number\":\"$BUILD_NUMBER\"}"
done
done
matrix+=']}'
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
build:
needs: setup
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_SHORT_VERSION }}
- name: Build and publish wheels
shell: bash
env:
GEMFURY_TOKEN: ${{ secrets.GEMFURY_TOKEN }}
APPVEYOR_PULL_REQUEST_NUMBER: ""
FORGE_ARCH: ${{ matrix.forge_arch }}
FORGE_PACKAGES: ${{ matrix.forge_packages }}
BUILD_NUMBER: ${{ matrix.build_number }}
PLATFORM: ${{ matrix.platform }}
run: |
set -euxo pipefail
. .ci/common.sh
export MOBILE_FORGE_ANDROID_SUPPORT_PATH=""
export MOBILE_FORGE_IOS_SUPPORT_PATH=""
if [[ "$PLATFORM" == "android" ]]; then
sudo apt-get update
sudo apt-get install -y sqlite3
python_android_dir="$HOME/projects/python-build/android"
curl -#OL "https://github.com/flet-dev/python-build/releases/download/v${PYTHON_SHORT_VERSION}/python-android-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz"
mkdir -p "$python_android_dir"
tar -xzf "python-android-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz" -C "$python_android_dir"
. .ci/install_ndk.sh
curl https://sh.rustup.rs -sSf | sh -s -- -y
. "$HOME/.cargo/env"
export PATH="$PATH:$HOME/.cargo/bin"
rustup target add aarch64-linux-android
rustup target add arm-linux-androideabi
rustup target add x86_64-linux-android
rustup target add i686-linux-android
export MOBILE_FORGE_ANDROID_SUPPORT_PATH="$python_android_dir"
else
python_ios_dir="$HOME/projects/python-build/darwin/Python-Apple-support"
curl -#OL "https://github.com/flet-dev/python-build/releases/download/v${PYTHON_SHORT_VERSION}/python-ios-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz"
mkdir -p "$python_ios_dir"
tar -xzf "python-ios-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz" -C "$python_ios_dir"
curl https://sh.rustup.rs -sSf | sh -s -- -y
. "$HOME/.cargo/env"
export PATH="$PATH:$HOME/.cargo/bin"
rustup target add aarch64-apple-ios
rustup target add aarch64-apple-ios-sim
rustup target add x86_64-apple-ios
export MOBILE_FORGE_IOS_SUPPORT_PATH="$python_ios_dir"
fi
source ./setup.sh "$PYTHON_VERSION"
export PATH="$PATH:$HOME/.cargo/bin"
IFS=' ' read -r -a packages <<< "$FORGE_PACKAGES"
for package in "${packages[@]}"; do
forge "$FORGE_ARCH" "$package:$BUILD_NUMBER"
done
rm -f dist/bzip2-* dist/xz-* dist/openssl-* dist/libffi-*
if compgen -G "dist/*.whl" > /dev/null; then
publish_to_pypi dist/*.whl
fi
- name: Upload logs on success
if: ${{ success() && hashFiles('logs/*.log') != '' }}
uses: actions/upload-artifact@v4
with:
name: logs-${{ matrix.artifact_name }}-${{ github.run_id }}-${{ github.run_attempt }}
path: logs/*.log
- name: Upload errors on failure
if: ${{ failure() && hashFiles('errors/*.log') != '' }}
uses: actions/upload-artifact@v4
with:
name: errors-${{ matrix.artifact_name }}-${{ github.run_id }}-${{ github.run_attempt }}
path: errors/*.log