Skip to content

Commit

Permalink
ci: Push example App to CI channel
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Aug 28, 2024
1 parent c7e8779 commit 4c00307
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 8 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,41 @@ jobs:
with:
distribution: 'zulu'
java-version: '17'
- name: Build with Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build example app
run: ./gradlew :composeApp:assembleRelease
run: |
echo ${{ secrets.SIGNING_KEY }} | base64 -d > keystore.jks
./gradlew :composeApp:assemble
env:
KEYSTORE_PATH: "../keystore.jks"
KEYSTORE_PASS: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Upload android artifact
uses: actions/upload-artifact@v4
with:
name: AndroidExampleApp
path: composeApp/build/outputs/apk/release
path: composeApp/build/outputs/apk/release
- name: Find apk
run: |
echo "RELEASE=$(find 'composeApp/build/outputs/apk/release' -name '*.apk')" >> $GITHUB_ENV
echo "DEBUG=$(find 'composeApp/build/outputs/apk/debug' -name '*.apk')" >> $GITHUB_ENV
- name: Post to Telegram ci channel
if: ${{ success() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag' }}
env:
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
RELEASE: ${{ env.RELEASE }}
DEBUG: ${{ env.DEBUG }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
COMMIT_URL: ${{ github.event.head_commit.url }}
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
event_path=$GITHUB_EVENT_PATH
commit_count=$(jq -r '.commits | length' $event_path)
{ echo -e 'Github CI\n'; git log -$commit_count --pretty=format:"%h %s"; } > ${{ github.workspace }}/git_log
ESCAPED="$(cat ${{ github.workspace }}/git_log | gawk '{gsub(/[_*[\]()~`>#+=\|{}.!-]/,"\\\\\\\\&")}1' | sed -e 's|"|\\"|g' -e 's|^[0-9a-z]\+|__&__|' | hexdump -v -e '/1 "%02X"' | sed 's/\(..\)/%\1/g')"
cd ${{ github.workspace }}
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Frelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Fdebug%22%2C%22caption%22%3A%22${ESCAPED}%22%2C%22parse_mode%22%3A%22MarkdownV2%22%7D%5D" -F release="@$RELEASE" -F debug="@$DEBUG"
fi
37 changes: 32 additions & 5 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
Expand Down Expand Up @@ -88,6 +89,31 @@ android {
versionCode = 1
versionName = verName
}
val properties = Properties()
runCatching { properties.load(project.rootProject.file("local.properties").inputStream()) }
val keystorePath = properties.getProperty("KEYSTORE_PATH") ?: System.getenv("KEYSTORE_PATH")
val keystorePwd = properties.getProperty("KEYSTORE_PASS") ?: System.getenv("KEYSTORE_PASS")
val alias = properties.getProperty("KEY_ALIAS") ?: System.getenv("KEY_ALIAS")
val pwd = properties.getProperty("KEY_PASSWORD") ?: System.getenv("KEY_PASSWORD")
if (keystorePath != null) {
signingConfigs {
register("github") {
storeFile = file(keystorePath)
storePassword = keystorePwd
keyAlias = alias
keyPassword = pwd
enableV3Signing = true
enableV4Signing = true
}
}
} else {
signingConfigs {
register("release") {
enableV3Signing = true
enableV4Signing = true
}
}
}
dependenciesInfo.includeInApk = false
packaging {
applicationVariants.all {
Expand All @@ -98,14 +124,15 @@ android {
resources.excludes += "**"
}
buildTypes {
getByName("release") {
release {
isMinifyEnabled = true
isShrinkResources = true
vcsInfo.include = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
signingConfig = signingConfigs.getByName(if (keystorePath != null) "github" else "release")
}
debug {
if (keystorePath != null) signingConfig = signingConfigs.getByName("github")
}
}

Expand Down

0 comments on commit 4c00307

Please sign in to comment.