update-build #66
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: Update Library | |
| on: | |
| repository_dispatch: | |
| types: [update-build] | |
| workflow_dispatch: | |
| jobs: | |
| update_framework: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout CEL Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| path: android | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| working-directory: android | |
| - name: Checkout CEL Rust Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: superwall/superscript | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| path: rust | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v2 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| - name: Extract Version Number from Cargo.toml | |
| id: extract_version | |
| run: | | |
| version=$(grep '^version =' rust/Cargo.toml | sed -E 's/version = "(.*)"/\1/') | |
| echo "VERSION_NUMBER=$version" >> $GITHUB_ENV | |
| - name: Check if Version Has Changed | |
| id: version_check | |
| run: | | |
| current_version=$(git tag --sort=-v:refname | grep '^v' | head -n 1 | sed 's/^v//') | |
| echo "Current version: $current_version" | |
| echo "New version: ${{ env.VERSION_NUMBER }}" | |
| if [ "$current_version" = "${{ env.VERSION_NUMBER }}" ]; then | |
| echo "Version has not changed, exiting." | |
| exit 0 | |
| fi | |
| - name: Cache Rust toolchain | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo | |
| ~/.rustup | |
| key: ${{ runner.os }}-rust-toolchain-${{ hashFiles('**/rust-toolchain') }} | |
| - name: Cache Cargo registry | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache Cargo build | |
| uses: actions/cache@v3 | |
| with: | |
| path: rust/target | |
| key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-build- | |
| - name: Install Rust (if not cached) | |
| run: | | |
| if [ ! -x "$(command -v rustup)" ]; then | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
| fi | |
| source $HOME/.cargo/env | |
| shell: bash | |
| - name: Install cross | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Free Disk Space for Docker | |
| uses: endersonmenezes/free-disk-space@v3 | |
| with: | |
| remove_android: false | |
| remove_dotnet: true | |
| remove_haskell: true | |
| rm_cmd: "rmz" # Faster cleanup | |
| - name: Build Android Framework | |
| run: | | |
| chmod +x ./build_android.sh | |
| ./build_android.sh | |
| working-directory: rust | |
| - name: Verify 16KB Page Alignment | |
| run: | | |
| chmod +x ./check_elf_alignment.sh | |
| ./check_elf_alignment.sh target/android/jniLibs/ | |
| working-directory: rust | |
| - name: Replace binaries | |
| run: | | |
| rm -rf android/supercel/src/main/jniLibs/ | |
| mv rust/target/android/jniLibs android/supercel/src/main/jniLibs/ | |
| - name: Replace Kotlin File | |
| run: | | |
| rm -rf android/supercel/src/main/java/com/superwall/supercel/Cel.kt | |
| mv rust/target/android/java/uniffi/cel/com/superwall/supercel/cel.kt android/supercel/src/main/java/com/superwall/supercel/CEL.kt | |
| - name: Remove lines containing RequiresApi | |
| run: | | |
| sed -i '/RequiresApi/d' ./android/supercel/src/main/java/com/superwall/supercel/CEL.kt | |
| - name: Update Version | |
| run: sed -i 's/version = "[0-9.]*"/version = "${{ env.VERSION_NUMBER }}"/' android/supercel/build.gradle.kts | |
| - name: Commit and Push Changes | |
| run: | | |
| cd android | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| git add . | |
| git commit -m "Update library" | |
| git push origin main | |
| - name: Build and publish | |
| env: | |
| ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PW}} | |
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SECRING }} | |
| ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }} | |
| ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PW }} | |
| run: ./gradlew publish | |
| working-directory: android | |
| - name: Tag the New Version | |
| run: | | |
| git tag -a "${{ env.VERSION_NUMBER }}" -m "Release version ${{ env.VERSION_NUMBER }}" | |
| git push origin "${{ env.VERSION_NUMBER }}" | |
| working-directory: android | |
| - name: Create GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ env.VERSION_NUMBER }} | |
| release_name: ${{ env.VERSION_NUMBER }} | |
| body: "This is an automatically generated release. Please see the [original Rust release](https://github.com/superwall/superscript/releases/tag/${{ env.VERSION_NUMBER }}) for any version changes." | |
| draft: false | |
| prerelease: false |