Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/build_apk_job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ on:
required: false
type: string
default: ''
release_build:
description: 'Whether this is a release build'
required: false
type: boolean
default: false
git_sha:
description: 'Git short SHA for APK filename'
required: false
type: string
default: ''

env:
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
Expand Down Expand Up @@ -50,7 +60,7 @@ jobs:
path: app/keystore

- name: Build APK
run: bash ./gradlew :app:assembleRelease --stacktrace --no-daemon
run: bash ./gradlew :app:assembleRelease -PGIT_SHA=${{ inputs.git_sha }} -PRELEASE_BUILD=${{ inputs.release_build }} --stacktrace --no-daemon

- name: Upload APK
uses: actions/upload-artifact@v4
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
id: extract
run: |
TAG="${GITHUB_REF_NAME}"
# Tag format: v2.2.0-70
VERSION_NAME="${TAG%-*}"
VERSION_NAME="${TAG#v}"
VERSION_NAME="${VERSION_NAME%-*}"
VERSION_CODE="${TAG##*-}"
echo "version_name=$VERSION_NAME" >> $GITHUB_OUTPUT
echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT
Expand All @@ -34,6 +34,7 @@ jobs:
with:
version_name: ${{ needs.extract_version.outputs.version_name }}
version_code: ${{ needs.extract_version.outputs.version_code }}
release_build: true
secrets: inherit

release:
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/build_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,32 @@ jobs:
outputs:
version_name: ${{ steps.extract.outputs.version_name }}
version_code: ${{ steps.extract.outputs.version_code }}
short_commit: ${{ steps.extract.outputs.short_commit }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Extract version from latest tag
id: extract
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
VERSION_CODE="${LATEST_TAG##*-}"
VERSION_NAME="${GITHUB_SHA::7}"
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
SHORT_SHA="${GITHUB_SHA::7}"

if [ -z "$LATEST_TAG" ]; then
VERSION_NAME="0.0.0-${SHORT_SHA}"
VERSION_CODE="1"
else
BASE_VERSION="${LATEST_TAG#v}"
BASE_VERSION="${BASE_VERSION%-*}"
VERSION_NAME="${BASE_VERSION}-${SHORT_SHA}"
VERSION_CODE="${LATEST_TAG##*-}"
fi
echo "version_name=$VERSION_NAME" >> $GITHUB_OUTPUT
echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT
echo "short_commit=$SHORT_SHA" >> $GITHUB_OUTPUT

build:
needs: extract_version
Expand All @@ -39,6 +51,8 @@ jobs:
checkout_keystore: ${{ github.event.pull_request.user.login == github.repository_owner }}
version_name: ${{ needs.extract_version.outputs.version_name }}
version_code: ${{ needs.extract_version.outputs.version_code }}
release_build: false
git_sha: ${{ needs.extract_version.outputs.short_commit }}
secrets: inherit

send:
Expand Down
17 changes: 14 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ android {
versionCode = providers
.environmentVariable("VERSION_CODE")
.orNull
?.toIntOrNull()
?: Int.MAX_VALUE
?.toIntOrNull() ?: 1
versionName = providers
.environmentVariable("VERSION_NAME")
.getOrElse("unknown")
Expand All @@ -29,7 +28,19 @@ android {
applicationVariants.configureEach {
outputs.configureEach {
if (this is BaseVariantOutputImpl) {
outputFileName = "LogFox-${versionName}-${name}.apk"
val shortCommit = providers.gradleProperty("GIT_SHA")
.orElse(providers.environmentVariable("GIT_SHA"))
.orNull
?.take(7) ?: "local"

val releaseBuild = providers.gradleProperty("RELEASE_BUILD")
.orElse(providers.environmentVariable("RELEASE_BUILD"))
.orNull ?: "false"

outputFileName = if (releaseBuild == "true" || versionName.contains(shortCommit))
"LogFox-v${versionName}-release.apk"
else
"LogFox-v${versionName}-${shortCommit}-release.apk"
}
}
}
Expand Down