Skip to content

Merge pull request #2 from mami-server-2/main #6

Merge pull request #2 from mami-server-2/main

Merge pull request #2 from mami-server-2/main #6

Workflow file for this run

name: Build & Release Updater
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Setup Android SDK
uses: android-actions/[email protected]
- name: Decode Keystore
env:
ENCODED_STRING: ${{ secrets.KEYSTORE_BASE_64 }}
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
RELEASE_KEYSTORE_ALIAS: ${{ secrets.RELEASE_KEYSTORE_ALIAS }}
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
run: |
echo $ENCODED_STRING > keystore-b64.txt
base64 -d keystore-b64.txt > keystore.jks
- name: Read version from build_req.json
id: version
run: |
version=$(jq -r .version ./build_req.json)
commit_id=$(git rev-parse --short HEAD)
new_version="${version}-${commit_id}"
current_version_code=$(grep versionCode ./app/build.gradle.kts | awk '{print $2}')
new_version_code=$((current_version_code + 1))
echo "NEW_VERSION=${new_version}" >> $GITHUB_ENV
echo "NEW_VERSION_CODE=${new_version_code}" >> $GITHUB_ENV
- name: Update versionName in build.gradle.kts
run: |
sed -i "s/versionName = \".*\"/versionName = \"${{ env.NEW_VERSION }}\"/" app/build.gradle.kts
sed -i "s/versionCode = .*/versionCode = ${NEW_VERSION_CODE}/" app/build.gradle.kts
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build APK
env:
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
RELEASE_KEYSTORE_ALIAS: ${{ secrets.RELEASE_KEYSTORE_ALIAS }}
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
run: ./gradlew assembleRelease --stacktrace
- name: Upload APK to GitHub Releases
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.NEW_VERSION }}
files: ./app/build/outputs/apk/release/app-release.apk
release_name: ${{ steps.version.outputs.version }}
body: '${{ steps.version.outputs.version }}'
token: ${{ secrets.GITHUB_TOKEN }}