Release #6
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: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
bump_version_scheme: | |
type: choice | |
description: "Release" | |
required: true | |
default: "patch" | |
options: | |
- "patch" | |
- "minor" | |
- "major" | |
jobs: | |
build-ios: | |
runs-on: macos-14 | |
strategy: | |
matrix: | |
arch: ["arm64-ios", "arm64-ios-simulator", "x64-ios-simulator"] | |
steps: | |
- name: Checkout Valhalla | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: "14.3.1" | |
- 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: Build for iOS & iOS Simulator | |
run: ./build.sh --ios ${{ matrix.arch }} | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.arch }} | |
path: | | |
build/apple/${{ matrix.arch }}/install | |
create-xcframework-release: | |
needs: build-ios | |
runs-on: macos-14 | |
steps: | |
- name: Checkout Valhalla | |
uses: actions/checkout@v4 | |
- uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: "14.3.1" | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: build/apple | |
- name: Move artifacts to correct locations | |
run: | | |
for arch in arm64-ios arm64-ios-simulator x64-ios-simulator; do | |
mkdir -p build/apple/$arch/install | |
mv build/apple/$arch/* build/apple/$arch/install/ || true | |
done | |
- name: Create XCFramework | |
run: | | |
./scripts/create_xcframework.sh | |
- name: Zip the xcframework | |
run: | | |
cd build/apple | |
zip -r valhalla-wrapper.xcframework.zip valhalla-wrapper.xcframework | |
mv valhalla-wrapper.xcframework.zip ../../ | |
cd ../../ | |
- name: Upload xcframework zip output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: valhalla-wrapper.xcframework.zip | |
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 | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
release_id: ${{ steps.release.outputs.id }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- name: Checkout Valhalla | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PAT }} | |
- name: Configure Git | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
- name: Download the xcframework artifact from the build-and-test | |
uses: actions/download-artifact@v4 | |
with: | |
name: valhalla-wrapper.xcframework.zip | |
- name: Get version tag | |
id: version | |
run: ./scripts/version_bump.sh ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'patch' || inputs.bump_version_scheme }} | |
- uses: softprops/action-gh-release@v1 | |
id: release | |
with: | |
draft: true | |
generate_release_notes: true | |
tag_name: ${{ steps.version.outputs.version }} | |
files: "valhalla-wrapper.xcframework.zip" | |
- name: Write the xcframework to Package.swift | |
run: ./scripts/write_xcframework_spm.sh ${{ steps.version.outputs.version }} | |
# https://github.com/marketplace/actions/git-auto-commit#push-to-protected-branches | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "Publish Package.swift and bump version to ${{ steps.version.outputs.version }} [skip ci]" | |
tagging_message: "${{ steps.version.outputs.version }}" | |
push_options: --force | |
- name: Output version | |
run: | | |
echo "version=${{ steps.version.outputs.version }}" >> "$GITHUB_OUTPUT" | |
echo "release_id=${{ steps.release.outputs.id }}" >> "$GITHUB_OUTPUT" | |
publish-release: | |
runs-on: ubuntu-latest | |
needs: draft-release | |
steps: | |
- uses: eregon/publish-release@v1 | |
env: | |
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 | |
with: | |
ref: main | |
fetch-depth: 0 | |
# TODO: Remove this once successful. | |
- name: Verify version | |
run: cat version.txt | |
- 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: Publish to Maven Central | |
env: | |
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | |
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache | |
working-directory: android |