DNSNet Publish #110
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: DNSNet Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: 'Tag name to create for the release' | |
| required: true | |
| type: string | |
| version_code: | |
| description: 'Version code to set for the release' | |
| required: true | |
| type: number | |
| jobs: | |
| publish: | |
| if: ${{ github.repository == 't895/DNSNet' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| api-level: [ 35 ] | |
| arch: [ x86_64 ] | |
| target: [ google_apis ] | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Set up NDK | |
| uses: nttld/setup-ndk@v1 | |
| id: setup-ndk | |
| with: | |
| ndk-version: r29 | |
| link-to-sdk: true | |
| - name: Give execution permissions to the gradle wrapper | |
| run: chmod +x ./gradlew | |
| - name: Enable KVM group perms | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| ls /dev/kvm | |
| - name: AVD cache | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: avd-${{ matrix.api-level }} | |
| - name: create AVD and generate snapshot for caching | |
| if: steps.avd-cache.outputs.cache-hit != 'true' | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| arch: ${{ matrix.arch }} | |
| target: ${{ matrix.target }} | |
| force-avd-creation: false | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| disable-animations: false | |
| script: echo "Generated AVD snapshot for caching." | |
| - name: Generate baseline profile | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| env: | |
| ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| ANDROID_NDK_LATEST_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| target: ${{ matrix.target }} | |
| arch: ${{ matrix.arch }} | |
| profile: Nexus 6 | |
| script: | | |
| ./gradlew :app:generateBaselineProfile -Pandroid.testoptions.manageddevices.emulator.gpu=swiftshader_indirect --stacktrace && killall -INT crashpad_handler || true | |
| - name: Commit baseline profile update | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: Update baseline profile | |
| push_options: --force-with-lease | |
| file_pattern: '**/baseline-prof.txt **/startup-prof.txt' | |
| - name: Update version name and code | |
| run: | | |
| sed -i \ | |
| -e "s/\(val versionCode by extra { \)[0-9]\+\( }\)/\1${{inputs.version_code}}\2/" \ | |
| -e "s/\(val versionName by extra { \"\)[^\"]\+\(\"\s*}\)/\1${{inputs.tag_name}}\2/" \ | |
| build.gradle.kts | |
| - name: Commit version update | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: Bump version to ${{inputs.tag_name}} | |
| push_options: --force-with-lease | |
| file_pattern: 'build.gradle.kts' | |
| - name: Get latest commit sha | |
| id: sha | |
| run: echo "LATEST_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
| - name: Push new tag | |
| uses: rickstaa/action-create-tag@v1 | |
| id: "tag_create" | |
| with: | |
| tag: ${{ inputs.tag_name }} | |
| commit_sha: ${{ steps.sha.outputs.LATEST_SHA }} | |
| - name: Build | |
| env: | |
| KEY_ALIAS: ${{secrets.KEY_ALIAS}} | |
| KEY_PASSWORD: ${{secrets.KEY_PASSWORD}} | |
| STORE_PASSWORD: ${{secrets.KEY_PASSWORD}} | |
| ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| ANDROID_NDK_LATEST_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| run: | | |
| echo "${{secrets.STORE_FILE}}" | base64 --decode > ${HOME}/keyfile.jks | |
| export STORE_FILE_PATH=${HOME}/keyfile.jks | |
| echo "${{secrets.SERVICE_ACCOUNT_KEY_FILE}}" | base64 --decode > ${HOME}/servicekey.json | |
| export SERVICE_ACCOUNT_KEY_PATH=${HOME}/servicekey.json | |
| rustup target add x86_64-linux-android i686-linux-android aarch64-linux-android armv7-linux-androideabi | |
| export RUSTFLAGS=--remap-path-prefix=$HOME/.cargo=/rust/cargo | |
| export STORE_TRACK=production | |
| ./gradlew :app:assembleRelease --stacktrace | |
| ./gradlew :app:buildApksRelease --stacktrace | |
| ./gradlew :app:bundleRelease --stacktrace | |
| ./gradlew :app:publishReleaseBundle --stacktrace | |
| - name: Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{inputs.tag_name}} | |
| artifacts: "./**/app-release.apk,./**/app-release.apks,./**/app-release.aab" |