Release Build #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# author: github.com/hmasum52 | |
name: Release Build | |
on: | |
workflow_dispatch: # Manually trigger the workflow | |
permissions: | |
contents: write | |
jobs: | |
release_build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup JAVA 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: 17 | |
- name: grant permission | |
run: chmod +x gradlew | |
- name: Cache Gradle and wrapper | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
- name: Decode Keystore | |
run: | | |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > composeApp/keystore.jks | |
- name: Build Release apk | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
run: ./gradlew assembleRelease | |
- name: Build Release bundle | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
run: ./gradlew bundleRelease | |
- name: Upload Release Build to Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-artifacts | |
path: | | |
composeApp/build/outputs/apk/release/ | |
composeApp/build/outputs/bundle/release/ | |
- name: Extract version from composeApp/build.gradle.kts | |
id: extract_version | |
run: | | |
version=$(grep 'versionName' composeApp/build.gradle.kts | cut -d '"' -f 2) | |
echo "VERSION=v$version" >> $GITHUB_ENV | |
- name: Check if Tag Exists | |
id: check_tag | |
run: | | |
if git show-ref --tags | grep -q "${{ env.VERSION }}"; then | |
echo "TAG_EXISTS=true" >> $GITHUB_ENV | |
else | |
echo "TAG_EXISTS=false" >> $GITHUB_ENV | |
fi | |
- name: Modify Tag if Exists | |
if: env.TAG_EXISTS == 'true' | |
id: modify_tag | |
run: | | |
new_version="${{ env.VERSION }}-build-${{ github.run_number }}" | |
echo "VERSION=$new_version" >> $GITHUB_ENV | |
- name: Create a release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.VERSION }} | |
release_name: ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Upload APK | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: composeApp/build/outputs/apk/release/composeApp-release.apk | |
asset_name: app-release.apk | |
asset_content_type: application/vnd.android.package-archive | |
- name: Upload Bundle | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: composeApp/build/outputs/bundle/release/composeApp-release.aab | |
asset_name: app-release.aab | |
asset_content_type: application/octet-stream |