From d793b7c0488c63501d8afa74db2263e888cfeccb Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Wed, 16 Dec 2020 18:24:37 +0100 Subject: [PATCH] Added support for github CI/CD and packaging. A few fixes for iOS build --- .github/workflows/android-ci.yml | 149 ++++++++++++++ .github/workflows/android-docker-base.yml | 29 +++ .github/workflows/android-docker-ndk-r21b.yml | 29 +++ .github/workflows/android-release.yml | 178 +++++++++++++++++ .github/workflows/ios-ci.yml | 100 ++++++++++ .github/workflows/ios-release.yml | 81 ++++++++ mapbox-gl-native-android/Makefile | 5 + .../MapboxGLAndroidSDK/build.gradle | 2 +- .../gradle/artifact-settings.gradle | 19 +- .../gradle/gradle-gitpackages.gradle | 85 ++++++++ .../scripts/release-notes-github.md.ejs | 3 + .../scripts/release-notes.js | 74 +++++++ mapbox-gl-native-ios/Makefile | 12 +- .../platform/ios/scripts/deploy-packages.sh | 41 +++- .../ios/scripts/deploy-swift-package.sh | 186 ++++++++++++++++++ .../scripts/install-packaging-dependencies.sh | 23 +-- .../platform/ios/scripts/package.sh | 2 +- .../platform/ios/scripts/publish.sh | 34 ++-- .../ios/scripts/release-notes-github.md.ejs | 7 - .../ios/scripts/swift_package_template.swift | 26 +++ .../platform/ios/scripts/xcpackage.sh | 159 +++++++++++++++ mapbox-gl-native-ios/scripts/environment.js | 18 +- mapbox-gl-native-ios/scripts/style-spec.js | 2 +- 23 files changed, 1193 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/android-ci.yml create mode 100644 .github/workflows/android-docker-base.yml create mode 100644 .github/workflows/android-docker-ndk-r21b.yml create mode 100644 .github/workflows/android-release.yml create mode 100644 .github/workflows/ios-ci.yml create mode 100644 .github/workflows/ios-release.yml create mode 100644 mapbox-gl-native-android/gradle/gradle-gitpackages.gradle create mode 100644 mapbox-gl-native-android/scripts/release-notes-github.md.ejs create mode 100755 mapbox-gl-native-android/scripts/release-notes.js create mode 100755 mapbox-gl-native-ios/platform/ios/scripts/deploy-swift-package.sh create mode 100644 mapbox-gl-native-ios/platform/ios/scripts/swift_package_template.swift create mode 100755 mapbox-gl-native-ios/platform/ios/scripts/xcpackage.sh diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml new file mode 100644 index 000000000..61fe4a48b --- /dev/null +++ b/.github/workflows/android-ci.yml @@ -0,0 +1,149 @@ +name: android-ci + +on: + workflow_dispatch: + push: + tags-ignore: + - '**' + paths-ignore: + - "mapbox-gl-native-ios/**" + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: [self-hosted, petr-ubuntu-acct] + defaults: + run: + working-directory: mapbox-gl-native-android + container: + image: ghcr.io/maptiler/android-ndk-r21b + credentials: + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + env: + LIBSYSCONFCPUS: 8 + JOBS: 8 + BUILDTYPE: Debug + IS_LOCAL_DEVELOPMENT: false + MBGL_ANDROID_STL: c++_static + steps: + + - uses: actions/checkout@v2 + with: + submodules: recursive + fetch-depth: 0 + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: npm install + run: npm install --ignore-scripts + working-directory: mapbox-gl-native-android + + - name: Prepare ccache + run: ccache --clear + + - name: Cache ccache + uses: actions/cache@v2 + env: + cache-name: ccache-v1 + with: + path: ~/.ccache' + key: ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }} + restore-keys: | + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }} + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }} + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }} + + - name: Clear ccache statistics + run: | + ccache --zero-stats + ccache --max-size=2G + ccache --show-stats + + - name: restore-gradle-cache + uses: actions/cache@v2 + env: + cache-name: gradle-v1 + with: + path: ~/.gradle' + key: ${{ env.cache-name }}-{{ hashFiles 'gradle/dependencies.gradle' }}-{{ hashFiles 'build.gradle' }}-{{ hashFiles 'gradle/wrapper/gradle-wrapper.properties' }}' + restore-keys: | + - ${{ env.cache-name }} + + - name: Check code style + run: make android-check + + - name: Run Android unit tests + run: make run-android-unit-test + + - name: Build libmapbox-gl.so for arm-v8 + run: make android-lib-arm-v8 + + - name: Generate Espresso sanity tests + run: make test-code-android + + - name: Build Test APK + run: | + MAPBOX_DEVELOPER_CONFIG_XML='${{ secrets.MAPBOX_DEVELOPER_CONFIG_XML }}' + if [ -n "${MAPBOX_DEVELOPER_CONFIG_XML}" ]; then + echo "${MAPBOX_DEVELOPER_CONFIG_XML}" > MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml + make android-ui-test-arm-v8 + else + echo "No secrets.MAPBOX_DEVELOPER_CONFIG_XML variable set, skipping apk build..." + fi + shell: bash + + - name: Log in to Google Cloud Platform + run: | + GLCLOUD_SERVICE_JSON='${{ secrets.GLCLOUD_SERVICE_JSON }}' + if [[ -n "${GLCLOUD_SERVICE_JSON}" ]]; then + echo "Activating google cloud account..." + echo "${GLCLOUD_SERVICE_JSON}" > secret.json + gcloud auth activate-service-account --key-file secret.json --project maptiler-gl-mobile + rm secret.json + else + echo "No secrets.GLCLOUD_SERVICE_JSON variable set, skipping google cloud login..." + fi + shell: bash + + - name: Run instrumentation tests on Firebase + run: | + GLCLOUD_SERVICE_JSON='${{ secrets.GLCLOUD_SERVICE_JSON }}' + if [[ -n "${GLCLOUD_SERVICE_JSON}" ]]; then + gcloud firebase test android models list + gcloud firebase test android run --type instrumentation \ + --app MapboxGLAndroidSDKTestApp/build/outputs/apk/debug/MapboxGLAndroidSDKTestApp-debug.apk \ + --test MapboxGLAndroidSDKTestApp/build/outputs/apk/androidTest/debug/MapboxGLAndroidSDKTestApp-debug-androidTest.apk \ + --device-ids sailfish --os-version-ids 26 --locales en --orientations portrait --timeout 20m \ + --environment-variables coverage=true,coverageFile="/sdcard/coverage.ec" --directories-to-pull /sdcard --results-dir mapbox-android-sdk-${CIRCLE_BUILD_NUM} + else + echo "No secrets.GLCLOUD_SERVICE_JSON variable set, skipping instrumentation tests..." + fi + shell: bash + + - name: Store debug artifacts + uses: actions/upload-artifact@v2 + with: + name: debug-artifacts + path: | + MapboxGLAndroidSDKTestApp/build/outputs/apk/debug + MapboxGLAndroidSDK/build/reports/lint-results.html + MapboxGLAndroidSDK/lint-baseline.xml + MapboxGLAndroidSDKTestApp/build/reports/lint-results.html + MapboxGLAndroidSDKTestApp/build/reports/lint-results.xml + MapboxGLAndroidSDKTestApp/lint-baseline.xml + MapboxGLAndroidSDK/build/intermediates/cmake/debug/obj \ No newline at end of file diff --git a/.github/workflows/android-docker-base.yml b/.github/workflows/android-docker-base.yml new file mode 100644 index 000000000..eeffbbbd0 --- /dev/null +++ b/.github/workflows/android-docker-base.yml @@ -0,0 +1,29 @@ +name: android-base-docker-image +on: + workflow_dispatch +jobs: + push_to_registry: + name: Docker image android-base + runs-on: [self-hosted, petr-ubuntu-acct] + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to ghcr.io + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Build and push android-base image + uses: docker/build-push-action@v2 + with: + file: ./mapbox-gl-native-android/docker/android-base + context: ./mapbox-gl-native-android/docker + tags: ghcr.io/maptiler/android-base:latest + push: true \ No newline at end of file diff --git a/.github/workflows/android-docker-ndk-r21b.yml b/.github/workflows/android-docker-ndk-r21b.yml new file mode 100644 index 000000000..35457cc70 --- /dev/null +++ b/.github/workflows/android-docker-ndk-r21b.yml @@ -0,0 +1,29 @@ +name: android-ndk-r21b-docker-image +on: + workflow_dispatch +jobs: + push_to_registry: + name: Docker image android-ndk-r21b + runs-on: [self-hosted, petr-ubuntu-acct] + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to ghcr.io + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Build and push android-ndk-r21b image + uses: docker/build-push-action@v2 + with: + file: ./mapbox-gl-native-android/docker/android-ndk-r21b + context: ./mapbox-gl-native-android/docker + tags: ghcr.io/maptiler/android-ndk-r21b:latest + push: true \ No newline at end of file diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml new file mode 100644 index 000000000..96133c0ce --- /dev/null +++ b/.github/workflows/android-release.yml @@ -0,0 +1,178 @@ +name: android-release + +on: + workflow_dispatch: + push: + tags: + - android-v* + branches: + - main +jobs: + build: + runs-on: [self-hosted, petr-ubuntu-acct] + defaults: + run: + working-directory: mapbox-gl-native-android + container: + image: ghcr.io/maptiler/android-ndk-r21b + credentials: + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + env: + LIBSYSCONFCPUS: 8 + JOBS: 8 + BUILDTYPE: Release + IS_LOCAL_DEVELOPMENT: false + steps: + + - uses: actions/checkout@v2 + with: + submodules: recursive + fetch-depth: 0 + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: npm install + run: npm install --ignore-scripts + working-directory: mapbox-gl-native-android + + - name: Prepare ccache + run: ccache --clear + + - name: Cache ccache + uses: actions/cache@v2 + env: + cache-name: ccache-v1 + with: + path: ~/.ccache' + key: ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }} + restore-keys: | + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }} + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }} + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }} + + - name: Clear ccache statistics + run: | + ccache --zero-stats + ccache --max-size=2G + ccache --show-stats + + - name: restore-gradle-cache + uses: actions/cache@v2 + env: + cache-name: gradle-v1 + with: + path: ~/.gradle' + key: ${{ env.cache-name }}-{{ hashFiles 'gradle/dependencies.gradle' }}-{{ hashFiles 'build.gradle' }}-{{ hashFiles 'gradle/wrapper/gradle-wrapper.properties' }}' + restore-keys: | + - ${{ env.cache-name }} + + - name: Android nitpick + run: make run-android-nitpick + + - name: Update version name + run: | + RELEASE_VERSION="$( git describe --tags --match=android-v*.*.* --abbrev=0 | sed 's/^android-v//' )" + echo "Latest version from tag: $RELEASE_VERSION" + if [ ! -z "$RELEASE_VERSION" ]; then + sed -i -e "s/^VERSION_NAME=.*/VERSION_NAME=${RELEASE_VERSION}/" MapboxGLAndroidSDK/gradle.properties + echo "MapboxGLAndroidSDK/gradle.properties:" + cat MapboxGLAndroidSDK/gradle.properties + fi + shell: bash + + - name: Build package + run: make apackage + + - name: Build release Test App + run: | + MAPBOX_DEVELOPER_CONFIG_XML='${{ secrets.MAPBOX_DEVELOPER_CONFIG_XML }}' + if [ -n "${MAPBOX_DEVELOPER_CONFIG_XML}" ]; then + echo "${MAPBOX_DEVELOPER_CONFIG_XML}" > MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml + make android + else + echo "No secrets.MAPBOX_DEVELOPER_CONFIG_XML variable set, skipping apk build..." + fi + shell: bash + + - name: Generate javadoc + run: make android-javadoc + + - name: Log in to Google Cloud Platform + run: | + GLCLOUD_SERVICE_JSON='${{ secrets.GLCLOUD_SERVICE_JSON }}' + if [[ -n "${GLCLOUD_SERVICE_JSON}" ]]; then + echo "Activating google cloud account..." + echo "${GLCLOUD_SERVICE_JSON}" > secret.json + gcloud auth activate-service-account --key-file secret.json --project maptiler-gl-mobile + rm secret.json + else + echo "No secrets.GLCLOUD_SERVICE_JSON variable set, skipping google cloud login..." + fi + shell: bash + + - name: Run robotest of release Test App on Firebase + run: | + GLCLOUD_SERVICE_JSON='${{ secrets.GLCLOUD_SERVICE_JSON }}' + if [[ -n "${GLCLOUD_SERVICE_JSON}" ]]; then + gcloud firebase test android run --type robo \ + --app MapboxGLAndroidSDKTestApp/build/outputs/apk/release/MapboxGLAndroidSDKTestApp-release.apk \ + --device-ids sailfish --os-version-ids "26" --locales en --orientations portrait --timeout 90s + else + echo "No secrets.GLCLOUD_SERVICE_JSON variable set, skipping tests..." + fi + shell: bash + + # create github release + - name: Prepare release + id: prepare_release + run: | + RELEASE_NOTES_PATH="${PWD}/release_notes.txt" + ./scripts/release-notes.js > ${RELEASE_NOTES_PATH} + echo ::set-output name=release_notes::${RELEASE_NOTES_PATH} + echo ::set-output name=version_tag::$( git describe --tags --match=android-v*.*.* --abbrev=0 ) + shell: bash + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.prepare_release.outputs.version_tag }} + release_name: ${{steps.prepare_release.outputs.version_tag }} + body_path: ${{ steps.prepare_release.outputs.release_notes }} + draft: false + prerelease: false + + - name: Upload aar + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: mapbox-gl-native-android/MapboxGLAndroidSDK/build/outputs/aar/MapboxGLAndroidSDK-release.aar + asset_name: MapboxGLAndroidSDK-release.aar + asset_content_type: application/zip + + - name: Clean release + run: | + rm -f ${{ steps.prepare_release.outputs.release_notes }} + shell: bash + + # deploy to github maven repo + - name: Publish package + run: make android-maven-publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ios-ci.yml b/.github/workflows/ios-ci.yml new file mode 100644 index 000000000..62ee9f74f --- /dev/null +++ b/.github/workflows/ios-ci.yml @@ -0,0 +1,100 @@ +name: ios-ci + +on: + workflow_dispatch: + push: + tags-ignore: + - '**' + paths-ignore: + - "mapbox-gl-native-android/**" + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + #runs-on: [self-hosted, petr-macos-vbox1] + runs-on: [self-hosted, petr-self-hosted] + env: + BUILDTYPE: Debug + HOMEBREW_NO_AUTO_UPDATE: 1 + HOMEBREW_NO_INSTALL_CLEANUP: 1 + defaults: + run: + working-directory: mapbox-gl-native-ios + shell: bash + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + fetch-depth: 0 + + - name: Install macos dependencies + run: | + brew list cmake || brew install cmake + brew list ccache || brew install ccache + brew list pkg-config || brew install pkg-config + brew list glfw3 || brew install glfw3 + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: /user/local/lib/node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: npm install + run: npm install --ignore-scripts + + - name: Prepare ccache + run: ccache --clear + + - name: Cache ccache + uses: actions/cache@v2 + env: + cache-name: ccache-v1 + with: + path: ~/.ccache' + key: ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }} + restore-keys: | + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }} + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }} + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }} + + - name: Clear ccache statistics + run: | + ccache --zero-stats + ccache --max-size=2G + ccache --show-stats + + - name: Install iOS packaging dependencies + run: | + ./platform/ios/scripts/install-packaging-dependencies.sh + env: + CILAUNCH: true + + - name: Check debug symbols + run: make darwin-check-public-symbols + + - name: Lint plist files + run: make ios-lint-plist + + - name: Running ios unit tests + run: make ios-test + + - name: Build and run SDK unit tests with thread and undefined behavior sanitizers + run: make ios-sanitize + + - name: Build and run SDK unit tests with address sanitizer + run: make ios-sanitize-address + + - name: Build and run SDK unit tests with the static analyzer + run: make ios-static-analyzer \ No newline at end of file diff --git a/.github/workflows/ios-release.yml b/.github/workflows/ios-release.yml new file mode 100644 index 000000000..f80aca00e --- /dev/null +++ b/.github/workflows/ios-release.yml @@ -0,0 +1,81 @@ +name: ios-release + +on: + push: + tags: + - ios-v* + branches: + - main + +jobs: + build: + runs-on: [self-hosted, petr-macos-vbox1] + env: + BUILDTYPE: Release + HOMEBREW_NO_AUTO_UPDATE: 1 + HOMEBREW_NO_INSTALL_CLEANUP: 1 + defaults: + run: + working-directory: mapbox-gl-native-ios + shell: bash + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + fetch-depth: 0 + + - name: Install macos dependencies + run: | + brew list cmake || brew install cmake + brew list ccache || brew install ccache + brew list pkg-config || brew install pkg-config + brew list glfw3 || brew install glfw3 + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: npm install + run: npm install --ignore-scripts + + - name: Prepare ccache + run: ccache --clear + + - name: Cache ccache + uses: actions/cache@v2 + env: + cache-name: ccache-v1 + with: + path: ~/.ccache' + key: ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }} + restore-keys: | + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }} + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }}-${{ github.ref }} + ${{ env.cache-name }}-${{ runner.os }}-${{ github.job }} + + - name: Clear ccache statistics + run: | + ccache --zero-stats + ccache --max-size=2G + ccache --show-stats + + - name: Install iOS packaging dependencies + run: | + ./platform/ios/scripts/install-packaging-dependencies.sh + env: + CILAUNCH: true + + - name: Build, package, and upload iOS release + run: platform/ios/scripts/deploy-swift-package.sh + env: + DIST_GITHUB_TOKEN: ${{ secrets.DIST_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/mapbox-gl-native-android/Makefile b/mapbox-gl-native-android/Makefile index 2e087b6f7..4016b47e8 100644 --- a/mapbox-gl-native-android/Makefile +++ b/mapbox-gl-native-android/Makefile @@ -256,6 +256,11 @@ run-android-upload-to-bintray: gradle/configuration.gradle run-android-upload-to-artifactory: gradle/configuration.gradle $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=all :MapboxGLAndroidSDK:artifactoryPublish +# Uploads the compiled Android SDK to maven github package registry +.PHONY: android-maven-publish +android-maven-publish: gradle/configuration.gradle + $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=all :MapboxGLAndroidSDK:publish + # Dump system graphics information for the test app .PHONY: android-gfxinfo android-gfxinfo: diff --git a/mapbox-gl-native-android/MapboxGLAndroidSDK/build.gradle b/mapbox-gl-native-android/MapboxGLAndroidSDK/build.gradle index efb676534..5b28d32f9 100644 --- a/mapbox-gl-native-android/MapboxGLAndroidSDK/build.gradle +++ b/mapbox-gl-native-android/MapboxGLAndroidSDK/build.gradle @@ -101,5 +101,5 @@ apply from: "${rootDir}/gradle/gradle-checkstyle.gradle" apply from: "${rootDir}/gradle/gradle-dependencies-graph.gradle" apply from: "${rootDir}/gradle/gradle-update-vendor-modules.gradle" apply from: "${rootDir}/gradle/android-nitpick.gradle" -apply from: "${rootDir}/gradle/gradle-bintray.gradle" +apply from: "${rootDir}/gradle/gradle-gitpackages.gradle" apply from: "${rootDir}/gradle/jacoco-report.gradle" \ No newline at end of file diff --git a/mapbox-gl-native-android/gradle/artifact-settings.gradle b/mapbox-gl-native-android/gradle/artifact-settings.gradle index acf29eeb8..ac190e6b4 100644 --- a/mapbox-gl-native-android/gradle/artifact-settings.gradle +++ b/mapbox-gl-native-android/gradle/artifact-settings.gradle @@ -1,15 +1,16 @@ ext { - mapboxArtifactGroupId = 'com.mapbox.mapboxsdk' - mapboxArtifactId = 'mapbox-android-sdk' - mapboxArtifactTitle = 'Mapbox Maps SDK for Android' - mapboxArtifactDescription = 'Mapbox Maps SDK for Android' - mapboxDeveloperName = 'Mapbox' - mapboxDeveloperId = 'mapbox' - mapboxArtifactUrl = 'https://github.com/mapbox/mapbox-gl-native' - mapboxArtifactVcsUrl = 'https://github.com/mapbox/mapbox-gl-native.git' - mapboxArtifactScmUrl = 'scm:git@github.com:mapbox/mapbox-gl-native.git' + mapboxArtifactGroupId = 'com.maptiler.gl' + mapboxArtifactId = 'android-sdk' + mapboxArtifactTitle = 'MapTiler Maps SDK for Android' + mapboxArtifactDescription = 'MapTiler Maps SDK for Android' + mapboxDeveloperName = 'MapTiler' + mapboxDeveloperId = 'maptiler' + mapboxArtifactUrl = 'https://github.com/maptiler/maptiler-gl-mobile' + mapboxArtifactVcsUrl = 'https://github.com/maptiler/maptiler-gl-mobile.git' + mapboxArtifactScmUrl = 'scm:git@github.com:maptiler/maptiler-gl-mobile.git' mapboxArtifactLicenseName = 'BSD' mapboxArtifactLicenseUrl = 'https://opensource.org/licenses/BSD-2-Clause' + mapboxPackageRepository = 'https://maven.pkg.github.com/maptiler/maptiler-gl-mobile' versionName = project.hasProperty('VERSION_NAME') ? project.property('VERSION_NAME') : System.getenv('VERSION_NAME') mapboxBintrayUserOrg = 'mapbox' diff --git a/mapbox-gl-native-android/gradle/gradle-gitpackages.gradle b/mapbox-gl-native-android/gradle/gradle-gitpackages.gradle new file mode 100644 index 000000000..e3bb81b67 --- /dev/null +++ b/mapbox-gl-native-android/gradle/gradle-gitpackages.gradle @@ -0,0 +1,85 @@ +apply plugin: 'digital.wup.android-maven-publish' +apply plugin: 'maven-publish' +apply from: file('../gradle/artifact-settings.gradle') + +version = project.ext.versionName +group = project.ext.mapboxArtifactGroupId + +publishing { + publications { + MapboxMapsSdkPublication(MavenPublication) { + from components.android + groupId this.group + artifactId project.ext.mapboxArtifactId + version this.version + + afterEvaluate { + artifact(androidSourcesJar) + artifact(androidJavadocsJar) + } + + pom.withXml { + final mainNode = asNode() + mainNode.appendNode('name', project.ext.mapboxArtifactTitle) + mainNode.appendNode('description', project.ext.mapboxArtifactTitle) + mainNode.appendNode('url', project.ext.mapboxArtifactUrl) + + final licenseNode = mainNode.appendNode('licenses').appendNode('license') + licenseNode.appendNode('name', project.ext.mapboxArtifactLicenseName) + licenseNode.appendNode('url', project.ext.mapboxArtifactLicenseUrl) + licenseNode.appendNode('distribution', "repo") + + final developerNode = mainNode.appendNode('developers').appendNode('developer') + developerNode.appendNode('id', project.ext.mapboxDeveloperId) + developerNode.appendNode('name', project.ext.mapboxDeveloperName) + + final scmNode = mainNode.appendNode("scm") + scmNode.appendNode("connection", project.ext.mapboxArtifactScmUrl) + scmNode.appendNode("developerConnection", project.ext.mapboxArtifactScmUrl) + scmNode.appendNode("url", project.ext.mapboxArtifactUrl) + } + } + } + repositories { + maven { + name = "GitHubPackages" + url = project.ext.mapboxPackageRepository + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + } +} + +task androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.java.sourceFiles + classpath = files(android.bootClasspath) + failOnError = false +} + +task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + classifier = 'javadoc' + from androidJavadocs.destinationDir +} + +task androidSourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.sourceFiles +} + +tasks.withType(Javadoc) { + options.addStringOption('encoding', 'UTF-8') + options.addStringOption('docencoding', 'UTF-8') + options.addStringOption('charset', 'UTF-8') +} + +afterEvaluate { project -> + android.libraryVariants.all { variant -> + tasks.androidJavadocs.doFirst { + classpath += files(variant.javaCompile.classpath.files) + } + } +} + + diff --git a/mapbox-gl-native-android/scripts/release-notes-github.md.ejs b/mapbox-gl-native-android/scripts/release-notes-github.md.ejs new file mode 100644 index 000000000..fd33e7a09 --- /dev/null +++ b/mapbox-gl-native-android/scripts/release-notes-github.md.ejs @@ -0,0 +1,3 @@ +<%-CHANGELOG-%> + + diff --git a/mapbox-gl-native-android/scripts/release-notes.js b/mapbox-gl-native-android/scripts/release-notes.js new file mode 100755 index 000000000..8000ecb0b --- /dev/null +++ b/mapbox-gl-native-android/scripts/release-notes.js @@ -0,0 +1,74 @@ +#!/usr/bin/env node + +const fs = require('fs'); +const execSync = require('child_process').execSync; +const ejs = require('ejs'); +const _ = require('lodash'); +const semver = require('semver'); + +const changelogPath = 'CHANGELOG.md'; +const changelog = fs.readFileSync(changelogPath, 'utf8'); + +/* + Find current and immediately previous releases by parsing git tags. +*/ +let currentVersion = execSync('git describe --tags --match=android-v*.*.* --abbrev=0') + .toString() + .trim() + .replace('android-v', ''); + +let gitTags = execSync('git tag --list android-v*.*.*') + .toString() + .split('\n') + .map(function (tag) { + tag = tag.replace('android-v', '').trim(); + return semver.clean(tag); + }); +let previousVersion = semver.maxSatisfying(gitTags, "<" + currentVersion); + +/* + Parse the raw changelog text and split it into individual releases. + + This regular expression: + - Matches lines starting with "## x.x.x". + - Groups the version number. + - Skips the (optional) release date. + - Groups the changelog content. + - Ends when another "## x.x.x" is found. +*/ +const regex = /^## (\d+\.\d+\.\d+).*?\n(.+?)(?=\n^## \d+\.\d+\.\d+.*?\n)/gms; + +let releaseNotes = []; +while (match = regex.exec(changelog)) { + releaseNotes.push({ + 'version': match[1], + 'changelog': match[2].trim(), + }); +} + +/* + Match the current tag with the most appropriate release notes. +*/ +const versionsInReleaseNotes = _.map(releaseNotes, 'version'); +const bestReleaseNotesForCurrentVersion = semver.minSatisfying(versionsInReleaseNotes, ">=" + currentVersion); +const currentReleaseNotes = _.find(releaseNotes, { version: bestReleaseNotesForCurrentVersion }); + +if (!currentReleaseNotes) { + console.error('Could not find a release section satisfying %s in %s — did you forget to rename the "master" section to %s?', currentVersion, changelogPath, currentVersion.split("-")[0]); + process.exit(1); +} + +/* + Fill and print the release notes template. +*/ +let templatedReleaseNotes; + +templatedReleaseNotes = ejs.render(fs.readFileSync('scripts/release-notes-github.md.ejs', 'utf8'), { + 'CURRENTVERSION': currentVersion, + 'PREVIOUSVERSION': previousVersion, + 'CHANGELOG': currentReleaseNotes.changelog, + 'isPrerelease': semver.prerelease(currentVersion) +}); +templatedReleaseNotes = templatedReleaseNotes.trimEnd(); + +process.stdout.write(templatedReleaseNotes); diff --git a/mapbox-gl-native-ios/Makefile b/mapbox-gl-native-ios/Makefile index b3e659a70..693a13a9a 100644 --- a/mapbox-gl-native-ios/Makefile +++ b/mapbox-gl-native-ios/Makefile @@ -57,7 +57,7 @@ endif .PHONY: default default: test -BUILD_DEPS += ./vendor/mapbox-gl-native/CMakeLists.txt +BUILD_DEPS += ../mapbox-gl-native/CMakeLists.txt BUILD_DOCS ?= true @@ -150,6 +150,11 @@ ios: $(IOS_PROJ_PATH) iproj: $(IOS_PROJ_PATH) xed $(IOS_WORK_PATH) +.PHONY: ios-lint-plist +ios-lint-plist: + find platform/ios/framework -type f -name '*.plist' | xargs plutil -lint + find platform/ios/app -type f -name '*.plist' | xargs plutil -lint + .PHONY: ios-lint ios-lint: ios-pod-lint find platform/ios/framework -type f -name '*.plist' | xargs plutil -lint @@ -195,6 +200,11 @@ iframework: $(IOS_PROJ_PATH) FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=$(SYMBOLS) BUILD_DOCS=$(BUILD_DOCS) \ ./platform/ios/scripts/package.sh +.PHONY: xcframework +xcframework: $(IOS_PROJ_PATH) + FORMAT=$(FORMAT) SYMBOLS=$(SYMBOLS) BUILD_DOCS=$(BUILD_DOCS) \ + ./platform/ios/scripts/xcpackage.sh + .PHONY: ideploy ideploy: caffeinate -i ./platform/ios/scripts/deploy-packages.sh diff --git a/mapbox-gl-native-ios/platform/ios/scripts/deploy-packages.sh b/mapbox-gl-native-ios/platform/ios/scripts/deploy-packages.sh index 1a5b1e758..0eb5bed30 100755 --- a/mapbox-gl-native-ios/platform/ios/scripts/deploy-packages.sh +++ b/mapbox-gl-native-ios/platform/ios/scripts/deploy-packages.sh @@ -48,11 +48,13 @@ buildPackageStyle() { export GITHUB_USER=mapbox export GITHUB_REPO=mapbox-gl-native-ios export BUILDTYPE=Release +export PACKAGE_FORMAT=xcframework VERSION_TAG=${VERSION_TAG:-''} PUBLISH_VERSION= BINARY_DIRECTORY='build/ios' -GITHUB_RELEASE=${GITHUB_RELEASE:-true} +GITHUB_RELEASE=${GITHUB_RELEASE:-false} +BUILD_FOR_COCOAPODS=${BUILD_FOR_COCOAPODS:-false} PUBLISH_PRE_FLAG='' if [[ -z `which github-release` ]]; then @@ -72,6 +74,14 @@ if [[ ${GITHUB_RELEASE} = "false" ]]; then GITHUB_RELEASE=false # Assign bool, not just a string fi +if [[ ${BUILD_FOR_COCOAPODS} = "false" ]]; then + BUILD_FOR_COCOAPODS=false # Assign bool, not just a string +fi + +if [[ ${BUILD_FOR_COCOAPODS} = "true" ]]; then + BUILD_FOR_COCOAPODS=true # Assign bool, not just a string +fi + if [[ -z ${VERSION_TAG} ]]; then step "Determining version number from most recent relevant git tag…" VERSION_TAG=$( git describe --tags --match=ios-v*.*.* --abbrev=0 ) @@ -120,10 +130,31 @@ if [[ "${GITHUB_RELEASE}" == true ]]; then fi # Used for binary release on Github - includes events SDK -buildPackageStyle "iframework" "dynamic-with-events" +buildPackageStyle "${PACKAGE_FORMAT}" "dynamic" + +echo "Binary artifact zip file: ${BINARY_ARTIFACT_ZIP_FILE}" +echo "Binary artifact url: ${BINARY_ARTIFACT_URL}" + +if [[ !-z "${BINARY_ARTIFACT_URL}" ]]; then + step "Creating Swift package…" + + rm -f Package.swift + cp swift_package_template.swift Package.swift + sed -i "s/__PACKAGE_URL__/${BINARY_ARTIFACT_URL}/g" Package.swift + CHECKSUM=$(swift package compute-checksum ${BINARY_ARTIFACT_ZIP_FILE}) + echo "Checksum: ${CHECKSUM}" + sed -i "s/__PACKAGE_CHECKSUM__/${CHECKSUM}/g" Package.swift + cat Package.swift +fi + + +if [[ ${BUILD_FOR_COCOAPODS} == true ]]; then + # Used for Cocoapods/Carthage + buildPackageStyle "${PACKAGE_FORMAT}" "dynamic" + buildPackageStyle "${PACKAGE_FORMAT} SYMBOLS=NO" "stripped-dynamic" +fi + + -# Used for Cocoapods/Carthage -buildPackageStyle "iframework" "dynamic" -buildPackageStyle "iframework SYMBOLS=NO" "stripped-dynamic" step "Finished deploying ${PUBLISH_VERSION} in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds" diff --git a/mapbox-gl-native-ios/platform/ios/scripts/deploy-swift-package.sh b/mapbox-gl-native-ios/platform/ios/scripts/deploy-swift-package.sh new file mode 100755 index 000000000..a04d6c1f3 --- /dev/null +++ b/mapbox-gl-native-ios/platform/ios/scripts/deploy-swift-package.sh @@ -0,0 +1,186 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail +set -u + +# dynamic environment variables: +# VERSION_TAG={determined automatically}: Version tag in format ios-vX.X.X-pre.X + +# environment variables and dependencies: +# - You must run "mbx auth ..." before running +# - Set GITHUB_TOKEN to a GitHub API access token in your environment +# - The "github-release" command is required + +function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } +function finish { >&2 echo -en "\033[0m"; } +trap finish EXIT + +export GITHUB_USER=maptiler +export GITHUB_REPO=maptiler-gl-mobile +export BUILDTYPE=Release + +VERSION_TAG=${VERSION_TAG:-''} +PUBLISH_VERSION= +BINARY_DIRECTORY='build/ios/pkg/dynamic' +PUBLISH_PRE_FLAG='' +S3_DISTRIBUTION=false + +uploadToGithub() { + local file_path=$1 + local version_tag=$2 + file_name=${file_path##*/} + github-release upload \ + --tag "${version_tag}" \ + --name ${file_name} \ + --file "${file_path}" > /dev/null + + EXT_TARGET_GITHUB_URL="https://github.com/${GITHUB_USER}/${GITHUB_REPO}/releases/download/${version_tag}/${file_name}" +} + +uploadToS3() { + local file_path=$1 + local progress=$2 + file_name=${file_path##*/} + + PROGRESS="" + if [ "${progress}" == false ]; then + PROGRESS="--no-progress" + fi + + local target_s3_location="s3://mapbox-gl-native/ios/builds/${file_name}" + local target_s3_url="https://mapbox-gl-native.s3.us-east-2.amazonaws.com/ios/builds/${file_name}" + + aws s3 cp ${file_path} ${target_s3_location} --acl public-read ${PROGRESS} + + EXT_TARGET_S3_URL="${target_s3_url}" +} + +rm -rf ${BINARY_DIRECTORY} + +if [[ -z `which github-release` ]]; then + step "Installing github-release…" + brew install github-release + if [ -z `which github-release` ]; then + echo "Unable to install github-release. See: https://github.com/aktau/github-release" + exit 1 + fi +fi + +if [[ -z `which jq` ]]; then + step "Installing jq …" + brew install jq + if [ -z `which jq` ]; then + echo "Unable to install which jq." + exit 1 + fi +fi + +if [[ -z ${VERSION_TAG} ]]; then + step "Determining version number from most recent relevant git tag…" + VERSION_TAG=$( git describe --tags --match=ios-v*.*.* --abbrev=0 ) + echo "Found tag: ${VERSION_TAG}" +fi + +if [[ $( echo ${VERSION_TAG} | grep --invert-match ios-v ) ]]; then + echo "Error: ${VERSION_TAG} is not a valid iOS version tag" + echo "VERSION_TAG should be in format: ios-vX.X.X-pre.X" + exit 1 +fi +if github-release info --tag ${VERSION_TAG} | grep --quiet "draft: ✗"; then + echo "Error: ${VERSION_TAG} has already been published on GitHub" + echo "See: https://github.com/${GITHUB_USER}/${GITHUB_REPO}/releases/tag/${VERSION_TAG}" + exit 1 +fi +PUBLISH_VERSION=$( echo ${VERSION_TAG} | sed 's/^ios-v//' ) + +npm install --ignore-scripts +mkdir -p ${BINARY_DIRECTORY} + +step "Building: make xcframework" +make xcframework + +step "Zipping xcframeworks…" +MAPBOX_ZIP_FILE="Mapbox-${PUBLISH_VERSION}.zip" +(cd ${BINARY_DIRECTORY} && rm -f ${MAPBOX_ZIP_FILE} && zip -yr ${MAPBOX_ZIP_FILE} Mapbox.xcframework) +MAPBOX_EVENTS_ZIP_FILE="MapboxMobileEvents-${PUBLISH_VERSION}.zip" +(cd ${BINARY_DIRECTORY} && rm -f ${MAPBOX_EVENTS_ZIP_FILE} && zip -yr ${MAPBOX_EVENTS_ZIP_FILE} MapboxMobileEvents.xcframework) + +if [[ ${S3_DISTRIBUTION} == true ]]; then + step "Uploading ${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE} to s3" + uploadToS3 "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" false + MAPBOX_ZIP_FILE_URL=$EXT_TARGET_S3_URL + step "Uploading ${BINARY_DIRECTORY}/${MAPBOX_EVENTS_ZIP_FILE} to s3" + uploadToS3 "${BINARY_DIRECTORY}/${MAPBOX_EVENTS_ZIP_FILE}" false + MAPBOX_EVENTS_ZIP_FILE_URL=$EXT_TARGET_S3_URL +fi + +step "Create GitHub release…" +RELEASE_NOTES=$( ./platform/ios/scripts/release-notes.js github ) + +if [[ -z "${RELEASE_NOTES}" ]]; then + echo "Release notes cannot be empty." + exit 1 +fi + +github-release release \ + --tag "ios-v${PUBLISH_VERSION}" \ + --name "ios-v${PUBLISH_VERSION}" \ + --description "${RELEASE_NOTES}" + +step "Uploading ${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE} to github release [${VERSION_TAG}]" +uploadToGithub "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" "${VERSION_TAG}" +MAPBOX_ZIP_FILE_URL=$EXT_TARGET_GITHUB_URL +step "Uploading ${BINARY_DIRECTORY}/${MAPBOX_EVENTS_ZIP_FILE} to github releases" +uploadToGithub "${BINARY_DIRECTORY}/${MAPBOX_EVENTS_ZIP_FILE}" "${VERSION_TAG}" +MAPBOX_EVENTS_ZIP_FILE_URL=$EXT_TARGET_GITHUB_URL + +step "Creating Swift package…" + +rm -f Package.swift +cp platform/ios/scripts/swift_package_template.swift Package.swift + +setTarget() { + local token=$1 + local targetBinaryPath=$2 + local targetUrl=$3 + local checksum=$(swift package compute-checksum ${targetBinaryPath}) + + echo "token=[${token}]" + echo "url=[$targetUrl]" + echo "cheksum=[$checksum]" + + sed -i '' -e 's|'"${token}_PACKAGE_URL"'|'"${targetUrl}"'|g' Package.swift + sed -i '' -e 's|'"${token}_PACKAGE_CHECKSUM"'|'"${checksum}"'|g' Package.swift +} + +setTarget "MAPBOX" "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" "${MAPBOX_ZIP_FILE_URL}" +setTarget "MAPBOX_EVENTS" "${BINARY_DIRECTORY}/${MAPBOX_EVENTS_ZIP_FILE}" "${MAPBOX_EVENTS_ZIP_FILE_URL}" + +step "Publishing Swift package…" + +DISTRIBUTION_GITHUB_REPO=https://api.github.com/repos/maptiler/maptiler-gl-mobile-distribution + +if [[ -z "${DIST_GITHUB_TOKEN}" ]]; then + echo "DIST_GITHUB_TOKEN is not set" + exit 1 +fi + +UPDATED_PACKAGE_CONTENT=$(cat Package.swift | base64) +ORIGINAL_FILE_SHA="$(curl -H "Authorization: token ${DIST_GITHUB_TOKEN}" ${DISTRIBUTION_GITHUB_REPO}/contents/Package.swift | jq -r -c '.sha')" +PAYLOAD="{\"message\": \"New release: ${PUBLISH_VERSION}\",\"content\": \"$UPDATED_PACKAGE_CONTENT\", \"sha\": \"$ORIGINAL_FILE_SHA\"}" + +# package definition update +curl -v -X PUT \ + -H "Authorization: token ${DIST_GITHUB_TOKEN}" \ + "${DISTRIBUTION_GITHUB_REPO}"/contents/Package.swift \ + -d "${PAYLOAD}" + +# setting up new tag +curl -v -X POST \ + -H "Authorization: token ${DIST_GITHUB_TOKEN}" \ + -H "Accept: application/vnd.github.v3+json" \ + "${DISTRIBUTION_GITHUB_REPO}"/releases \ + -d "{\"tag_name\":\"${PUBLISH_VERSION}\"}" + +step "Finished deploying ${PUBLISH_VERSION} in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds" diff --git a/mapbox-gl-native-ios/platform/ios/scripts/install-packaging-dependencies.sh b/mapbox-gl-native-ios/platform/ios/scripts/install-packaging-dependencies.sh index 6d63c9764..ec2b8b1e3 100755 --- a/mapbox-gl-native-ios/platform/ios/scripts/install-packaging-dependencies.sh +++ b/mapbox-gl-native-ios/platform/ios/scripts/install-packaging-dependencies.sh @@ -4,7 +4,7 @@ set -euo pipefail COCOAPODS_VERSION="1.7.5" JAZZY_VERSION="0.11.1" -CIRCLECI=${CIRCLECI:-false} +CILAUNCH=${CILAUNCH:-false} function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } function finish { >&2 echo -en "\033[0m"; } @@ -21,25 +21,6 @@ else echo "Found awscli" fi -## -## cocoapods -## -if [[ -z `which pod` || $(pod --version) != "${COCOAPODS_VERSION}" ]]; then - step "Installing cocoapods…" - - if [[ "${CIRCLECI}" == true ]]; then - sudo gem install cocoapods -v $COCOAPODS_VERSION --no-document - else - gem install cocoapods -v $COCOAPODS_VERSION --no-document - fi - - if [ -z `which pod` ]; then - echo "Unable to install cocoapods ($COCOAPODS_VERSION)." - exit 1 - fi -else - echo "Found cocoapods (${COCOAPODS_VERSION})" -fi ## ## jazzy @@ -47,7 +28,7 @@ fi if [[ -z `which jazzy` || $(jazzy -v) != "jazzy version: ${JAZZY_VERSION}" ]]; then step "Installing jazzy…" - if [[ "${CIRCLECI}" == true ]]; then + if [[ "${CILAUNCH}" == true ]]; then sudo gem install jazzy -v $JAZZY_VERSION --no-document else gem install jazzy -v $JAZZY_VERSION --no-document diff --git a/mapbox-gl-native-ios/platform/ios/scripts/package.sh b/mapbox-gl-native-ios/platform/ios/scripts/package.sh index dc3a518cb..51c00824e 100755 --- a/mapbox-gl-native-ios/platform/ios/scripts/package.sh +++ b/mapbox-gl-native-ios/platform/ios/scripts/package.sh @@ -59,7 +59,7 @@ fi step "Recording library version…" VERSION="${OUTPUT}"/version.txt -echo -n "https://github.com/mapbox/mapbox-gl-native-ios/commit/" > ${VERSION} +echo -n "https://github.com/maptiler/mapbox-gl-mobile/commit/" > ${VERSION} HASH=`git log | head -1 | awk '{ print $2 }' | cut -c 1-10` && true echo -n "mapbox-gl-native-ios " echo ${HASH} diff --git a/mapbox-gl-native-ios/platform/ios/scripts/publish.sh b/mapbox-gl-native-ios/platform/ios/scripts/publish.sh index ba7bff1c8..877abb50e 100755 --- a/mapbox-gl-native-ios/platform/ios/scripts/publish.sh +++ b/mapbox-gl-native-ios/platform/ios/scripts/publish.sh @@ -18,23 +18,23 @@ else PUBLISH_STYLE="" fi -GITHUB_REPO=${GITHUB_REPO:-'mapbox-gl-native-ios'} +GITHUB_REPO=${GITHUB_REPO:-'maptiler-gl-native'} # # zip # cd build/ios/pkg -ZIP_FILENAME="mapbox-ios-sdk-${PUBLISH_VERSION}${PUBLISH_STYLE}.zip" -step "Compressing ${ZIP_FILENAME}…" -rm -f ../${ZIP_FILENAME} -zip -yr ../${ZIP_FILENAME} * +BINARY_ARTIFACT_ZIP_FILE="mapbox-ios-sdk-${PUBLISH_VERSION}${PUBLISH_STYLE}.zip" +step "Compressing ${BINARY_ARTIFACT_ZIP_FILE}…" +rm -f ../${BINARY_ARTIFACT_ZIP_FILE} +zip -yr ../${BINARY_ARTIFACT_ZIP_FILE} * cd .. # # report file sizes # step "Echoing file sizes…" -du -sh ${ZIP_FILENAME} +du -sh ${BINARY_ARTIFACT_ZIP_FILE} du -sch pkg/* du -sch pkg/dynamic/* @@ -51,11 +51,13 @@ if [ -n "${CI:-}" ]; then PROGRESS="--no-progress" fi -step "Uploading ${ZIP_FILENAME} to s3… ${DRYRUN}" +step "Uploading ${BINARY_ARTIFACT_ZIP_FILE} to s3… ${DRYRUN}" -aws s3 cp ${ZIP_FILENAME} s3://mapbox/mapbox-gl-native/ios/builds/ --acl public-read ${PROGRESS} ${DRYRUN} -S3_URL=https://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/builds/${ZIP_FILENAME} -echo "URL: ${S3_URL}" +aws s3 cp ${BINARY_ARTIFACT_ZIP_FILE} s3://mapbox-gl-native/ios/builds --acl public-read ${PROGRESS} ${DRYRUN} +BINARY_ARTIFACT_URL=https://mapbox-gl-native.s3.us-east-2.amazonaws.com/ios/builds/${BINARY_ARTIFACT_ZIP_FILE} +export BINARY_ARTIFACT_URL +export BINARY_ARTIFACT_ZIP_FILE +echo "URL: ${BINARY_ARTIFACT_URL}" echo "mapbox-gl-native is currently hardcoded" # @@ -63,10 +65,10 @@ echo "mapbox-gl-native is currently hardcoded" # if [[ ${PUBLISH_VERSION} =~ "snapshot" ]]; then step "Updating ${PUBLISH_VERSION} to ${PUBLISH_STYLE}…" - GENERIC_ZIP_FILENAME="mapbox-ios-sdk-${PUBLISH_VERSION}.zip" + GENERIC_BINARY_ARTIFACT_ZIP_FILE="mapbox-ios-sdk-${PUBLISH_VERSION}.zip" aws s3 cp \ - s3://mapbox/mapbox-gl-native/ios/builds/${ZIP_FILENAME} \ - s3://mapbox/mapbox-gl-native/ios/builds/${GENERIC_ZIP_FILENAME} --acl public-read ${PROGRESS} ${DRYRUN} + s3://mapbox-gl-native/ios/builds/${BINARY_ARTIFACT_ZIP_FILE} \ + s3://mapbox-gl-native/ios/builds/${GENERIC_BINARY_ARTIFACT_ZIP_FILE} --acl public-read ${PROGRESS} ${DRYRUN} fi # @@ -76,9 +78,9 @@ fi step "Validating local and remote checksums…" if [[ ! ${SKIP_S3-} ]]; then - curl --output remote-${ZIP_FILENAME} ${S3_URL} - LOCAL_CHECKSUM=$( shasum -a 256 -b ${ZIP_FILENAME} | cut -d ' ' -f 1 ) - REMOTE_CHECKSUM=$( shasum -a 256 -b remote-${ZIP_FILENAME} | cut -d ' ' -f 1 ) + curl --output remote-${BINARY_ARTIFACT_ZIP_FILE} ${BINARY_ARTIFACT_URL} + LOCAL_CHECKSUM=$( shasum -a 256 -b ${BINARY_ARTIFACT_ZIP_FILE} | cut -d ' ' -f 1 ) + REMOTE_CHECKSUM=$( shasum -a 256 -b remote-${BINARY_ARTIFACT_ZIP_FILE} | cut -d ' ' -f 1 ) if [ "${LOCAL_CHECKSUM}" == "${REMOTE_CHECKSUM}" ]; then echo "Checksums match: ${LOCAL_CHECKSUM}" diff --git a/mapbox-gl-native-ios/platform/ios/scripts/release-notes-github.md.ejs b/mapbox-gl-native-ios/platform/ios/scripts/release-notes-github.md.ejs index 759894421..d0affd8d5 100644 --- a/mapbox-gl-native-ios/platform/ios/scripts/release-notes-github.md.ejs +++ b/mapbox-gl-native-ios/platform/ios/scripts/release-notes-github.md.ejs @@ -1,9 +1,2 @@ -[Changes](https://github.com/mapbox/mapbox-gl-native-ios/compare/ios-v<%-PREVIOUSVERSION%>...ios-v<%-CURRENTVERSION%>) since [Mapbox Maps SDK for iOS v<%-PREVIOUSVERSION%>](https://github.com/mapbox/mapbox-gl-native-ios/releases/tag/ios-v<%-PREVIOUSVERSION%>): - <%-CHANGELOG-%> -<% if (isPrerelease) { %> -To install this pre-release via a dependency manager, see our [CocoaPods](https://github.com/mapbox/mapbox-gl-native-ios/blob/ios-v<%-CURRENTVERSION%>/platform/ios/INSTALL.md#CocoaPods) or [Carthage](https://github.com/mapbox/mapbox-gl-native-ios/blob/ios-v<%-CURRENTVERSION%>/platform/ios/INSTALL.md#Carthage) instructions. -<% } -%> - -Documentation is [available online](https://www.mapbox.com/ios-sdk/api/<%-CURRENTVERSION%>/) or as part of the download. diff --git a/mapbox-gl-native-ios/platform/ios/scripts/swift_package_template.swift b/mapbox-gl-native-ios/platform/ios/scripts/swift_package_template.swift new file mode 100644 index 000000000..175e8e10d --- /dev/null +++ b/mapbox-gl-native-ios/platform/ios/scripts/swift_package_template.swift @@ -0,0 +1,26 @@ +// swift-tools-version:5.3 +import PackageDescription + +let package = Package( + name: "maptiler-gl-mobile", + products: [ + .library( + name: "Mapbox", + targets: ["Mapbox"]), + .library( + name: "MapboxMobileEvents", + targets: ["MapboxMobileEvents"]) + ], + dependencies: [ + ], + targets: [ + .binaryTarget( + name: "Mapbox", + url: "MAPBOX_PACKAGE_URL", + checksum: "MAPBOX_PACKAGE_CHECKSUM"), + .binaryTarget( + name: "MapboxMobileEvents", + url: "MAPBOX_EVENTS_PACKAGE_URL", + checksum: "MAPBOX_EVENTS_PACKAGE_CHECKSUM") + ] +) \ No newline at end of file diff --git a/mapbox-gl-native-ios/platform/ios/scripts/xcpackage.sh b/mapbox-gl-native-ios/platform/ios/scripts/xcpackage.sh new file mode 100755 index 000000000..222cda370 --- /dev/null +++ b/mapbox-gl-native-ios/platform/ios/scripts/xcpackage.sh @@ -0,0 +1,159 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail +set -u + +NAME=Mapbox +OUTPUT=build/ios/pkg +DERIVED_DATA=build/ios +PRODUCTS=${DERIVED_DATA} +LOG_PATH=build/xcodebuild-$(date +"%Y-%m-%d_%H%M%S").log + +BUILD_DOCS=${BUILD_DOCS:-true} +SYMBOLS=${SYMBOLS:-YES} + +BUILDTYPE=${BUILDTYPE:-Debug} +if [[ ${SYMBOLS} == YES && ${BUILDTYPE} == Release ]]; then + BUILDTYPE='RelWithDebInfo' +fi + +FORMAT=${FORMAT:-dynamic} +if [[ ${FORMAT} != "dynamic" ]]; then + echo "Error: only dynamic FORMAT is supported in xcpackage build." + exit 1 +fi + +function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } +function finish { >&2 echo -en "\033[0m"; } +trap finish EXIT + +IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version` +IOS_SIM_SDK_VERSION=`xcrun --sdk iphonesimulator --show-sdk-version` + +step "Configuring ${FORMAT} framework for iphoneos ${IOS_SDK_VERSION} and iphonesimulator ${IOS_SIM_SDK_VERSION} (symbols: ${SYMBOLS}, buildtype: ${BUILDTYPE})" + +xcodebuild -version + +rm -rf ${OUTPUT} +BINOUT="${OUTPUT}"/dynamic +mkdir -p ${BINOUT} + +step "Recording library version…" +VERSION="${OUTPUT}"/version.txt +echo -n "https://github.com/maptiler/mapbox-gl-mobile/commit/" > ${VERSION} +HASH=`git log | head -1 | awk '{ print $2 }' | cut -c 1-10` && true +echo -n "mapbox-gl-native-ios " +echo ${HASH} +echo ${HASH} >> ${VERSION} + +PROJ_VERSION=$(git rev-list --count HEAD) +SEM_VERSION=$( git describe --tags --match=ios-v*.*.* --abbrev=0 | sed 's/^ios-v//' ) +SHORT_VERSION=${SEM_VERSION%-*} + +step "Building targets (build ${PROJ_VERSION}, version ${SEM_VERSION})" + +SCHEME='dynamic' + +CI_XCCONFIG='' +if [[ ! -z "${CI:=}" ]]; then + xcconfig='platform/darwin/ci.xcconfig' + echo "CI environment, using ${xcconfig}" + CI_XCCONFIG="-xcconfig ./${xcconfig}" +fi + +step "Building ${FORMAT} archive for iOS Simulator using ${SCHEME} scheme -> ${BINOUT}/${NAME}-iphonesimulator.xcarchive" +xcodebuild \ + archive \ + CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \ + CURRENT_COMMIT_HASH=${HASH} \ + SKIP_INSTALL=NO \ + BUILD_LIBRARY_FOR_DISTRIBUTION=YES \ + -workspace ./platform/ios/ios.xcworkspace \ + -archivePath ${BINOUT}/${NAME}-iphonesimulator.xcarchive \ + -scheme ${SCHEME} \ + -configuration ${BUILDTYPE} \ + -sdk iphonesimulator \ + -jobs ${JOBS} | tee ${LOG_PATH} | xcpretty + +step "Building ${FORMAT} archive for iOS devices using ${SCHEME} scheme -> ${BINOUT}/${NAME}-iphoneos.xcarchive" +xcodebuild \ + archive \ + CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \ + CURRENT_COMMIT_HASH=${HASH} \ + SKIP_INSTALL=NO \ + BUILD_LIBRARY_FOR_DISTRIBUTION=YES \ + -workspace ./platform/ios/ios.xcworkspace \ + -archivePath ${BINOUT}/${NAME}-iphoneos.xcarchive \ + -scheme ${SCHEME} \ + -configuration ${BUILDTYPE} \ + -sdk iphoneos \ + -jobs ${JOBS} | tee ${LOG_PATH} | xcpretty + +LIBS=(Mapbox.a) + +function realpath { + [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" +} + +function addFramework { + local archive=$1 + local frameworkName=$2 + local includeDebugSymbols=$3 + + local frameworkPath="${archive}/Products/Library/Frameworks/${frameworkName}.framework" + BUILD_ARGS="$BUILD_ARGS -framework $frameworkPath" + + if [[ $includeDebugSymbols == true ]]; then + SYMBOL_PATH=$(realpath "${archive}/dSYMs/${frameworkName}.framework.dSYM") + BUILD_ARGS="$BUILD_ARGS -debug-symbols ${SYMBOL_PATH}" + fi +} + + +step "Creating ${NAME} xcframework" + +EVENTS_NAME=MapboxMobileEvents +INCLUDE_DEBUG_SYMBOLS=false +if [[ $BUILDTYPE='RelWithDebInfo' || $BUILDTYPE='Debug' ]]; then + INCLUDE_DEBUG_SYMBOLS=true +fi + + +# Mapbox mobile +BUILD_ARGS="" +addFramework "${BINOUT}/${NAME}-iphoneos.xcarchive" ${NAME} ${INCLUDE_DEBUG_SYMBOLS} +addFramework "${BINOUT}/${NAME}-iphonesimulator.xcarchive" ${NAME} ${INCLUDE_DEBUG_SYMBOLS} +BUILD_ARGS="$BUILD_ARGS -output ${BINOUT}/${NAME}.xcframework" +echo "Creating ${NAME}.xcframework with args: $BUILD_ARGS" +xcodebuild -create-xcframework $BUILD_ARGS +echo "${NAME}.xcframework created" + +# Mapbox mobile events +BUILD_ARGS="" +BUILD_ARGS="$BUILD_ARGS -output ${BINOUT}/${EVENTS_NAME}.xcframework" +addFramework "${BINOUT}/${NAME}-iphoneos.xcarchive" ${EVENTS_NAME} ${INCLUDE_DEBUG_SYMBOLS} +addFramework "${BINOUT}/${NAME}-iphonesimulator.xcarchive" ${EVENTS_NAME} ${INCLUDE_DEBUG_SYMBOLS} +echo "Creating ${EVENTS_NAME}.xcframework with args: $BUILD_ARGS" +xcodebuild -create-xcframework $BUILD_ARGS +echo "${EVENTS_NAME}.xcframework created" + +step "Copying library resources…" +cp -pv LICENSE.md ${OUTPUT} +sed -n -e '/^## /,$p' platform/ios/CHANGELOG.md > "${OUTPUT}/CHANGELOG.md" + +rm -rf /tmp/mbgl +mkdir -p /tmp/mbgl/ +README=/tmp/mbgl/README.md +cp platform/ios/docs/pod-README.md "${README}" +sed -i '' -e '/{{STATIC}}/,/{{\/STATIC}}/d' "${README}" +sed -i '' \ + -e '/{{DYNAMIC}}/d' -e '/{{\/DYNAMIC}}/d' \ + -e '/{{STATIC}}/d' -e '/{{\/STATIC}}/d' \ + "${README}" +cp ${README} "${OUTPUT}" + +if [ ${BUILD_DOCS} == true ]; then + step "Generating API documentation for ${BUILDTYPE} Build…" + make idocument OUTPUT="${OUTPUT}/documentation" +fi diff --git a/mapbox-gl-native-ios/scripts/environment.js b/mapbox-gl-native-ios/scripts/environment.js index 759a7f2a4..bb462cfa6 100755 --- a/mapbox-gl-native-ios/scripts/environment.js +++ b/mapbox-gl-native-ios/scripts/environment.js @@ -6,29 +6,29 @@ const github = require('@octokit/rest')(); const {execSync} = require('child_process'); -const pr = process.env['CIRCLE_PULL_REQUEST']; +const pr = process.env['GITHUB_PULL_REQUEST']; if (pr) { const number = +pr.match(/\/(\d+)\/?$/)[1]; return github.pullRequests.get({ - owner: 'mapbox', - repo: 'mapbox-gl-native', + owner: 'maptiler', + repo: 'maptiler-gl-mobile', number }).then(({data}) => { const base = data.base.ref; - const head = process.env['CIRCLE_SHA1']; + const head = process.env['GITHUB_SHA']; const mergeBase = execSync(`git merge-base origin/${base} ${head}`).toString().trim(); - console.log(`export CIRCLE_TARGET_BRANCH=${base}`); - console.log(`export CIRCLE_MERGE_BASE=${mergeBase}`); + console.log(`export GITHUB_TARGET_BRANCH=${base}`); + console.log(`export GITHUB_MERGE_BASE=${mergeBase}`); }); } else { - const head = process.env['CIRCLE_SHA1']; + const head = process.env['GITHUB_SHA']; for (const sha of execSync(`git rev-list --max-count=500 ${head}`).toString().trim().split('\n')) { const base = execSync(`git branch -r --contains ${sha} origin/master origin/release-*`).toString().split('\n')[0].trim().replace(/^origin\//, ''); if (base) { const mergeBase = execSync(`git merge-base origin/${base} ${head}`).toString().trim(); - console.log(`export CIRCLE_TARGET_BRANCH=${base}`); - console.log(`export CIRCLE_MERGE_BASE=${mergeBase}`); + console.log(`export GITHUB_TARGET_BRANCH=${base}`); + console.log(`export GITHUB_MERGE_BASE=${mergeBase}`); break; } } diff --git a/mapbox-gl-native-ios/scripts/style-spec.js b/mapbox-gl-native-ios/scripts/style-spec.js index c0f03407b..75795020e 100644 --- a/mapbox-gl-native-ios/scripts/style-spec.js +++ b/mapbox-gl-native-ios/scripts/style-spec.js @@ -1 +1 @@ -module.exports = require('../vendor/mapbox-gl-native/mapbox-gl-js/src/style-spec/reference/v8'); +module.exports = require('../../mapbox-gl-native/mapbox-gl-js/src/style-spec/reference/v8');