From 76e67b81324d1a1fb09f8ced1985c7c2e0753dc8 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Mon, 27 Sep 2021 16:23:34 +0200 Subject: [PATCH 1/4] chore: build with github actions --- .github/Dockerfile | 11 ++++++++ .github/workflows/android.yml | 47 +++++++++++++++++++++++++++++++++++ .github/workflows/ios.yml | 35 ++++++++++++++++++++++++++ scripts/build-android.py | 1 + scripts/build-ios.py | 7 +++--- 5 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 .github/Dockerfile create mode 100644 .github/workflows/android.yml create mode 100644 .github/workflows/ios.yml diff --git a/.github/Dockerfile b/.github/Dockerfile new file mode 100644 index 000000000..bf81ca30f --- /dev/null +++ b/.github/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:20.04 +MAINTAINER https://github.com/Kudo + +RUN apt-get update +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get install -y sudo + +RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu +RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers +USER ubuntu +WORKDIR /home/ubuntu diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 000000000..bfc8314e9 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,47 @@ +name: Build for Android + +on: [workflow_dispatch] + +jobs: + build: + strategy: + # max-parallel: 1 + matrix: + # arch: ['arm' ,'arm64' ,'x86' ,'x64'] + arch: ['arm'] + runs-on: ubuntu-latest + + steps: + + + - uses: actions/checkout@v2 + - name: Setup JDK + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + + - uses: nttld/setup-ndk@v1 + with: + ndk-version: r22 + + - name: Build swig + run: | + cd scripts + python swigpp-java.py --profile standard --swig ../../mobile-swig/swig + + - name: Get branch name + shell: bash + run: echo "VERSION_NAME=$(echo ${GITHUB_HEAD_REF} | tr / - | sed "s/^[a-zA-Z]*-//g")" >> $GITHUB_ENV + + - name: Build CartoSDK + run: | + cd scripts + python build-android.py --profile standard+valhalla --build-aar --build-version ${{ env.VERSION_NAME }} --configuration=Release + + - uses: actions/upload-artifact@v2 + with: + name: dist + path: dist/android/*.zip diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml new file mode 100644 index 000000000..d20ddada8 --- /dev/null +++ b/.github/workflows/ios.yml @@ -0,0 +1,35 @@ +name: Build for iOS + +on: [workflow_dispatch] + +env: + CACHE_KEY_SUFFIX: v2 + +jobs: + build: + runs-on: macos-latest + steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - uses: actions/checkout@v2 + + - name: Build swig + run: | + cd scripts + python swigpp-objc.py --profile standard+valhalla --swig ../../mobile-swig/swig + + - name: Get branch name + shell: bash + run: echo "VERSION_NAME=$(echo ${GITHUB_HEAD_REF} | tr / - | sed "s/^[a-zA-Z]*-//g")" >> $GITHUB_ENV + + - name: Build CartoSDK + run: | + cd scripts + python build-ios.py --profile standard+valhalla --build-cocoapod --build-version ${{ env.VERSION_NAME }} --build-xcframework + + - uses: actions/upload-artifact@v2 + with: + name: dist + path: dist/ios/*.zip \ No newline at end of file diff --git a/scripts/build-android.py b/scripts/build-android.py index 2aad93932..3221c2bed 100644 --- a/scripts/build-android.py +++ b/scripts/build-android.py @@ -6,6 +6,7 @@ from build.sdk_build_utils import * ANDROID_ABIS = ['armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'] +SDK_VERSION = "4.4.2" def javac(args, dir, *cmdArgs): return execute(args.javac, dir, *cmdArgs) diff --git a/scripts/build-ios.py b/scripts/build-ios.py index bf9560b17..0058bfbe1 100644 --- a/scripts/build-ios.py +++ b/scripts/build-ios.py @@ -8,6 +8,7 @@ from build.sdk_build_utils import * IOS_ARCHS = ['i386', 'x86_64', 'armv7', 'arm64', 'arm64-simulator', 'x86_64-maccatalyst', 'arm64-maccatalyst'] +SDK_VERSION = "4.4.2" def getFinalBuildDir(target, arch=None): return getBuildDir(('%s_metal' % target) if args.metalangle else target, arch) @@ -296,14 +297,14 @@ def buildIOSPackage(args, buildCocoapod, buildSwiftPackage): if 'all' in args.iosarch or args.iosarch == []: args.iosarch = IOS_ARCHS if not args.buildxcframework: - args.iosarch = filter(lambda arch: not (arch.endswith('-simulator') or arch.endswith('-maccatalyst')), args.iosarch) + args.iosarch = list(filter(lambda arch: not (arch.endswith('-simulator') or arch.endswith('-maccatalyst')), args.iosarch)) if not args.metalangle: - args.iosarch = filter(lambda arch: not arch.endswith('-maccatalyst'), args.iosarch) + args.iosarch = list(filter(lambda arch: not arch.endswith('-maccatalyst'), args.iosarch)) args.defines += ';' + getProfile(args.profile).get('defines', '') if args.metalangle: args.defines += ';' + '_CARTO_USE_METALANGLE' else: - if filter(lambda arch: arch.endswith('-maccatalyst'), args.iosarch): + if list(filter(lambda arch: arch.endswith('-maccatalyst'), args.iosarch)): print('Mac Catalyst builds are only supported with MetalANGLE') sys.exit(-1) args.cmakeoptions += ';' + getProfile(args.profile).get('cmake-options', '') From 021b2083d8378263809d493f9c49c49d1689f2da Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Fri, 1 Oct 2021 15:09:41 +0200 Subject: [PATCH 2/4] chore: github ci build script for now only android and ios. No catalyst --- .github/workflows/build.yml | 102 ++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..dc6fc5f4e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,102 @@ +name: Build CartoMobileSDK + +on: [workflow_dispatch] + +jobs: + build: + strategy: + # max-parallel: 1 + matrix: + variant: ['android', 'ios'] + runs-on: macos-latest + name: CartoMobileSDK ${{ matrix.variant }} + steps: + - uses: actions/checkout@v2 + + - name: fetch externals + run: | + git submodule update --init --remote --recursive + + - name: Setup JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Setup Android SDK + if: matrix.variant == 'android' + uses: android-actions/setup-android@v2 + + - uses: nttld/setup-ndk@v1 + if: matrix.variant == 'android' + id: setup-ndk + with: + ndk-version: r22 + + - name: prepare boost + run: | + cd libs-external/boost + ./bootstrap.sh + ./b2 headers + + - name: Build swig + run: | + brew install autoconf automake libtool + git clone https://github.com/farfromrefug/mobile-swig.git + cd mobile-swig + wget https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.37/pcre2-10.37.tar.gz + ./Tools/pcre-build.sh + ./autogen.sh + ./configure + make + + - name: Build swig-objc + if: matrix.variant != 'android' + run: | + cd scripts + python swigpp-objc.py --profile standard+valhalla --swig ../mobile-swig/swig + + - name: Build swig-java + if: matrix.variant == 'android' + run: | + cd scripts + python swigpp-java.py --profile standard --swig ../mobile-swig/swig + + - name: Get branch name + shell: bash + run: echo "VERSION_NAME=$(echo ${GITHUB_HEAD_REF} | tr / - | sed "s/^[a-zA-Z]*-//g" | sed "s/^$/4.4.2/")" >> $GITHUB_ENV + + - name: Build CartoSDK + if: matrix.variant == 'android' + run: | + brew install gradle@6 + cd scripts + python build-android.py --profile standard+valhalla --build-aar --build-version ${{ env.VERSION_NAME }} --configuration=Release --gradle /usr/local/opt/gradle@6/bin/gradle + env: + ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} + + - name: Build CartoSDK + if: matrix.variant == 'ios' + run: | + cd scripts + python build-ios.py --profile standard+valhalla --build-cocoapod --build-version ${{ env.VERSION_NAME }} --build-xcframework + + - name: Build CartoSDK + if: matrix.variant == 'ios-metal' + run: | + cd scripts + python build-ios.py --profile standard+valhalla --build-cocoapod --build-version ${{ env.VERSION_NAME }} --build-xcframework + + - uses: actions/upload-artifact@v2 + if: matrix.variant == 'android' + with: + name: CartoMobileSDK-android-{{env.VERSION_NAME}}.zip + path: | + dist/android/*.aar + dist/android/*.jar + dist/android/*.pom + + - uses: actions/upload-artifact@v2 + if: matrix.variant != 'android' + with: + name: CartoMobileSDK-ios-{{env.VERSION_NAME}}.zip + path: dist/ios/*.zip From 86b18c9acfcfdea1b3cd8ddb579a1966b4e3184a Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Fri, 1 Oct 2021 15:13:36 +0200 Subject: [PATCH 3/4] chore: cleanup --- .github/Dockerfile | 11 -------- .github/workflows/android.yml | 47 ----------------------------------- .github/workflows/ios.yml | 35 -------------------------- 3 files changed, 93 deletions(-) delete mode 100644 .github/Dockerfile delete mode 100644 .github/workflows/android.yml delete mode 100644 .github/workflows/ios.yml diff --git a/.github/Dockerfile b/.github/Dockerfile deleted file mode 100644 index bf81ca30f..000000000 --- a/.github/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:20.04 -MAINTAINER https://github.com/Kudo - -RUN apt-get update -ENV DEBIAN_FRONTEND noninteractive -RUN apt-get install -y sudo - -RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu -RUN echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers -USER ubuntu -WORKDIR /home/ubuntu diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index bfc8314e9..000000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Build for Android - -on: [workflow_dispatch] - -jobs: - build: - strategy: - # max-parallel: 1 - matrix: - # arch: ['arm' ,'arm64' ,'x86' ,'x64'] - arch: ['arm'] - runs-on: ubuntu-latest - - steps: - - - - uses: actions/checkout@v2 - - name: Setup JDK - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - - name: Setup Android SDK - uses: android-actions/setup-android@v2 - - - uses: nttld/setup-ndk@v1 - with: - ndk-version: r22 - - - name: Build swig - run: | - cd scripts - python swigpp-java.py --profile standard --swig ../../mobile-swig/swig - - - name: Get branch name - shell: bash - run: echo "VERSION_NAME=$(echo ${GITHUB_HEAD_REF} | tr / - | sed "s/^[a-zA-Z]*-//g")" >> $GITHUB_ENV - - - name: Build CartoSDK - run: | - cd scripts - python build-android.py --profile standard+valhalla --build-aar --build-version ${{ env.VERSION_NAME }} --configuration=Release - - - uses: actions/upload-artifact@v2 - with: - name: dist - path: dist/android/*.zip diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml deleted file mode 100644 index d20ddada8..000000000 --- a/.github/workflows/ios.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Build for iOS - -on: [workflow_dispatch] - -env: - CACHE_KEY_SUFFIX: v2 - -jobs: - build: - runs-on: macos-latest - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - uses: actions/checkout@v2 - - - name: Build swig - run: | - cd scripts - python swigpp-objc.py --profile standard+valhalla --swig ../../mobile-swig/swig - - - name: Get branch name - shell: bash - run: echo "VERSION_NAME=$(echo ${GITHUB_HEAD_REF} | tr / - | sed "s/^[a-zA-Z]*-//g")" >> $GITHUB_ENV - - - name: Build CartoSDK - run: | - cd scripts - python build-ios.py --profile standard+valhalla --build-cocoapod --build-version ${{ env.VERSION_NAME }} --build-xcframework - - - uses: actions/upload-artifact@v2 - with: - name: dist - path: dist/ios/*.zip \ No newline at end of file From 769c8900870b08b8db7832a08fded5df509a2b38 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Fri, 1 Oct 2021 17:28:11 +0200 Subject: [PATCH 4/4] chore: artifact name fix --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc6fc5f4e..5f9c11005 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,7 +89,7 @@ jobs: - uses: actions/upload-artifact@v2 if: matrix.variant == 'android' with: - name: CartoMobileSDK-android-{{env.VERSION_NAME}}.zip + name: CartoMobileSDK-android-${{env.VERSION_NAME}}.zip path: | dist/android/*.aar dist/android/*.jar @@ -98,5 +98,5 @@ jobs: - uses: actions/upload-artifact@v2 if: matrix.variant != 'android' with: - name: CartoMobileSDK-ios-{{env.VERSION_NAME}}.zip + name: CartoMobileSDK-ios-${{env.VERSION_NAME}}.zip path: dist/ios/*.zip