Skip to content

Commit

Permalink
add android build and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneschepke committed Jun 12, 2024
1 parent 3c19132 commit c1e221c
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 178 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/build-nym-vpn-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: build-nym-vpn-android
on: [workflow_dispatch, workflow_call]

env:
SIGNING_KEY_ALIAS: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }}
SENTRY_DSN: ${{ secrets.ANDROID_SENTRY_DSN }}
KEY_STORE_FILE: 'android_keystore.jks'
KEY_STORE_LOCATION: ${{ github.workspace }}/app/keystore/
UPLOAD_DIR_ANDROID_APK: android_apk

jobs:
build:
runs-on: ubuntu-22.04-arc
defaults:
run:
working-directory: nym-vpn-android
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: gradle

- name: Install unzip
run: sudo apt-get update && sudo apt-get install -y unzip

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Setup Android SDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r25c

- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Native build dependencies
- name: Setup Go
uses: actions/setup-go@v5

- name: Add rust stable toolchain
uses: dtolnay/rust-toolchain@stable

- name: Add all targets
run: |
rustup target add \
aarch64-linux-android \
x86_64-linux-android \
i686-linux-android
- name: Add cargo-ndk
run: |
cargo install cargo-ndk
- name: Install Protoc
uses: arduino/setup-protoc@v3

- name: Install deps
run: |
sudo apt-get update && sudo apt-get install -y libdbus-1-dev libmnl-dev libnftnl-dev protobuf-compiler git curl gcc g++ make unzip
# Here we need to decode keystore.jks from base64 string and place it
# in the folder specified in the release signing configuration
- name: Decode Keystore
id: decode_keystore
uses: timheuer/[email protected]
with:
fileName: ${{ env.KEY_STORE_FILE }}
fileDir: ${{ env.KEY_STORE_LOCATION }}
encodedString: ${{ secrets.ANDROID_KEYSTORE }}

# create keystore path for gradle to read
- name: Create keystore path env var
run: |
store_path=${{ env.KEY_STORE_LOCATION }}${{ env.KEY_STORE_FILE }}
echo "KEY_STORE_PATH=$store_path" >> $GITHUB_ENV
- name: Create service_account.json
id: createServiceAccount
run: echo '${{ secrets.ANDROID_SERVICE_ACCOUNT_JSON }}' > service_account.json

- name: Build Release APK
run: ./gradlew :app:assembleRelease --stacktrace
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Get apk path
id: apk-path
run: echo "path=$(find . -regex '^.*/build/outputs/apk/fdroid/release/.*\.apk$' -type f | head -1)" >> $GITHUB_OUTPUT

- name: Move things around to prepare for upload
run: |
mkdir ${{ env.UPLOAD_DIR_ANDROID_APK }}
cp -vpr ${{ steps.apk-path.outputs.path }} ${{ env.UPLOAD_DIR_ANDROID_APK }}
- name: Upload apk
uses: actions/upload-artifact@v4
with:
name: ${{ env.UPLOAD_DIR_ANDROID_APK }}
path: ${{ env.UPLOAD_DIR_ANDROID_APK }}
retention-days: 1
5 changes: 4 additions & 1 deletion .github/workflows/ci-nym-vpn-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ jobs:
run: ./gradlew ktlintCheck

- name: Run detekt
run: ./gradlew detekt --info
run: ./gradlew detekt --info

build-nym-vpn-android:
uses: ./.github/workflows/build-nym-vpn-android.yml
3 changes: 3 additions & 0 deletions .github/workflows/ci-nym-vpn-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,6 @@ jobs:
working-directory: nym-vpn-core
run: |
cargo clippy --target aarch64-apple-ios -p nym-vpn-lib -- -Dwarnings
build-nym-vpn-android:
uses: ./.github/workflows/build-nym-vpn-android.yml
125 changes: 125 additions & 0 deletions .github/workflows/publish-nym-vpn-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: release-nym-vpn-android-play

env:
SIGNING_KEY_ALIAS: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }}
SENTRY_DSN: ${{ secrets.ANDROID_SENTRY_DSN }}
KEY_STORE_FILE: 'android_keystore.jks'
KEY_STORE_LOCATION: ${{ github.workspace }}/app/keystore/
UPLOAD_DIR_ANDROID_APK: android_apk

on:
schedule:
- cron: "4 3 * * *"
workflow_dispatch:
inputs:
track:
type: choice
description: "Fastlane release track"
options:
- none
- internal
- alpha
- beta
- production
default: alpha
required: true
tag_name:
description: "Tag name for release"
required: false
default: nightly-vpn-android
release_type:
type: choice
description: "GitHub release type"
options:
- none
- prerelease
- release
default: release
required: true

push:
tags:
- 'nym-vpn-android-v*.*.*'

jobs:

build-nym-vpn-android:
if: ${{ inputs.release_type != 'none' }}
uses: ./.github/workflows/build-nym-vpn-android.yml

publish-github:
if: ${{ inputs.release_type != 'none' }}
needs:
- build-nym-vpn-android
runs-on: ubuntu-22.04-arc
defaults:
run:
working-directory: nym-vpn-android
steps:
- name: Get version code
run: |
version_code=$(grep "VERSION_CODE" buildSrc/src/main/kotlin/Constants.kt | awk '{print $5}' | tr -d '\n')
echo "VERSION_CODE=$version_code" >> $GITHUB_ENV
- name: Set version release notes
run: |
release_notes=$(cat ${{ github.workspace }}/fastlane/metadata/android/en-US/changelogs/${{ env.VERSION_CODE }}.txt)
echo "RELEASE_NOTES=$release_notes" >> $GITHUB_ENV
# Setup TAG_NAME, which is used as a general "name"
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: |
echo "TAG_NAME=nightly-android" >> $GITHUB_ENV
echo "RELEASE_NOTES=Nightly build of the latest development version of the android client." >> $GITHUB_ENV
- if: github.event_name == 'push'
run: echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV

- name: Delete old nightly
if: ${{ contains(env.TAG_NAME, 'nightly') }}
run: |
gh release delete nightly-android --yes || true
- name: Create release with fastlane changelog notes
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ env.RELEASE_NOTES }}
tag_name: ${{ env.TAG_NAME }}
name: ${{ github.TAG_NAME}}
draft: false
make_latest: ${{ inputs.release_type == 'release' }}
prerelease: ${{ inputs.release_type == 'prerelease' || inputs.release_type == '' }}
files: |
${{ github.workspace }}/${{ env.UPLOAD_DIR_ANDROID_APK }}
- name: Dispatch update for fdroid repo
if: inputs.release_type == 'release'
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT }}
repository: nymtech/fdroid
event-type: fdroid-update

publish-play:
if: ${{ inputs.track != 'none' && inputs.track != '' }}
runs-on: ubuntu-22.04-arc
defaults:
run:
working-directory: nym-vpn-android
steps:
- name: Deploy with fastlane
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2' # Not needed with a .ruby-version file
bundler-cache: true
- name: Distribute app to fastlane track 🚀
run: (cd ${{ github.workspace }} && bundle install && bundle exec fastlane ${{ inputs.track }})



Loading

0 comments on commit c1e221c

Please sign in to comment.