initial commit #7
Workflow file for this run
This file contains hidden or 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 AAR | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: 'Tag to release (e.g. v0.3.1)' | |
| required: false | |
| prerelease: | |
| description: 'Mark release as pre-release' | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: 1 | |
| ANDROID_NDK_VERSION: 26.3.11579264 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Set up Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| - name: Install protoc + toolchain deps | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler build-essential clang | |
| echo "PROTOC=/usr/bin/protoc" >> $GITHUB_ENV | |
| - name: Install just | |
| uses: extractions/setup-just@v1 | |
| - name: Install Android NDK ${{ env.ANDROID_NDK_VERSION }} | |
| run: | | |
| if [ ! -d "$ANDROID_SDK_ROOT/ndk/${ANDROID_NDK_VERSION}" ]; then | |
| yes | sdkmanager "ndk;${ANDROID_NDK_VERSION}" | |
| fi | |
| echo "ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/${ANDROID_NDK_VERSION}" >> $GITHUB_ENV | |
| echo "ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/${ANDROID_NDK_VERSION}" >> $GITHUB_ENV | |
| echo "ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/${ANDROID_NDK_VERSION}" >> $GITHUB_ENV | |
| - name: Cache Cargo registry/git (not target) | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock', 'rust/Cargo.toml') }} | |
| restore-keys: ${{ runner.os }}-cargo- | |
| - name: Cache Gradle | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: ${{ runner.os }}-gradle- | |
| - name: Setup Rust Android targets | |
| run: just setup-targets | |
| # The next two steps are some hacks needed to get the aws-lc-sys crate to cross compile | |
| # Maybe there is a more elegant way? | |
| # Keep tools/tests off so aws-lc-sys doesn't try to add_subdirectory(tool*). | |
| - name: Configure aws-lc-sys for Android | |
| run: | | |
| echo 'AWS_LC_SYS_CMAKE_ARGS=-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake;-DANDROID_PLATFORM=21;-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY;-DBUILD_TESTING=OFF;-DBUILD_TOOL=OFF;-DBUILD_LIBSSL=OFF;-DDISABLE_GO=ON;-DDISABLE_PERL=ON;-DCMAKE_DISABLE_FIND_PACKAGE_Go=ON;-DCMAKE_DISABLE_FIND_PACKAGE_Perl=ON;-DGO_EXECUTABLE=GO-NOTFOUND;-DPERL_EXECUTABLE=PERL-NOTFOUND' >> $GITHUB_ENV | |
| # Purge stale CMake caches from aws-lc-sys that may have a different generator recorded. | |
| - name: Clean stale aws-lc-sys CMake cache | |
| run: | | |
| set -euxo pipefail | |
| find rust/target -type f -name CMakeCache.txt -path '*aws-lc-sys*' -print -delete || true | |
| find rust/target -type d -name CMakeFiles -path '*aws-lc-sys*' -print -exec rm -rf {} + || true | |
| - name: Build release AAR | |
| env: | |
| CARGO_NET_GIT_FETCH_WITH_CLI: true | |
| run: | | |
| ./gradlew clean cargoBuildArm64 :assembleRelease --no-daemon --parallel | |
| - name: Locate AAR | |
| id: aar | |
| run: | | |
| set -euo pipefail | |
| AAR_PATH=$(ls -1 build/outputs/aar/*release*.aar 2>/dev/null | head -n1 || true) | |
| if [ -z "${AAR_PATH}" ]; then | |
| AAR_PATH=$(ls -1 */build/outputs/aar/*release*.aar 2>/dev/null | head -n1 || true) | |
| fi | |
| if [ -z "${AAR_PATH}" ]; then | |
| echo "No release AAR found under build/outputs/aar/**." | |
| exit 1 | |
| fi | |
| echo "aar_path=${AAR_PATH}" >> "$GITHUB_OUTPUT" | |
| echo "Found AAR: ${AAR_PATH}" | |
| - name: Prepare asset | |
| id: prep | |
| run: | | |
| set -euo pipefail | |
| VERSION="${GITHUB_REF_NAME:-}" | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -z "${VERSION}" ]; then | |
| VERSION="${{ inputs.tag_name || '' }}" | |
| fi | |
| if [ -z "${VERSION}" ]; then | |
| echo "No tag detected and no tag_name provided." | |
| exit 1 | |
| fi | |
| VERSION="${VERSION#v}" | |
| BASENAME="$(basename "${{ steps.aar.outputs.aar_path }}")" | |
| NAME_WITH_VER="${BASENAME%.aar}-${VERSION}.aar" | |
| mkdir -p dist | |
| cp "${{ steps.aar.outputs.aar_path }}" "dist/${NAME_WITH_VER}" | |
| echo "asset=dist/${NAME_WITH_VER}" >> "$GITHUB_OUTPUT" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Publish GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_type == 'tag' && github.ref_name || inputs.tag_name }} | |
| files: ${{ steps.prep.outputs.asset }} | |
| generate_release_notes: true | |
| prerelease: ${{ inputs.prerelease }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |