Show a build ref the app was built from in about section

This commit is contained in:
Artem Chepurnoy 2024-01-24 09:46:14 +02:00
parent 751c63489f
commit 04fff90d26
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
12 changed files with 127 additions and 0 deletions

View File

@ -23,6 +23,7 @@ jobs:
echo ${{ secrets.KEYSTORE_PROPS_B64 }} | base64 -d | zcat >> androidApp/keyguard-release.properties
echo ${{ secrets.GOOGLE_SERVICES }} | base64 -d | zcat >> androidApp/google-services.json
echo "" >> gradle.properties
echo "versionRef=$(git rev-parse --short HEAD)" >> gradle.properties
echo buildkonfig.flavor=release >> gradle.properties
- name: "Check and Build licenses"
uses: eskatos/gradle-command-action@v2

View File

@ -28,6 +28,7 @@ jobs:
echo ${{ secrets.SERVICE_ACCOUNT_B64 }} | base64 -d | zcat >> service-account-google.json
echo "" >> gradle.properties
echo versionDate=${{ steps.vars.outputs.tag }} >> gradle.properties
echo "versionRef=${{ env.GITHUB_REF_NAME }}" >> gradle.properties
echo buildkonfig.flavor=release >> gradle.properties
- name: "Check and Build licenses"
uses: eskatos/gradle-command-action@v2

View File

@ -34,6 +34,8 @@ jobs:
- name: "Setup build env"
run: |
echo "" >> gradle.properties
echo versionDate=${{ steps.vars.outputs.tag }} >> gradle.properties
echo "versionRef=${{ env.GITHUB_REF_NAME }}" >> gradle.properties
echo buildkonfig.flavor=release >> gradle.properties
- name: "Setup signing config"
run: |
@ -87,6 +89,8 @@ jobs:
- name: "Setup build env"
run: |
echo "" >> gradle.properties
echo versionDate=${{ steps.vars.outputs.tag }} >> gradle.properties
echo "versionRef=${{ env.GITHUB_REF_NAME }}" >> gradle.properties
echo buildkonfig.flavor=release >> gradle.properties
- name: "./gradlew :desktopApp:bundleFlatpak"
uses: eskatos/gradle-command-action@v2
@ -122,6 +126,8 @@ jobs:
- name: "Setup build env"
run: |
echo "" >> gradle.properties
echo versionDate=${{ steps.vars.outputs.tag }} >> gradle.properties
echo "versionRef=${{ env.GITHUB_REF_NAME }}" >> gradle.properties
echo buildkonfig.flavor=release >> gradle.properties
- name: "./gradlew :desktopApp:packageMsi"
uses: eskatos/gradle-command-action@v2
@ -158,6 +164,7 @@ jobs:
echo ${{ secrets.GOOGLE_SERVICES }} | base64 -d | zcat >> androidApp/google-services.json
echo "" >> gradle.properties
echo versionDate=${{ steps.vars.outputs.tag }} >> gradle.properties
echo "versionRef=${{ env.GITHUB_REF_NAME }}" >> gradle.properties
echo buildkonfig.flavor=release >> gradle.properties
- name: "Check and Build licenses"
uses: eskatos/gradle-command-action@v2

View File

@ -8,12 +8,16 @@ data class VersionInfo(
val marketingVersion: String,
val logicalVersion: Int,
val buildDate: String,
val buildRef: String,
)
fun Project.createVersionInfo(
marketingVersion: String,
logicalVersion: Int, // max 9999
): VersionInfo {
val buildRef = project.properties["versionRef"]
?.let { it as? String }
.orEmpty()
val dateFormat = SimpleDateFormat("yyyyMMdd")
val calendar = Calendar.getInstance().apply {
timeZone = TimeZone.getTimeZone("UTC")
@ -34,5 +38,6 @@ fun Project.createVersionInfo(
marketingVersion = marketingVersion,
logicalVersion = codeVersion,
buildDate = buildDate,
buildRef = buildRef,
)
}

View File

@ -260,6 +260,7 @@ buildkonfig {
defaultConfigs {
buildConfigField(STRING, "buildType", BuildType.DEV.name)
buildConfigField(STRING, "buildDate", versionInfo.buildDate)
buildConfigField(STRING, "buildRef", versionInfo.buildRef)
buildConfigField(STRING, "versionName", versionInfo.marketingVersion.toString())
buildConfigField(INT, "versionCode", versionInfo.logicalVersion.toString())
}

View File

@ -0,0 +1,5 @@
package com.artemchep.keyguard.common.usecase
import kotlinx.coroutines.flow.Flow
interface GetAppBuildRef : () -> Flow<String>

View File

@ -19,6 +19,7 @@ import com.artemchep.keyguard.common.util.flow.foldAsList
import com.artemchep.keyguard.feature.EmptyView
import com.artemchep.keyguard.feature.home.settings.component.SettingComponent
import com.artemchep.keyguard.feature.home.settings.component.settingAboutAppBuildDateProvider
import com.artemchep.keyguard.feature.home.settings.component.settingAboutAppBuildRefProvider
import com.artemchep.keyguard.feature.home.settings.component.settingAboutAppProvider
import com.artemchep.keyguard.feature.home.settings.component.settingAboutTeamProvider
import com.artemchep.keyguard.feature.home.settings.component.settingAboutTelegramProvider
@ -142,6 +143,7 @@ object Setting {
const val OPEN_SOURCE_LICENSES = "open_source_licenses"
const val ABOUT_APP = "about_app"
const val ABOUT_APP_BUILD_DATE = "about_app_build_date"
const val ABOUT_APP_BUILD_REF = "about_app_build_ref"
const val ABOUT_TEAM = "about_team"
const val EXPERIMENTAL = "experimental"
const val LAUNCH_APP_PICKER = "launch_app_picker"
@ -212,6 +214,7 @@ val hub = mapOf<String, (DirectDI) -> SettingComponent>(
Setting.FEEDBACK_APP to ::settingFeedbackAppProvider,
Setting.ABOUT_APP to ::settingAboutAppProvider,
Setting.ABOUT_APP_BUILD_DATE to ::settingAboutAppBuildDateProvider,
Setting.ABOUT_APP_BUILD_REF to ::settingAboutAppBuildRefProvider,
Setting.ABOUT_TEAM to ::settingAboutTeamProvider,
Setting.REDDIT to ::settingAboutTelegramProvider,
Setting.CROWDIN to ::settingLocalizationProvider,

View File

@ -0,0 +1,76 @@
package com.artemchep.keyguard.feature.home.settings.component
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import com.artemchep.keyguard.common.usecase.GetAppBuildRef
import com.artemchep.keyguard.feature.navigation.LocalNavigationController
import com.artemchep.keyguard.feature.navigation.NavigationIntent
import com.artemchep.keyguard.res.Res
import com.artemchep.keyguard.ui.FlatItem
import com.artemchep.keyguard.ui.icons.ChevronIcon
import dev.icerock.moko.resources.compose.stringResource
import kotlinx.coroutines.flow.map
import org.kodein.di.DirectDI
import org.kodein.di.instance
fun settingAboutAppBuildRefProvider(
directDI: DirectDI,
) = settingAboutAppBuildRefProvider(
getAppBuildRef = directDI.instance(),
)
fun settingAboutAppBuildRefProvider(
getAppBuildRef: GetAppBuildRef,
): SettingComponent = getAppBuildRef()
.map { buildRef ->
if (buildRef.isNullOrBlank()) {
return@map null
}
// composable
SettingIi(
search = SettingIi.Search(
group = "about",
tokens = listOf(
"about",
"app",
"build",
"ref",
),
),
) {
SettingAboutAppBuildRef(
buildRef = buildRef,
)
}
}
@Composable
private fun SettingAboutAppBuildRef(
buildRef: String,
) {
val controller by rememberUpdatedState(LocalNavigationController.current)
FlatItem(
title = {
Text(
text = stringResource(Res.strings.pref_item_app_build_ref_title),
)
},
text = {
Text(buildRef)
},
trailing = {
ChevronIcon()
},
onClick = {
val intent = run {
val url =
"https://github.com/AChep/keyguard-app/tree/$buildRef"
NavigationIntent.NavigateToBrowser(url)
}
controller.queue(intent)
},
)
}

View File

@ -53,6 +53,7 @@ fun OtherSettingsScreen() {
),
SettingPaneItem.Item(Setting.ABOUT_APP),
SettingPaneItem.Item(Setting.ABOUT_APP_BUILD_DATE),
SettingPaneItem.Item(Setting.ABOUT_APP_BUILD_REF),
),
)
}

View File

@ -838,6 +838,11 @@
<string name="pref_item_nav_label_title">Show labels on navigation buttons</string>
<string name="pref_item_app_version_title">App version</string>
<string name="pref_item_app_build_date_title">App build date</string>
<!--
The short ref name of the branch or tag that triggered the workflow run.
This value matches the branch or tag name shown on GitHub.
-->
<string name="pref_item_app_build_ref_title">App build ref</string>
<string name="pref_item_app_team_title">Team behind the app</string>
<string name="pref_item_reddit_community_title">Reddit community</string>
<string name="pref_item_github_title">GitHub project</string>

View File

@ -0,0 +1,15 @@
package com.artemchep.keyguard.copy
import com.artemchep.keyguard.build.BuildKonfig
import com.artemchep.keyguard.common.usecase.GetAppBuildRef
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import org.kodein.di.DirectDI
class GetAppBuildRefImpl(
) : GetAppBuildRef {
constructor(directDI: DirectDI) : this(
)
override fun invoke(): Flow<String> = flowOf(BuildKonfig.buildRef)
}

View File

@ -85,6 +85,7 @@ import com.artemchep.keyguard.common.usecase.GetAllowScreenshots
import com.artemchep.keyguard.common.usecase.GetAllowTwoPanelLayoutInLandscape
import com.artemchep.keyguard.common.usecase.GetAllowTwoPanelLayoutInPortrait
import com.artemchep.keyguard.common.usecase.GetAppBuildDate
import com.artemchep.keyguard.common.usecase.GetAppBuildRef
import com.artemchep.keyguard.common.usecase.GetAppBuildType
import com.artemchep.keyguard.common.usecase.GetAppIcons
import com.artemchep.keyguard.common.usecase.GetAppVersion
@ -305,6 +306,7 @@ import com.artemchep.keyguard.copy.Base32ServiceJvm
import com.artemchep.keyguard.copy.Base64ServiceJvm
import com.artemchep.keyguard.copy.DateFormatterAndroid
import com.artemchep.keyguard.copy.GetAppBuildDateImpl
import com.artemchep.keyguard.copy.GetAppBuildRefImpl
import com.artemchep.keyguard.copy.GetPasswordStrengthJvm
import com.artemchep.keyguard.copy.NumberFormatterJvm
import com.artemchep.keyguard.copy.PasswordGeneratorDiceware
@ -903,6 +905,11 @@ fun globalModuleJvm() = DI.Module(
directDI = this,
)
}
bindSingleton<GetAppBuildRef> {
GetAppBuildRefImpl(
directDI = this,
)
}
bindProvider<MessageHub> {
instance<MessageHubImpl>()
}