Skip to content

Commit

Permalink
Modified release feature workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Surzhykov <yuriisurzhykov@gmail.com>
  • Loading branch information
yuriisurzhykov committed May 29, 2024
1 parent a7e673a commit e7e8bb2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 86 deletions.
128 changes: 53 additions & 75 deletions .github/workflows/release_feature_github.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
name: Release Build

on:
push:
tags:
- 'v*'
branches: [ "main" ]
tags: [ "v*" ]

pull_request:
branches: [ "main" ]

jobs:
Build:
name: Build/Sign APK
release_build:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')

steps:
- uses: actions/checkout@v3
- name: Set up JDK 19
Expand All @@ -16,82 +22,54 @@ jobs:
distribution: 'corretto'
cache: gradle

- name: Get Tag
id: var
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Configure Keystore
run: |
echo "$ANDROID_KEYSTORE_FILE" > keystore.jks.b64
base64 -d -i keystore.jks.b64 > app/keystore.jks
echo "keystoreFile=keystore.jks" >> signing.properties
echo "keyAlias=$KEYSTORE_KEY_ALIAS" >> signing.properties
echo "keystorePassword=$KEYSTORE_STORE_PASSWORD" >> signing.properties
echo "::debug::storePassword=$KEYSTORE_STORE_PASSWORD"
echo "keyPassword=$KEYSTORE_KEY_PASSWORD" >> signing.properties
env:
ANDROID_KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}

- name: Build APK
id: build
run: bash ./gradlew assembleRelease
env:
VERSION_CODE: ${{ env.GITHUB_RUN_NUMBER }}
VERSION_NAME: ${{ github.event.inputs.versionName }}

- name: Sign APK
id: sign_apk
uses: r0adkll/sign-android-release@v1
- name: Cache Gradle and wrapper
uses: actions/cache@v4
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.KEYSTORE_FILE }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}

- name: Make artifact
uses: actions/upload-artifact@v2
with:
name: app-release-signed
path: ${{steps.sign_apk.outputs.signedReleaseFile}}
#1
- name: Decode Keystore
env:
ENCODED_STRING: ${{ secrets.SIGNING_KEY_STORE_BASE64 }}
SIGNING_KEY_STORE_PATH: ${{ secrets.SIGNING_KEY_STORE_PATH }}

- name: Build Changelog
id: changelog
uses: ardalanamini/auto-changelog@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
commit-types: |
feat: New Features
fix: Bug Fixes
build: Build System & Dependencies
perf: Performance Improvements
docs: Documentation
test: Tests
refactor: Refactors
chore: Chores
ci: CI
style: Code Style
revert: Reverts
run: |
echo $ENCODED_STRING > keystore-b64.txt
base64 -d keystore-b64.txt > $SIGNING_KEY_STORE_PATH
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ steps.changelog.outputs.changelog }} ;
#2
- name: Build Release apk
env:
GITHUB_TOKEN: ${{ github.token }}
SIGNING_KEY_STORE_PATH: ${{ secrets.SIGNING_KEY_STORE_PATH }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
run: ./gradlew assembleRelease

- name: Upload APK
uses: actions/upload-release-asset@v1
- name: Build Release bundle
env:
GITHUB_TOKEN: ${{ github.token }}
SIGNING_KEY_STORE_PATH: ${{ secrets.SIGNING_KEY_STORE_PATH }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
run: ./gradlew bundleRelease
#3
- name: Upload Release Build to Artifacts
uses: actions/upload-artifact@v3
with:
name: release-artifacts
paths: |
app/build/outputs/apk/release/
app/build/outputs/bundle/release/
#4
- name: Create Github Release
uses: softprops/action-gh-release@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{steps.sign_apk.outputs.signedReleaseFile}}
asset_name: app-release-signed-${{ steps.var.outputs.tag }}.apk
asset_content_type: application/zip
generate_release_notes: true
prerelease: true
files: |
app/build/outputs/apk/release/app-release.apk
app/build/outputs/bundle/release/app-release.aab
15 changes: 4 additions & 11 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import java.io.FileInputStream
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
Expand Down Expand Up @@ -35,14 +32,10 @@ android {

signingConfigs {
create("release") {
val properties = Properties()
FileInputStream(file("../signing.properties")).use { stream ->
properties.load(stream)
}
storeFile = file(properties.getProperty("keystoreFile"))
storePassword = properties.getProperty("keystorePassword").toString()
keyAlias = properties.getProperty("keyAlias").toString()
keyPassword = properties.getProperty("keyPassword").toString()
storeFile = file("keystore.jks")
storePassword = System.getenv("SIGNING_STORE_PASSWORD")
keyAlias = System.getenv("SIGNING_KEY_ALIAS")
keyPassword = System.getenv("SIGNING_KEY_PASSWORD")
}
}

Expand Down

0 comments on commit e7e8bb2

Please sign in to comment.