From 1a591de894c9cfbac1bca5f109f79cb8d4b776df Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Sun, 12 Jan 2025 22:02:56 +0100 Subject: [PATCH] :construction_worker: Publish to DockerHub - multi-platform build using buildx - push to DockerHub and update DockerHub README on push to main or tagging - use the Docker Hub registry for caching image layers to speed up builds --- .github/workflows/android.yml | 50 ---------------------------- .github/workflows/docker.yml | 55 +++++++++++++++++++++++++++++++ .github/workflows/ios.yml | 33 ------------------- .github/workflows/test_python.yml | 22 ++++++++----- README.md | 10 ++---- 5 files changed, 70 insertions(+), 100 deletions(-) delete mode 100644 .github/workflows/android.yml create mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/ios.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index 4a689fef1..000000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,50 +0,0 @@ -on: [push, pull_request] - -env: - PYTHONFORANDROID_PREREQUISITES_INSTALL_INTERACTIVE: 0 - -name: Android Integration -jobs: - Integration: - strategy: - matrix: - os: - - 'ubuntu-latest' - - 'macOs-latest' - runs-on: ${{ matrix.os }} - steps: - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Setup Java - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - - uses: actions/checkout@v4 - - name: Setup environment - run: | - pip install . - - run: buildozer --help - - run: buildozer init - - name: SDK, NDK and p4a download - run: | - sed -i.bak "s/# android.accept_sdk_license = False/android.accept_sdk_license = True/" buildozer.spec - sed -i.bak "s/#p4a.branch = master/p4a.branch = develop/" buildozer.spec - buildozer android p4a -- --help - # Install OS specific dependencies - - name: Install Linux dependencies - if: matrix.os == 'ubuntu-latest' - # Required by some p4a recipes, but not - # installed by p4a on Linux. - run: sudo apt -y install automake - - name: Debug Build - run: | - touch main.py - buildozer android debug - - name: Release Build (aab) - run: | - touch main.py - export BUILDOZER_ALLOW_ORG_TEST_DOMAIN=1 - buildozer android release diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..890329462 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,55 @@ +name: Docker + +on: + push: + pull_request: + workflow_dispatch: + +env: + IMAGE_NAME: kivy/buildozer + # TODO: debugging + # SHOULD_PUBLISH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} + SHOULD_PUBLISH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/feature/docker_ci' || startsWith(github.ref, 'refs/tags/')) }} + +jobs: + build: + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + if: ${{ env.SHOULD_PUBLISH == 'true' }} + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and Push Multi-platform Image + uses: docker/build-push-action@v6 + with: + push: ${{ env.SHOULD_PUBLISH == 'true' }} + tags: ${{ env.IMAGE_NAME }}:latest + platforms: linux/amd64,linux/arm64 + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:latest + cache-to: ${{ env.SHOULD_PUBLISH == 'true' && format('type=registry,ref={0}:latest,mode=max', env.IMAGE_NAME) || '' }} + - name: Local Build for Testing + with: + # Load image into local Docker daemon + load: true + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:latest + tags: ${{ env.IMAGE_NAME }}:latest + # Run the locally built image to test it + - name: Docker run + run: docker run ${{ env.IMAGE_NAME }} --version + + update-readme: + runs-on: ubuntu-24.04 + needs: build + steps: + - uses: actions/checkout@v4 + - uses: peter-evans/dockerhub-description@v4 + if: ${{ env.SHOULD_PUBLISH == 'true' }} + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: ${{ env.IMAGE_NAME }} + readme-filepath: README.md diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml deleted file mode 100644 index f59dca5d7..000000000 --- a/.github/workflows/ios.yml +++ /dev/null @@ -1,33 +0,0 @@ -on: [push, pull_request] -name: iOS -jobs: - Integration: - name: "Integration (${{ matrix.runs_on }}, ${{ matrix.python }})" - runs-on: ${{ matrix.runs_on }} - strategy: - matrix: - # macos-latest (ATM macos-14) runs on Apple Silicon, - # macos-13 runs on Intel - runs_on: [macos-latest, macos-13] - steps: - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - uses: actions/checkout@v4 - - name: Setup environment - run: | - pip install .[ios] - - name: Check buildozer installation - run: | - buildozer --help - - name: Initialize buildozer in project folder - run: | - buildozer init - - name: Install dependencies - run: | - brew install autoconf automake libtool pkg-config - - name: buildozer ios debug - run: | - touch main.py - buildozer ios debug diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index bcf2a0264..108e9c0f6 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -32,18 +32,23 @@ jobs: run: tox - name: Coveralls env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_SERVICE_NAME: github + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_SERVICE_NAME: github-actions + COVERALLS_FLAG_NAME: python-${{ matrix.python }}-${{ matrix.os }} + COVERALLS_PARALLEL: true run: coveralls - Docker: + Coveralls: + needs: Tests runs-on: ubuntu-latest + container: python:3-slim steps: - - uses: actions/checkout@v4 - - name: Docker build - run: docker build --tag=kivy/buildozer . - - name: Docker run - run: docker run kivy/buildozer --version + - name: Finished + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + pip install coveralls + coveralls --finish Documentation: runs-on: ubuntu-latest @@ -55,4 +60,3 @@ jobs: run: sphinx-build -b linkcheck docs/source docs/build - name: Generate documentation run: sphinx-build docs/source docs/build - diff --git a/README.md b/README.md index 93c14601c..e81cf7ba5 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ build dependencies. For more information, see [![Android](https://github.com/kivy/buildozer/workflows/Android/badge.svg)](https://github.com/kivy/buildozer/actions?query=workflow%3AAndroid) [![iOS](https://github.com/kivy/buildozer/workflows/iOS/badge.svg)](https://github.com/kivy/buildozer/actions?query=workflow%3AiOS) [![Coverage Status](https://coveralls.io/repos/github/kivy/buildozer/badge.svg)](https://coveralls.io/github/kivy/buildozer) +[![TODO](https://github.com/kivy/buildozer/workflows/Docker/badge.svg)](https://github.com/kivy/buildozer/actions?query=workflow%3ATests) ## Installation @@ -68,7 +69,7 @@ docker build --tag=kivy/buildozer . For macOS, build with: ```bash -docker buildx build --platform=linux/amd64 -t kivy/buildozer . +docker buildx build --platform=linux/amd64 --tag=kivy/buildozer . ``` - Run with: @@ -77,10 +78,6 @@ docker buildx build --platform=linux/amd64 -t kivy/buildozer . docker run --volume "$(pwd)":/home/user/hostcwd kivy/buildozer --version ``` -> [!WARNING] -> [DockerHub](https://hub.docker.com/) contains an obsolete Docker image for -> Buildozer. It is deprecated. Build your own. - ### Example Build with Caching - Build and keep downloaded SDK and NDK in `~/.buildozer` directory: @@ -95,9 +92,6 @@ Use [ArtemSBulgakov/buildozer-action@v1](https://github.com/ArtemSBulgakov/build to build your packages automatically on push or pull request. See [full workflow example](https://github.com/ArtemSBulgakov/buildozer-action#full-workflow). -> [!WARNING] -> This GitHub action may use an obsolete version of Buildozer; use with caution. - ## Usage ```yml