Skip to content

Commit 3df4180

Browse files
committed
👷 On-demand CI custom build
Make it possible to trigger a build from the CI on demand. The following parameters are configurable on demand: - artifact type (e.g. aab, aar, apk) - arch (comma separated list) - bootstrap (e.g. q2, sdl2, service_library, service_only, webview) - build mode (e.g. debug, release) - operating system (e.g. ubuntu-latest, macos-latest) - requirements (comma separated list) Also bump a few action versions.
1 parent db4059d commit 3df4180

File tree

4 files changed

+114
-5
lines changed

4 files changed

+114
-5
lines changed

.github/workflows/custom-build.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Custom build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
arch:
7+
description: "Comma separated architectures (e.g., armeabi-v7a, arm64-v8a, x86_64, x86)"
8+
required: true
9+
default: "armeabi-v7a,arm64-v8a,x86_64,x86"
10+
artifact:
11+
description: "Artifact type"
12+
required: true
13+
default: "apk"
14+
type: choice
15+
options:
16+
- "aab"
17+
- "aar"
18+
- "apk"
19+
bootstrap:
20+
description: "Bootstrap to use"
21+
required: true
22+
default: "sdl2"
23+
type: choice
24+
options:
25+
- "qt"
26+
- "sdl2"
27+
- "service_library"
28+
- "service_only"
29+
- "webview"
30+
mode:
31+
description: "Build mode"
32+
required: true
33+
default: "debug"
34+
type: choice
35+
options:
36+
- "debug"
37+
- "release"
38+
os:
39+
description: "Operating system to run on"
40+
required: true
41+
default: "ubuntu-latest"
42+
type: choice
43+
options:
44+
- "ubuntu-latest"
45+
- "macos-latest"
46+
requirements:
47+
description: "Comma separated requirements"
48+
required: true
49+
default: "python3,kivy"
50+
51+
env:
52+
APK_ARTIFACT_FILENAME: bdist_unit_tests_app-debug-1.1.apk
53+
AAB_ARTIFACT_FILENAME: bdist_unit_tests_app-release-1.1.aab
54+
AAR_ARTIFACT_FILENAME: bdist_unit_tests_app-release-1.1.aar
55+
PYTHONFORANDROID_PREREQUISITES_INSTALL_INTERACTIVE: 0
56+
57+
jobs:
58+
build:
59+
name: Build test APP [ ${{ github.event.inputs.arch }} | ${{ github.event.inputs.artifact }} | ${{ github.event.inputs.bootstrap }} | ${{ github.event.inputs.mode }} | ${{ github.event.inputs.os }} | ${{ github.event.inputs.requirements }}]
60+
runs-on: ${{ github.event.inputs.os }}
61+
steps:
62+
- name: Checkout python-for-android
63+
uses: actions/checkout@v4
64+
- name: Pull the python-for-android docker image
65+
run: make docker/pull
66+
- name: Build python-for-android docker image
67+
run: make docker/build
68+
- name: Build multi-arch artifact with docker
69+
run: |
70+
docker run --name p4a-latest kivy/python-for-android make ARCH=${{ github.event.inputs.arch }} ARTIFACT=${{ github.event.inputs.artifact }} BOOTSTRAP=${{ github.event.inputs.bootstrap }} MODE=${{ github.event.inputs.mode }} REQUIREMENTS=${{ github.event.inputs.requirements }} testapps-generic
71+
- name: Copy produced artifacts from docker container (*.apk, *.aab)
72+
if: github.event.inputs.bootstrap != 'service_library'
73+
run: |
74+
mkdir -p dist
75+
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/${{ env.APK_ARTIFACT_FILENAME }} dist/ || true
76+
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/${{ env.AAB_ARTIFACT_FILENAME }} dist/ || true
77+
- name: Copy produced artifacts from docker container (*.aar)
78+
if: github.event.inputs.bootstrap == 'service_library'
79+
run: |
80+
mkdir -p dist
81+
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/${{ env.AAR_ARTIFACT_FILENAME }} dist/
82+
- name: Rename artifacts to include the build platform name (*.apk, *.aab, *.aar)
83+
run: |
84+
if [ -f dist/${{ env.APK_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.APK_ARTIFACT_FILENAME }} dist/${{ github.event.inputs.os }}-${{ github.event.inputs.bootstrap }}-${{ env.APK_ARTIFACT_FILENAME }}; fi
85+
if [ -f dist/${{ env.AAB_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAB_ARTIFACT_FILENAME }} dist/${{ github.event.inputs.os }}-${{ github.event.inputs.bootstrap }}-${{ env.AAB_ARTIFACT_FILENAME }}; fi
86+
if [ -f dist/${{ env.AAR_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAR_ARTIFACT_FILENAME }} dist/${{ github.event.inputs.os }}-${{ github.event.inputs.bootstrap }}-${{ env.AAR_ARTIFACT_FILENAME }}; fi
87+
- name: Upload artifacts
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: ${{ github.event.inputs.os }}-${{ github.event.inputs.bootstrap }}-artifacts
91+
path: dist
92+
# Cleanup the container after all steps are done
93+
- name: Cleanup Docker container
94+
run: docker rm p4a-latest
95+
if: always()

.github/workflows/push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Checkout python-for-android
1818
uses: actions/checkout@v4
1919
- name: Set up Python 3.x
20-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@v5
2121
with:
2222
python-version: 3.x
2323
- name: Run flake8
@@ -38,7 +38,7 @@ jobs:
3838
- name: Checkout python-for-android
3939
uses: actions/checkout@v4
4040
- name: Set up Python ${{ matrix.python-version }}
41-
uses: actions/setup-python@v4
41+
uses: actions/setup-python@v5
4242
with:
4343
python-version: ${{ matrix.python-version }}
4444
- name: Tox tests

.github/workflows/pypi-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ jobs:
55
pypi_release:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v3
8+
- uses: actions/checkout@v4
99
- name: Set up Python 3.x
10-
uses: actions/setup-python@v4
10+
uses: actions/setup-python@v5
1111
with:
1212
python-version: '3.x'
1313
- name: Install dependencies
@@ -22,4 +22,4 @@ jobs:
2222
uses: pypa/gh-action-pypi-publish@v1.4.2
2323
with:
2424
user: __token__
25-
password: ${{ secrets.pypi_password }}
25+
password: ${{ secrets.pypi_password }}

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ rebuild_updated_recipes: virtualenv
3333
ANDROID_SDK_HOME=$(ANDROID_SDK_HOME) ANDROID_NDK_HOME=$(ANDROID_NDK_HOME) \
3434
$(PYTHON) ci/rebuild_updated_recipes.py $(REBUILD_UPDATED_RECIPES_EXTRA_ARGS)
3535

36+
# make ARCH=armeabi-v7a,arm64-v8a ARTIFACT=apk BOOTSTRAP=sdl2 MODE=debug REQUIREMENTS=python testapps-generic
37+
testapps-generic: virtualenv
38+
@if [ -z "$(ARCH)" ]; then echo "ARCH is not set"; exit 1; fi
39+
@if [ -z "$(ARTIFACT)" ]; then echo "ARTIFACT is not set"; exit 1; fi
40+
@if [ -z "$(BOOTSTRAP)" ]; then echo "BOOTSTRAP is not set"; exit 1; fi
41+
@if [ -z "$(MODE)" ]; then echo "MODE is not set"; exit 1; fi
42+
@if [ -z "$(REQUIREMENTS)" ]; then echo "REQUIREMENTS is not set"; exit 1; fi
43+
@ARCH_FLAGS=$$(echo "$(ARCH)" | tr ',' ' ' | sed 's/\([^ ]\+\)/--arch=\1/g'); \
44+
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
45+
python setup.py $(ARTIFACT) \
46+
--sdk-dir $(ANDROID_SDK_HOME) \
47+
--ndk-dir $(ANDROID_NDK_HOME) \
48+
$$ARCH_FLAGS --bootstrap $(BOOTSTRAP) --$(MODE) --requirements $(REQUIREMENTS)
49+
3650
testapps-with-numpy: testapps-with-numpy/debug/apk testapps-with-numpy/release/aab
3751

3852
# testapps-with-numpy/MODE/ARTIFACT

0 commit comments

Comments
 (0)