Build CartoMobileSDK #117
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build CartoMobileSDK | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
required: false | |
description: 'version number' | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
outputs: | |
RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }} | |
VERSION: ${{ steps.get_version_or_prompt.outputs.result }} | |
VERSION_TAG: v${{ steps.get_version_or_prompt.outputs.result }} | |
steps: | |
- name: setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
- uses: actions/github-script@v6 | |
id: get_version_or_prompt | |
with: | |
result-encoding: string | |
script: | | |
if ("${{ github.event.inputs.version }}".length) { | |
return "${{ github.event.inputs.version }}"; | |
} | |
- name: create release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
# This pulls from the "Get Changelog Entry" step above, referencing it's ID to get its outputs object. | |
# See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
tag: v${{ steps.get_version_or_prompt.outputs.result }} | |
name: v${{ steps.get_version_or_prompt.outputs.result }} | |
generateReleaseNotes: true | |
# we create first the release as draft. Will be published once everything is done | |
draft: true | |
allowUpdates: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
strategy: | |
matrix: | |
variant: ['android'] | |
runs-on: ${{ matrix.variant == 'android' && 'ubuntu-latest' || 'macos-latest' }} | |
needs: [create-release] | |
name: CartoMobileSDK ${{ matrix.variant }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- uses: maxim-lobanov/setup-xcode@v1 | |
if: matrix.variant != 'android' | |
- name: Setup JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.12 | |
- name: Setup Android SDK | |
if: matrix.variant == 'android' | |
uses: android-actions/setup-android@v3 | |
# - if: matrix.variant == 'android' | |
# name: run SDKManager | |
# run: sdkmanager "build-tools;30.0.3" | |
- uses: nttld/setup-ndk@v1 | |
if: matrix.variant == 'android' | |
id: setup-ndk | |
with: | |
ndk-version: r25c | |
local-cache: false | |
- name: Setup cmake | |
uses: jwlawson/actions-setup-cmake@v2 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
if: matrix.variant == 'android' | |
with: | |
cache: gradle | |
java-version: 17 | |
distribution: 'temurin' | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: ensure dist | |
run: | | |
mkdir dist | |
- name: fetch externals | |
run: | | |
git submodule update --init --remote --recursive | |
- name: prepare boost | |
run: | | |
wget https://boostorg.jfrog.io/artifactory/main/release/1.85.0/source/boost_1_85_0.zip | |
unzip boost_1_85_0.zip | |
ln -s ../boost_1_85_0 libs-external/boost | |
cd boost_1_85_0 | |
./bootstrap.sh | |
./b2 headers | |
- name: Build CSS2XML | |
if: matrix.variant != 'ios_metal' | |
run: | | |
cd libs-carto/cartocss/util | |
cmake -B build -DCMAKE_BUILD_TYPE=Release | |
cd build | |
make css2xml | |
mv css2xml css2xml_${{ matrix.variant }} | |
zip ../../../../dist/css2xml_${{ matrix.variant }}.zip css2xml_${{ matrix.variant }} | |
- name: Install build tools | |
if: matrix.variant == 'android' | |
run: | | |
sudo apt-get install autoconf automake libtool build-essential | |
- name: Install build tools | |
if: matrix.variant != 'android' | |
run: | | |
brew install autoconf automake libtool | |
- name: Build swig | |
if: matrix.variant == 'android' | |
run: | | |
git clone https://github.com/farfromrefug/mobile-swig.git | |
cd mobile-swig | |
wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.tar.gz | |
./Tools/pcre-build.sh | |
./autogen.sh | |
./configure | |
make | |
- name: Build swig | |
if: matrix.variant != 'android' | |
run: | | |
git clone https://github.com/farfromrefug/mobile-swig.git | |
cd mobile-swig | |
wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.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+valhalla --swig ../mobile-swig/swig | |
- name: Build CartoSDK | |
if: matrix.variant == 'android' | |
run: | | |
cd scripts | |
python build-android.py --profile standard+valhalla --build-aar --build-version ${{ needs.create-release.outputs.VERSION }}--configuration=Release | |
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 ${{ needs.create-release.outputs.VERSION }} --configuration=Release --build-xcframework | |
- name: Build CartoSDK | |
if: matrix.variant == 'ios_metal' | |
run: | | |
cd scripts | |
python build-ios.py --profile standard+valhalla --build-cocoapod --build-version ${{ needs.create-release.outputs.VERSION }} --configuration=Release --build-xcframework --use-metalangle | |
- uses: actions/upload-artifact@v4 | |
if: matrix.variant == 'android' | |
with: | |
name: CartoMobileSDK-${{matrix.variant}}-${{ needs.create-release.outputs.VERSION }}.zip | |
path: | | |
dist/css2xml_*.zip | |
dist/android/*.aar | |
dist/android/*.jar | |
dist/android/*.pom | |
- uses: actions/upload-artifact@v4 | |
if: matrix.variant != 'android' | |
with: | |
name: CartoMobileSDK-${{matrix.variant}}-${{ needs.create-release.outputs.VERSION }}.zip | |
path: | | |
dist/css2xml_*.zip | |
dist/${{matrix.variant}}/*.zip | |
- name: Upload Release Asset | |
if: matrix.variant == 'android' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload ${{ needs.create-release.outputs.VERSION_TAG }} dist/css2xml_*.zip | |
gh release upload ${{ needs.create-release.outputs.VERSION_TAG }} dist/android/*.aar | |
- name: Upload Release Asset | |
if: matrix.variant != 'android' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload ${{ needs.create-release.outputs.VERSION_TAG }} dist/css2xml_*.zip | |
gh release upload ${{ needs.create-release.outputs.VERSION_TAG }} dist/${{matrix.variant}}/*.zip | |
update-release: | |
runs-on: ubuntu-latest | |
needs: [create-release, build] | |
permissions: | |
contents: write # release changes require contents write | |
steps: | |
- name: Update release | |
uses: irongut/EditRelease@v1.2.0 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
id: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }} | |
draft: false | |