Skip to content

Commit

Permalink
Prepare Android release workflow for Vulkan release (#3081)
Browse files Browse the repository at this point in the history
  • Loading branch information
louwers authored Dec 11, 2024
1 parent 2f13366 commit 780b736
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 42 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ name: android-release

on:
workflow_dispatch:
inputs:
renderer:
description: "Select renderering backend"
required: true
default: "OpenGL"
type: choice
options:
- OpenGL
- Vulkan

jobs:
build:
Expand All @@ -28,15 +19,6 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: Map renderer input
id: backend_lowercase
run: |
if [ "${{ github.event.inputs.renderer }}" = "OpenGL" ]; then
echo "backend_lowercase=drawable" >> "$GITHUB_ENV"
elif [ "${{ github.event.inputs.renderer }}" = "Vulkan" ]; then
echo "backend_lowercase=vulkan" >> "$GITHUB_ENV"
fi
- run: echo "cmake.dir=$(dirname "$(dirname "$(command -v cmake)")")" >> local.properties

- uses: actions/setup-java@v4
Expand Down Expand Up @@ -74,9 +56,9 @@ jobs:
shell: bash

- name: Build package
run: make apackage
env:
RENDERER: ${{ env.backend_lowercase }}
run: |
RENDERER=vulkan make apackage
RENDERER=opengl make apackage
- name: Build release Test App
run: |
Expand Down Expand Up @@ -123,25 +105,44 @@ jobs:
draft: false
prerelease: ${{ env.prerelease }}

- name: Upload aar
id: upload-release-asset
- name: Upload aar (OpenGL)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: platform/android/MapLibreAndroid/build/outputs/aar/MapLibreAndroid-${{ env.backend_lowercase }}-release.aar
asset_path: platform/android/MapLibreAndroid/build/outputs/aar/MapLibreAndroid-drawable-release.aar
asset_name: MapLibreAndroid-release.aar
asset_content_type: application/zip

- name: Upload debug symbols
- name: Upload aar (Vulkan)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: platform/android/MapLibreAndroid/build/outputs/aar/MapLibreAndroid-vulkan-release.aar
asset_name: MapLibreAndroid-release-vulkan.aar
asset_content_type: application/zip

- name: Upload debug symbols (OpenGL)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: platform/android/build/debug-symbols-opengl.tar.gz
asset_name: debug-symbols-maplibre-android-opengl-${{ steps.prepare_release.outputs.version_tag }}.tar.gz
asset_content_type: application/gzip

- name: Upload debug symbols (Vulkan)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: platform/android/build/debug-symbols.tar.gz
asset_name: debug-symbols.tar.gz
asset_path: platform/android/build/debug-symbols-vulkan.tar.gz
asset_name: debug-symbols-maplibre-android-vulkan-${{ steps.prepare_release.outputs.version_tag }}.tar.gz
asset_content_type: application/gzip

- name: Clean release
Expand All @@ -164,4 +165,3 @@ jobs:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
RENDERER: ${{ env.backend_lowercase }}
6 changes: 4 additions & 2 deletions platform/android/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,16 @@ run-android-unit-test:
run-android-unit-test-%:
$(MLN_ANDROID_GRADLE) -Pmaplibre.abis=none :MapLibreAndroid:testLegacyDebugUnitTest --info --tests "$*"

DEBUG_TAR_FILE_NAME := $(if $(findstring drawable,$(RENDERER)),debug-symbols-opengl.tar.gz,debug-symbols-$(RENDERER).tar.gz)

# Builds a release package and .tar.gz with debug symbols of the Android SDK
.PHONY: apackage
apackage:
echo "Building for $(RENDERER)"
make android-lib-arm-v7 && make android-lib-arm-v8 && make android-lib-x86 && make android-lib-x86-64
$(MLN_ANDROID_GRADLE) -Pmaplibre.abis=all assemble$(RENDERER)$(BUILDTYPE)
mkdir -p build
tar -czvf build/debug-symbols.tar.gz -C MapLibreAndroid/build/intermediates/library_jni/*/*JniLibsProjectOnly/jni .
tar -czvf build/$(DEBUG_TAR_FILE_NAME) -C MapLibreAndroid/build/intermediates/library_jni/$(RENDERER)Release/*JniLibsProjectOnly/jni .

# Build test app instrumentation tests apk and test app apk for all abi's
.PHONY: android-ui-test
Expand All @@ -245,7 +247,7 @@ run-android-test-app-center:
# Uploads the compiled Android SDK to Maven Central Staging
.PHONY: run-android-publish
run-android-publish:
$(MLN_ANDROID_GRADLE_SINGLE_JOB)-Pmaplibre.abis=all :MapLibreAndroid:publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
$(MLN_ANDROID_GRADLE_SINGLE_JOB)-Pmaplibre.abis=all :MapLibreAndroid:publishAllPublicationsToSonatypeRepository closeAndReleaseSonatypeStagingRepository

# Dump system graphics information for the test app
.PHONY: android-gfxinfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extra["mapLibreArtifactGroupId"] = "org.maplibre.gl"
extra["mapLibreArtifactId"] = "android-sdk"
extra["mapLibreArtifactTitle"] = "MapLibre Maps SDK for Android"
extra["mapLibreArtifactDescription"] = "MapLibre Maps SDK for Android"
extra["mapLibreArtifactTitle"] = "MapLibre Android"
extra["mapLibreArtifactDescription"] = "MapLibre Android"
extra["mapLibreDeveloperName"] = "MapLibre"
extra["mapLibreDeveloperId"] = "maplibre"
extra["mapLibreArtifactUrl"] = "https://github.com/maplibre/maplibre-native"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.gradle.kotlin.dsl.get
import java.util.Locale

plugins {
`maven-publish`
Expand Down Expand Up @@ -43,20 +44,24 @@ project.logger.lifecycle(project.extra["versionName"].toString())
version = project.extra["versionName"] as String
group = project.extra["mapLibreArtifactGroupId"] as String

afterEvaluate {
fun configureMavenPublication(
renderer: String,
publicationName: String,
artifactIdPostfix: String,
descriptionPostfix: String,
) {
publishing {
publications {
create<MavenPublication>("release") {
groupId = this@afterEvaluate.group.toString()
artifactId = project.extra["mapLibreArtifactId"].toString()
version = this@afterEvaluate.version.toString()
create<MavenPublication>(publicationName) {
groupId = project.group.toString()
artifactId = "${project.extra["mapLibreArtifactId"]}$artifactIdPostfix"
version = project.version.toString()

// Conditional component selection based on environment variable
from(components[if (System.getenv("RENDERER")?.lowercase() == "vulkan") "vulkanRelease" else "drawableRelease"])
from(components["${renderer}Release"])

pom {
name.set(project.extra["mapLibreArtifactTitle"].toString())
description.set(project.extra["mapLibreArtifactTitle"].toString())
name.set("${project.extra["mapLibreArtifactTitle"]}$descriptionPostfix")
description.set("${project.extra["mapLibreArtifactTitle"]}$descriptionPostfix")
url.set(project.extra["mapLibreArtifactUrl"].toString())
licenses {
license {
Expand All @@ -68,7 +73,7 @@ afterEvaluate {
developer {
id.set(project.extra["mapLibreDeveloperId"].toString())
name.set(project.extra["mapLibreDeveloperName"].toString())
email.set("maplibre@maplibre.org")
email.set("team@maplibre.org")
}
}
scm {
Expand All @@ -80,7 +85,24 @@ afterEvaluate {
}
}
}
}


// workaround for https://github.com/gradle/gradle/issues/26091#issuecomment-1836156762
// https://github.com/gradle-nexus/publish-plugin/issues/208
tasks {
withType<PublishToMavenRepository> {
dependsOn(withType<Sign>())
}
}

afterEvaluate {
configureMavenPublication("drawable", "opengl", "", "")
configureMavenPublication("vulkan", "vulkan", "-vulkan", "(Vulkan)")
// Right now this is the same as the first, but in the future we might release a major version
// which defaults to Vulkan (or has support for multiple backends). We will keep using only
// OpenGL ES with this artifact ID if that happens.
configureMavenPublication("drawable", "opengl2", "-opengl", " (OpenGL ES)")
}


Expand Down

0 comments on commit 780b736

Please sign in to comment.