From 4fa17cdbd494d45bc2c2b0e726f1edbf1ac8d3bc Mon Sep 17 00:00:00 2001 From: Morgan Koh Date: Tue, 19 Nov 2024 19:37:57 +0100 Subject: [PATCH] Add GitHub Actions --- .github/workflows/release.yml | 76 +++++++++++++++++++++++++++++++++++ composeApp/build.gradle.kts | 10 +++++ 2 files changed, 86 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ddca9db --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,76 @@ +name: Release + +on: + push: + tags: + - '[0-9]+.[0-9]+' + +jobs: + release: + name: Publish on Google Play + runs-on: [ self-hosted, macOS ] + timeout-minutes: 45 + env: + BUILD_NUMBER: ${{ github.run_number }} + + steps: + # Checkout - https://github.com/actions/checkout + - name: Checkout + uses: actions/checkout@v4.1.7 + + # Setup Java - https://github.com/actions/setup-java + - name: Set up JDK 21 + uses: actions/setup-java@v4.3.0 + with: + distribution: 'temurin' + java-version: '21' + - name: Check JDK version + run: java -version + + # Setup Android - https://github.com/android-actions/setup-android + - name: Setup Android SDK + uses: android-actions/setup-android@v3.2.1 + + # Decode Keystore + - name: Decode Keystore + env: + RELEASE_KEYSTORE_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }} + + run: | + echo "$RELEASE_KEYSTORE_BASE64" | base64 --decode > release.jks + + + # Build and deploy - https://github.com/gradle/gradle-build-action +# - name: Build and Publish App on Google Play +# uses: gradle/actions/setup-gradle@v3.5.0 +# env: +# RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }} +# RELEASE_KEY_PASS: ${{ secrets.RELEASE_KEY_PASS }} +# with: +# gradle-version: wrapper +# arguments: publishReleaseBundle --stacktrace + + # Run Gradlew + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: build prod + run: ./gradlew app:bundleRelease + env: + RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }} + RELEASE_KEY_PASS: ${{ secrets.RELEASE_KEY_PASS }} + + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: Build Artifacts + path: app/build/outputs/ + + # Create GitHub release - https://github.com/softprops/action-gh-release + - name: GitHub Release + uses: softprops/action-gh-release@v2.1.0 + with: + name: Twilight ${{ env.GITHUB_REF_NAME }} + + # Set VERSION_INFORMATION + - run: echo "VERSION_INFORMATION=$(${{github.workspace}}/gradlew -q printVersionInformation)" >> $GITHUB_ENV + continue-on-error: true \ No newline at end of file diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 790b6cd..1b48b28 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -93,6 +93,15 @@ android { sourceSets["main"].res.srcDirs("src/androidMain/res") sourceSets["main"].resources.srcDirs("src/commonMain/resources") + signingConfigs { + create("release") { + storeFile = file("secrets/release.jks") + storePassword = System.getenv("RELEASE_KEY_PASS") + keyAlias = System.getenv("RELEASE_KEY_ALIAS") + keyPassword = System.getenv("RELEASE_KEY_PASS") + } + } + defaultConfig { applicationId = "com.delacrixmorgan.twilight.android" minSdk = libs.versions.android.minSdk.get().toInt() @@ -120,6 +129,7 @@ android { buildFeatures { buildConfig = true } + dependencies { debugImplementation(libs.compose.ui.tooling) }