Build CartoMobileSDK #142
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 }} | |
draft: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
strategy: | |
matrix: | |
variant: ['android', 'ios', 'ios_metal'] | |
runs-on: ${{ matrix.variant == 'android' && 'ubuntu-latest' || 'macos-latest' }} | |
needs: [create-release] | |
name: CartoMobileSDK ${{ matrix.variant }} | |
steps: | |
- name: Runner platform name | |
if: matrix.variant != 'ios_metal' | |
run: | | |
export PLATFORM_UP=${{ runner.os }} | |
echo "PLATFORM_UP=$PLATFORM_UP" | |
echo "PLATFORM=$(echo "$PLATFORM_UP" | tr "[:upper:]" "[:lower:]")" >>${GITHUB_ENV} | |
echo "PLATFORM=${{ env.PLATFORM }}" | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- uses: maxim-lobanov/setup-xcode@v1 | |
if: matrix.variant != 'android' | |
- name: Setup cmake | |
uses: jwlawson/actions-setup-cmake@v2 | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
if: matrix.variant == 'android' | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
- 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: r27c | |
local-cache: false | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
gradle-version: "8.10" | |
- 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: 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: 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 -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" | |
cd build | |
make css2xml | |
mv css2xml css2xml_${{ env.PLATFORM }} | |
zip ../../../../dist/css2xml_${{ env.PLATFORM }}.zip css2xml_${{ env.PLATFORM }} | |
- 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 | |
- name: Upload Release Asset | |
if: matrix.variant != 'ios_metal' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload ${{ needs.create-release.outputs.VERSION_TAG }} dist/css2xml_*.zip | |
- name: Upload Release Asset | |
if: matrix.variant == 'android' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
ls -la dist/android | |
gh release upload ${{ needs.create-release.outputs.VERSION_TAG }} dist/android/*.aar | |
gh release upload ${{ needs.create-release.outputs.VERSION_TAG }} dist/android/*.pom | |
- 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/${{matrix.variant}}/*.zip | |
update-release: | |
runs-on: ubuntu-latest | |
needs: [create-release, build] | |
permissions: | |
contents: write # release changes require contents write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
# we need to do this so that the tag is created now that the build worked | |
- name: Update release | |
uses: irongut/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
id: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }} | |
prerelease: true | |
draft: false | |
- name: Update CHANGELOG | |
id: changelog | |
uses: requarks/changelog-action@v1 | |
with: | |
useGitmojis: false | |
excludeTypes: build,docs,other,style,chore,perf,doc | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: v${{ needs.create-release.outputs.VERSION }} | |
- name: Commit CHANGELOG.md | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
branch: master | |
commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]' | |
file_pattern: CHANGELOG.md | |
- name: Update release | |
uses: irongut/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
id: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }} | |
body: ${{ steps.changelog.outputs.changes }} | |
prerelease: false | |
draft: false | |