Skip to content

Commit

Permalink
Merge pull request #47 from Rallista/feat/ci-release-cleanup
Browse files Browse the repository at this point in the history
Revisions and cleanup for CI release pipeline
  • Loading branch information
Archdoog authored Oct 20, 2024
2 parents 76ee451 + 4dbf744 commit 338bd50
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 3,558 deletions.
122 changes: 113 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: iOS Release
name: Release

on:
push:
branches: [main]
workflow_dispatch:
inputs:
bump_version_scheme:
Expand All @@ -16,14 +14,11 @@ on:
- "major"

jobs:
build:
build-ios:
runs-on: macos-14
strategy:
matrix:
arch: ["arm64-ios", "arm64-ios-simulator", "x64-ios-simulator"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-ios-build-${{ matrix.arch }}
cancel-in-progress: true

steps:
- name: Checkout Valhalla
Expand Down Expand Up @@ -52,7 +47,7 @@ jobs:
build/apple/${{ matrix.arch }}/install
create-xcframework-release:
needs: build
needs: build-ios
runs-on: macos-14
steps:
- name: Checkout Valhalla
Expand Down Expand Up @@ -92,6 +87,79 @@ jobs:
path: |
valhalla-wrapper.xcframework.zip
build-android:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
strategy:
matrix:
arch: ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]

steps:
- name: Checkout Valhalla
uses: actions/checkout@v4
with:
submodules: "recursive"

- name: Setup VCPKG
run: |
git clone https://github.com/microsoft/vcpkg && git -C vcpkg checkout 2024.09.23
./vcpkg/bootstrap-vcpkg.sh
export VCPKG_ROOT=`pwd`/vcpkg
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: android

- name: Build with Gradle
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew buildValhallaFor-${{ matrix.arch }}
working-directory: android

- name: Upload JNI Lib
uses: actions/upload-artifact@v4
with:
name: libvalhalla-${{ matrix.arch }}
path: android/valhalla/src/main/jniLibs/${{ matrix.arch }}/libvalhalla-wrapper.so
retention-days: 1

combine-android:
needs: build-android
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: jniLibs

- name: Organize and zip artifacts
run: |
mkdir -p android/valhalla/src/main/jniLibs
for arch in arm64-v8a armeabi-v7a x86 x86_64; do
mkdir -p android/valhalla/src/main/jniLibs/$arch
if [ -f jniLibs/libvalhalla-$arch/libvalhalla-wrapper.so ]; then
cp jniLibs/libvalhalla-$arch/libvalhalla-wrapper.so android/valhalla/src/main/jniLibs/$arch/
fi
done
zip -r valhalla-jniLibs.zip android
- name: Upload zipped JNI Libs
uses: actions/upload-artifact@v4
with:
name: valhalla-jniLibs
path: valhalla-jniLibs.zip
retention-days: 1

draft-release:
runs-on: macos-14
needs: create-xcframework-release
Expand Down Expand Up @@ -135,7 +203,6 @@ jobs:
files: "valhalla-wrapper.xcframework.zip"

- name: Write the xcframework to Package.swift
# run: ./scripts/write_xcframework_spm.sh ${{ fromJSON(steps.release.outputs.assets)[0].browser_download_url }}
run: ./scripts/write_xcframework_spm.sh ${{ steps.version.outputs.version }}

# https://github.com/marketplace/actions/git-auto-commit#push-to-protected-branches
Expand All @@ -159,3 +226,40 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.draft-release.outputs.release_id }}

publish-android:
needs: [combine-android, publish-release]
runs-on: ubuntu-latest
permissions:
contents: read
packages: read

steps:
- uses: actions/checkout@v4

- name: Download JNI Libs
uses: actions/download-artifact@v4
with:
name: valhalla-jniLibs
path: .

- name: Unzip JNI Libs
run: unzip valhalla-jniLibs.zip

- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: android

- name: Unit test
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publishToMavenCentral
working-directory: android
16 changes: 15 additions & 1 deletion android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import java.util.regex.Pattern

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
}

fun getSharedVersion(): String {
val text = file("../version.txt").readText().trim()
val semVerPattern = Pattern.compile("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$")

if (!semVerPattern.matcher(text).matches()) {
throw IllegalArgumentException("The version string '$text' is not a valid semantic version.")
}

print("Shared project version: $text")
return text
}

allprojects {
version = "0.1.0"
version = getSharedVersion()
}
4 changes: 4 additions & 0 deletions android/valhalla/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()

if (project.version.toString() === "unspecified") {
throw IllegalArgumentException("Version must be specified")
}

coordinates("io.github.rallista", "valhalla-mobile", project.version.toString())

configure(AndroidSingleVariantLibrary(sourcesJar = true, publishJavadocJar = true))
Expand Down
Loading

0 comments on commit 338bd50

Please sign in to comment.