mirror of
https://github.com/dessalines/thumb-key.git
synced 2024-09-11 08:55:43 +03:00
Adding local pre-tag changelog generation. (#688)
- Adds a ./generate_changelog.sh script, using git-cliff. - Removes unecessary internet permission. - Fixes #683
This commit is contained in:
parent
d84d28ce14
commit
902b25cf5e
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,6 +12,7 @@
|
||||
local.properties
|
||||
app/release
|
||||
app/schemas
|
||||
app/src/main/assets
|
||||
.project
|
||||
.settings
|
||||
.classpath
|
||||
|
@ -71,7 +71,6 @@ android {
|
||||
dependencies {
|
||||
|
||||
implementation "com.github.jeziellago:compose-markdown:0.3.5"
|
||||
implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.12"
|
||||
|
||||
implementation 'androidx.navigation:navigation-compose:2.7.6'
|
||||
implementation 'com.github.alorma:compose-settings-ui-m3:1.0.3'
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application
|
||||
android:name=".ThumbkeyApplication"
|
||||
android:allowBackup="true"
|
||||
|
@ -25,11 +25,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
const val DEFAULT_KEY_SIZE = 64
|
||||
const val DEFAULT_ANIMATION_SPEED = 250
|
||||
@ -360,28 +356,11 @@ class AppSettingsRepository(private val appSettingsDao: AppSettingsDao) {
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
suspend fun updateChangelog() {
|
||||
suspend fun updateChangelog(ctx: Context) {
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val httpClient: OkHttpClient =
|
||||
OkHttpClient.Builder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.addNetworkInterceptor { chain ->
|
||||
chain.request().newBuilder()
|
||||
.header("User-Agent", "Thumb-Key")
|
||||
.build()
|
||||
.let(chain::proceed)
|
||||
}
|
||||
.build()
|
||||
Log.d("thumb-key", "Fetching RELEASES.md ...")
|
||||
// Fetch the markdown text
|
||||
val releasesUrl =
|
||||
"https://raw.githubusercontent.com/dessalines/thumb-key/main/RELEASES.md".toHttpUrl()
|
||||
val req = Request.Builder().url(releasesUrl).build()
|
||||
val res = httpClient.newCall(req).execute()
|
||||
_changelog.value = res.body.string()
|
||||
val releasesStr = ctx.assets.open("RELEASES.md").bufferedReader().use { it.readText() }
|
||||
_changelog.value = releasesStr
|
||||
} catch (e: Exception) {
|
||||
Log.e("thumb-key", "Failed to load changelog: $e")
|
||||
}
|
||||
@ -607,9 +586,9 @@ class AppSettingsViewModel(private val repository: AppSettingsRepository) : View
|
||||
repository.updateLastVersionCodeViewed(versionCode)
|
||||
}
|
||||
|
||||
fun updateChangelog() =
|
||||
fun updateChangelog(ctx: Context) =
|
||||
viewModelScope.launch {
|
||||
repository.updateChangelog()
|
||||
repository.updateChangelog(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,8 @@ val DONATION_MARKDOWN =
|
||||
- [Support on Liberapay](https://liberapay.com/dessalines).
|
||||
- [Support on Patreon](https://www.patreon.com/dessalines).
|
||||
|
||||
---
|
||||
|
||||
""".trimIndent()
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@ -62,7 +64,7 @@ fun ShowChangelog(appSettingsViewModel: AppSettingsViewModel) {
|
||||
val scrollState = rememberScrollState()
|
||||
val markdown by appSettingsViewModel.changelog.collectAsState()
|
||||
LaunchedEffect(appSettingsViewModel) {
|
||||
appSettingsViewModel.updateChangelog()
|
||||
appSettingsViewModel.updateChangelog(ctx)
|
||||
}
|
||||
|
||||
AlertDialog(
|
||||
|
77
cliff.toml
Normal file
77
cliff.toml
Normal file
@ -0,0 +1,77 @@
|
||||
# git-cliff ~ configuration file
|
||||
# https://git-cliff.org/docs/configuration
|
||||
|
||||
[remote.github]
|
||||
owner = "dessalines"
|
||||
repo = "thumb-key"
|
||||
# token = ""
|
||||
|
||||
[changelog]
|
||||
# template for the changelog body
|
||||
# https://keats.github.io/tera/docs/#introduction
|
||||
body = """
|
||||
# Thumb-Key {{ version }} ({{ timestamp | date(format="%Y-%m-%d") }})
|
||||
|
||||
## What's Changed
|
||||
{% for commit in commits %}
|
||||
{% if commit.github.pr_title -%}
|
||||
{%- set commit_message = commit.github.pr_title -%}
|
||||
{%- else -%}
|
||||
{%- set commit_message = commit.message -%}
|
||||
{%- endif -%}
|
||||
* {{ commit_message | split(pat="\n") | first | trim }}\
|
||||
{% if commit.github.username %} by @{{ commit.github.username }}{%- endif -%}
|
||||
{% if commit.github.pr_number %} in #{{ commit.github.pr_number }}{%- endif %}
|
||||
{%- endfor -%}
|
||||
|
||||
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
|
||||
{% raw %}\n{% endraw -%}
|
||||
## New Contributors
|
||||
{%- endif %}\
|
||||
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
|
||||
* @{{ contributor.username }} made their first contribution in #{{ contributor.pr_number }}
|
||||
{%- endfor -%}
|
||||
|
||||
{% if version %}
|
||||
{% if previous.version %}
|
||||
**Full Changelog**: https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}/compare/{{ previous.version }}...{{ version }}
|
||||
{% endif %}
|
||||
{% else -%}
|
||||
{% raw %}\n{% endraw %}
|
||||
{% endif %}
|
||||
"""
|
||||
# remove the leading and trailing whitespace from the template
|
||||
trim = true
|
||||
# changelog footer
|
||||
footer = """
|
||||
<!-- generated by git-cliff -->
|
||||
"""
|
||||
# postprocessors
|
||||
postprocessors = []
|
||||
|
||||
[git]
|
||||
# parse the commits based on https://www.conventionalcommits.org
|
||||
conventional_commits = false
|
||||
# filter out the commits that are not conventional
|
||||
filter_unconventional = true
|
||||
# process each line of a commit as an individual commit
|
||||
split_commits = false
|
||||
# regex for preprocessing the commit messages
|
||||
commit_preprocessors = [
|
||||
# remove issue numbers from commits
|
||||
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
|
||||
]
|
||||
# protect breaking changes from being skipped due to matching a skipping commit_parser
|
||||
protect_breaking_commits = false
|
||||
# filter out the commits that are not matched by commit parsers
|
||||
filter_commits = false
|
||||
# regex for matching git tags
|
||||
tag_pattern = "v[0-9].*"
|
||||
# regex for skipping tags
|
||||
skip_tags = "beta|alpha"
|
||||
# regex for ignoring tags
|
||||
ignore_tags = "rc"
|
||||
# sort the tags topologically
|
||||
topo_order = false
|
||||
# sort the commits inside sections by oldest/newest order
|
||||
sort_commits = "newest"
|
13
generate_changelog.sh
Executable file
13
generate_changelog.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Creating the new tag
|
||||
new_tag="$1"
|
||||
last_tag=$(git describe --tags --abbrev=0)
|
||||
|
||||
# Writing to the Releases.md asset that's loaded inside the app
|
||||
git cliff "$last_tag"..HEAD --tag "$new_tag" --output app/src/main/assets/RELEASES.md
|
||||
|
||||
# Prepending to the RELEASES.md
|
||||
git cliff "$last_tag"..HEAD --tag "$new_tag" --prepend RELEASES.md
|
||||
prettier -w RELEASES.md
|
Loading…
Reference in New Issue
Block a user