Skip to content

Commit

Permalink
fix android pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneschepke committed Jun 13, 2024
1 parent dedc06f commit fe82551
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 25 deletions.
33 changes: 22 additions & 11 deletions .github/workflows/build-nym-vpn-android.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
name: build-nym-vpn-android
on:
workflow_dispatch:
secrets:
ANDROID_SIGNING_KEY_ALIAS:
required: true
ANDROID_SIGNING_KEY_PASSWORD:
required: true
ANDROID_SIGNING_STORE_PASSWORD:
required: true
ANDROID_SENTRY_DSN:
required: true
ANDROID_SERVICE_ACCOUNT_JSON:
required: true
ANDROID_KEYSTORE:
required: true
workflow_call:
secrets:
ANDROID_SIGNING_KEY_ALIAS:
Expand All @@ -15,6 +28,8 @@ on:
required: true
ANDROID_KEYSTORE:
required: true
env:
UPLOAD_DIR_ANDROID: android_artifacts

jobs:
build:
Expand All @@ -26,10 +41,11 @@ jobs:
SENTRY_DSN: ${{ secrets.ANDROID_SENTRY_DSN }}
KEY_STORE_FILE: 'android_keystore.jks'
KEY_STORE_LOCATION: ${{ github.workspace }}/nym-vpn-android/app/keystore/
UPLOAD_DIR_ANDROID_APK: android_apk
defaults:
run:
working-directory: nym-vpn-android
outputs:
UPLOAD_DIR_ANDROID: ${{ env.UPLOAD_DIR_ANDROID }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -49,6 +65,7 @@ jobs:

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

Expand All @@ -73,8 +90,6 @@ jobs:
- name: Add cargo-ndk
run: |
cargo install cargo-ndk
- name: Install Protoc
uses: arduino/setup-protoc@v3
- name: Install deps
run: |
Expand Down Expand Up @@ -104,18 +119,14 @@ jobs:
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 }}
run: echo "path=$(find . -regex '^.*/build/outputs/apk/fdroid/release/.*\.apk$' -type f | head -1 | tail -c+2)" >> $GITHUB_OUTPUT

- name: Upload apk
uses: actions/upload-artifact@v4
with:
name: ${{ env.UPLOAD_DIR_ANDROID_APK }}
path: ${{ env.UPLOAD_DIR_ANDROID_APK }}
name: ${{ env.UPLOAD_DIR_ANDROID }}
path: ${{github.workspace}}/nym-vpn-android${{ steps.apk-path.outputs.path }}
retention-days: 1
45 changes: 36 additions & 9 deletions .github/workflows/publish-nym-vpn-android.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: release-nym-vpn-android-play
name: publish-nym-vpn-android

on:
schedule:
Expand All @@ -19,7 +19,7 @@ on:
tag_name:
description: "Tag name for release"
required: false
default: nightly-vpn-android
default: nightly-android
release_type:
type: choice
description: "GitHub release type"
Expand All @@ -33,12 +33,14 @@ on:
push:
tags:
- 'nym-vpn-android-v*.*.*'
env:
UPLOAD_DIR_ANDROID: android_artifacts

jobs:

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

publish-github:
if: ${{ inputs.release_type != 'none' }}
Expand All @@ -48,32 +50,57 @@ jobs:
defaults:
run:
working-directory: nym-vpn-android
env:
# GH needed for gh cli
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
nym-vpn-android
- name: Install system dependencies
run: |
sudo apt update && sudo apt install -y gettext-base gh zip
- name: Get version code
run: |
version_code=$(grep "VERSION_CODE" buildSrc/src/main/kotlin/Constants.kt | awk '{print $5}' | tr -d '\n')
version_code=$(grep "VERSION_CODE" ${{ github.workspace }}/nym-vpn-android/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
RELEASE_NOTES="$(cat ${{ github.workspace }}/nym-vpn-android/fastlane/metadata/android/en-US/changelogs/${{ env.VERSION_CODE }}.txt)"
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "$RELEASE_NOTES" >> $GITHUB_ENV
echo "EOF" >> $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
- name: On nightly release
if: ${{ contains(env.TAG_NAME, 'nightly') }}
run: |
echo "RELEASE_NOTES=Nightly build of the latest development version of the android client." >> $GITHUB_ENV
gh release delete nightly-android --yes || true
- name: Make download dir
run: mkdir ${{ github.workspace }}/temp

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.UPLOAD_DIR_ANDROID }}
path: ${{ github.workspace }}/temp

- name: Create release with fastlane changelog notes
id: create_release
uses: softprops/action-gh-release@v2
Expand All @@ -87,7 +114,7 @@ jobs:
make_latest: ${{ inputs.release_type == 'release' }}
prerelease: ${{ inputs.release_type == 'prerelease' || inputs.release_type == '' }}
files: |
${{ github.workspace }}/${{ env.UPLOAD_DIR_ANDROID_APK }}
${{ github.workspace }}/temp/*
- name: Dispatch update for fdroid repo
if: inputs.release_type == 'release'
Expand Down
6 changes: 1 addition & 5 deletions nym-vpn-android/nym_vpn_client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ android {
buildFeatures {
buildConfig = true
}

ndkVersion = sdkDirectory.resolve("ndk").listFilesOrdered().last().name
}

dependencies {
Expand All @@ -87,9 +85,7 @@ dependencies {
}

tasks.register<Exec>(Constants.BUILD_LIB_TASK) {
val ndkPath =
android.sdkDirectory.resolve("ndk").listFilesOrdered().last().path
?: System.getenv("ANDROID_NDK_HOME")
val ndkPath = android.sdkDirectory.resolve("ndk").listFilesOrdered().lastOrNull()?.path ?: System.getenv("ANDROID_NDK_HOME")
commandLine("echo", "NDK HOME: $ndkPath")
val script = "${projectDir.path}/src/main/scripts/build-libs.sh"
// TODO find a better way to limit builds
Expand Down

0 comments on commit fe82551

Please sign in to comment.