Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7.2.0 #221

Merged
merged 35 commits into from
Aug 20, 2024
Merged

7.2.0 #221

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ed4dcfc
add stateful links
vendelieu Aug 15, 2024
d79e128
add redis impl for stateful link
vendelieu Aug 15, 2024
0aaea97
Update gradle/actions action to v4 (#218)
renovate[bot] Aug 15, 2024
655e849
fix release ci
vendelieu Aug 15, 2024
0a1da5b
apply stateful link example
vendelieu Aug 15, 2024
5103761
fix GeneratedActivities.kt
vendelieu Aug 16, 2024
d3d3ada
remove renovate for snapping
vendelieu Aug 16, 2024
4073d23
exclude build for non-build places
vendelieu Aug 16, 2024
cdbb394
Update dependency ch.qos.logback:logback-classic to v1.5.7 (#219)
renovate[bot] Aug 16, 2024
c3f2266
add more tests
vendelieu Aug 16, 2024
77cde87
add chain getAllState bindings generation
vendelieu Aug 16, 2024
52decbe
lint
vendelieu Aug 17, 2024
426d520
fix wrong input for className
vendelieu Aug 17, 2024
e06cfb2
add gradle plugin
vendelieu Aug 18, 2024
c0181f1
update readme and wflows
vendelieu Aug 18, 2024
9cfc40c
update readme and wflows
vendelieu Aug 18, 2024
81776dc
update plugin
vendelieu Aug 18, 2024
0975970
add an error message for the wrong package name
vendelieu Aug 18, 2024
c38e842
update snap publish
vendelieu Aug 18, 2024
62db146
update readme
vendelieu Aug 18, 2024
6b8d7c1
remove implementation
vendelieu Aug 18, 2024
f1d9b4c
remove ChainStateManager
vendelieu Aug 18, 2024
0af3bdd
update build script
vendelieu Aug 18, 2024
a7467ff
update build script
vendelieu Aug 18, 2024
106f4dc
update api
vendelieu Aug 18, 2024
1ed1a0e
disabe automated publishing
vendelieu Aug 18, 2024
059d205
exclude plugin from gh maven
vendelieu Aug 18, 2024
1240aeb
improve plugin code
vendelieu Aug 18, 2024
10a2da1
improve plugin code
vendelieu Aug 18, 2024
4d73dc7
Update README.md
vendelieu Aug 18, 2024
cf44777
Update README.md
vendelieu Aug 18, 2024
6bb209d
update version regex
vendelieu Aug 19, 2024
ca406d8
Update dependency org.jetbrains.kotlinx:kotlinx-datetime to v0.6.1 (#…
renovate[bot] Aug 20, 2024
10a7630
note changes
vendelieu Aug 20, 2024
7870fa9
return datetime to make toml config work correctly
vendelieu Aug 20, 2024
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
44 changes: 42 additions & 2 deletions .github/workflows/ci.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,39 @@ on:
push:
branches:
- master
paths-ignore:
- '.editorconfig'
- '.gitignore'
- 'CHANGELOG.md'
- 'CODE_OF_CONDUCT.md'
- 'CONTRIBUTING.md'
- 'FUNDING.yml'
- 'LICENSE'
- 'README.md'
- 'SECURITY.md'
- 'gradlew'
- 'gradlew.bat'
- 'parse_changelog.sh'
- 'renovate.json'
- '.github/**'
- 'assets/**'
pull_request:
paths-ignore:
- '.editorconfig'
- '.gitignore'
- 'CHANGELOG.md'
- 'CODE_OF_CONDUCT.md'
- 'CONTRIBUTING.md'
- 'FUNDING.yml'
- 'LICENSE'
- 'README.md'
- 'SECURITY.md'
- 'gradlew'
- 'gradlew.bat'
- 'parse_changelog.sh'
- 'renovate.json'
- '.github/**'
- 'assets/**'

permissions:
contents: write
Expand All @@ -22,11 +54,19 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3-beta
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: current
dependency-graph: generate-and-submit

- name: Cache konan dependencies
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Build artifact
env:
TELEGRAM_ID: ${{ secrets.TELEGRAM_ID }}
Expand All @@ -35,7 +75,7 @@ jobs:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
BOT_TOKEN_2: ${{ secrets.BOT_TOKEN_2 }}
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
run: ./gradlew clean koverXmlReport
run: ./gradlew koverXmlReport

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
26 changes: 24 additions & 2 deletions .github/workflows/ci.gh.snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: GH Packages Autorelease
on:
push:
paths:
- 'buildSrc/**'
- 'helper/**'
- 'telegram-bot/**'
- 'ksp/**'
Expand All @@ -17,7 +18,20 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_type == 'branch'
if: github.event_name == 'push' && github.ref_type == 'branch' && !startsWith(github.ref, 'refs/heads/renovate/')
strategy:
matrix:
module: [
":telegram-bot",
":ksp",
":webapps",
":ktgram-utils",
":ktgram-botctx-redis",
":ktgram-config-env",
":ktgram-config-toml",
":ktor-starter",
":spring-ktgram-starter"
]
steps:
- uses: actions/checkout@v4

Expand All @@ -40,7 +54,15 @@ jobs:
with:
gradle-version: current

- name: Cache konan dependencies
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Publish to Gh
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: ./gradlew publishAllPublicationsToGHPackagesRepository -PlibVersion=${{ env.git_branch }}-${{ env.date }}~${{ env.git_hash }}
run: ./gradlew ${{ matrix.module }}:publishAllPublicationsToGHPackagesRepository -PlibVersion=${{ env.git_branch }}-${{ env.date }}~${{ env.git_hash }} --no-parallel
21 changes: 17 additions & 4 deletions .github/workflows/ci.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ jobs:
java-version: 17

- name: Setup gradle
uses: gradle/actions/setup-gradle@v3-beta
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: current

- name: Cache konan dependencies
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Prepare to publish
run: |
echo '${{secrets.GPG_KEY_CONTENTS}}' | base64 -d > publish_key.gpg
Expand All @@ -56,8 +64,13 @@ jobs:
BRANCH: gh-pages
FOLDER: telegram-bot/build/dokka

- run: ./gradlew publishPlugins -PlibVersion=${{ needs.version.outputs.version }}
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}

readme:
needs: publish
needs: [ version, publish ]
name: Replace version in README.md
runs-on: ubuntu-latest
permissions:
Expand All @@ -68,8 +81,8 @@ jobs:
ref: ${{ github.head_ref }}
- uses: jacobtomlinson/gha-find-replace@v3
with:
find: '[0-9]+.[0-9]+.[0-9]+\"\)'
replace: "${{ needs.version.outputs.version }}\")"
find: '[:"]([0-9]+\.[0-9]+\.[0-9]+)\"'
replace: "${{ needs.version.outputs.version }}"
include: "**README.md"
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Telegram-bot (KtGram) changelog

## 7.2.0

* Added new plugin for a more convenient installation of the library.
* Moved from `ChainStateManager` to `StatefulLink` flow, since it's more convenient.

## 7.1.0

* Cover Telegram API [7.9](https://core.telegram.org/bots/api#august-14-2024) version.
Expand Down
58 changes: 46 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@ Telegram Bot Api wrapper with a user-friendly interface.

# Installation

Add the ksp plugin and library to the dependencies.
Add the ksp plugin and library plugin to your Gradle build file.

build.gradle.kts example:

```gradle
plugins {
// ...
id("com.google.devtools.ksp") version "2.0.10-1.0.24"
id("eu.vendeli.telegram-bot") version "7.1.0"
}
```

<details>
<summary>Manually</summary>
To set up the project without using the plugin, you need to add a dependency and configure the ksp processor:

```gradle
plugins {
// ...
Expand All @@ -30,12 +42,27 @@ dependencies {
}
```

For multiplatform, you need to add the dependency to common sources and define ksp for the targets you need, see example
in [native-example](https://github.com/ktgram/native-example/blob/master/build.gradle.kts).
</details>


<details>
<summary><i>Snapshots</i></summary>

[![Snapshot version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fv229149.hosted-by-vdsina.ru%2Fsnap-ver%2Ftelegram-bot&query=%24%5B0%5D.name&logo=github&label=SNAPSHOT&link=https%3A%2F%2Fgithub.com%2Fvendelieu%3Ftab%3Dpackages%26repo_name%3Dtelegram-bot)](https://github.com/vendelieu?tab=packages&repo_name=telegram-bot)

To install snapshot versions add dev repository:
To install snapshot versions, add snapshot repository,
if you're using plugin just use `addSnapshotRepo` parameter:

```gradle
ktGram {
forceVersion = "branch-xxxxxx~xxxxxx"
addSnapshotRepo = true
}
```

or manually add repository:

```gradle
repositories {
Expand All @@ -45,8 +72,8 @@ repositories {
}
```

And use the latest package version from [packages](https://github.com/vendelieu?tab=packages&repo_name=telegram-bot) or
from badge above.
And add library dependency (with ksp processor) as described in `manually` section using the latest package version
from [packages](https://github.com/vendelieu?tab=packages&repo_name=telegram-bot) or from badge above.

</details>

Expand Down Expand Up @@ -128,20 +155,23 @@ fun main() = runBlocking {

### Configuration

The library has very flexible customization options, \,
The library has very flexible customization options, \,
and there are different options to configure through external sources.

You can read more in a [Bot configuration](https://github.com/vendelieu/telegram-bot/wiki/Bot-configuration) article.

### Processing responses

To process over response or/and have more control over request flow
use [`sendReturning()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.interfaces/-action/send-returning.html)
use [
`sendReturning()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.interfaces.action/-action/send-returning.html)
instead
of [`send()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.interfaces/-action/send.html)
of [
`send()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.interfaces.action/-action/send.html)
method,
which
returns [`Response`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/-response/index.html):
returns [
`Response`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/-response/index.html):

```kotlin
message { "test" }.sendReturning(user, bot).onFailure {
Expand All @@ -150,11 +180,15 @@ message { "test" }.sendReturning(user, bot).onFailure {
```

Any `sendReturning` method returns
a [`Response`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/-response/index.html)
a [
`Response`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/-response/index.html)
on which you can also use
methods [`getOrNull()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/get-or-null.html)
, [`isSuccess()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/is-success.html)
, [`onFailure()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/on-failure.html)
methods [
`getOrNull()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/get-or-null.html)
, [
`isSuccess()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/is-success.html)
, [
`onFailure()`](https://vendelieu.github.io/telegram-bot/-telegram%20-bot/eu.vendeli.tgbot.types.internal/on-failure.html)

### Additional resources

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ plugins {
}

tasks.create("prepareRelease") {
dependsOn("ksp:formatKotlin")
dependsOn("telegram-bot:kdocUpdate")
dependsOn("telegram-bot:formatKotlin")
dependsOn("ktgram-gradle-plugin:formatKotlin")
dependsOn("helper:formatKotlin")

dependsOn("ksp:detekt")
Expand Down
23 changes: 13 additions & 10 deletions buildSrc/src/main/kotlin/publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.KotlinMultiplatform
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id("com.vanniktech.maven.publish")
}

apply(plugin = "org.jetbrains.kotlin.multiplatform")
val libraryData = extensions.create("libraryData", PublishingExtension::class)
val doSign = providers.gradleProperty("signing.keyId").isPresent
val releaseMode = providers.gradleProperty("signing.keyId").isPresent
val isMultiplatform = !project.plugins.hasPlugin("org.jetbrains.kotlin.jvm")

if (isMultiplatform) apply(plugin = "org.jetbrains.kotlin.multiplatform")

mavenPublishing {
coordinates("eu.vendeli", project.name, project.version.toString())
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true)
if (doSign) signAllPublications()
if (releaseMode) signAllPublications()

val javaDoc = if (project.name == "telegram-bot" && releaseMode) JavadocJar.Dokka("dokkaHtml")
else JavadocJar.Empty()

val platformArtifact = if (isMultiplatform) KotlinMultiplatform(javaDoc, true)
else KotlinJvm(JavadocJar.None(), true)

configure(
KotlinMultiplatform(
javadocJar = if (project.name == "telegram-bot" && doSign) JavadocJar.Dokka("dokkaHtml")
else JavadocJar.Empty(),
sourcesJar = true,
),
)
configure(platformArtifact)

pom {
name = libraryData.name
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
org.gradle.jvmargs=-Xmx4096M -XX:MaxMetaspaceSize=1024m
org.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache-problems=warn
org.gradle.configuration-cache=true
kotlin.incremental=true
7 changes: 4 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ktor = "2.3.12"
redis = "6.4.0.RELEASE"
logging = "2.0.4"
logback = "1.5.6"
logback = "1.5.7"

datetime = "0.6.0"
serialization = "1.7.1"
Expand All @@ -27,6 +27,7 @@ poet = "1.18.1"

binvalid = "0.16.3"
publisher = "0.29.0"
gradle-publish = "1.2.1"
env = "1.0.4"

[libraries]
Expand Down Expand Up @@ -62,6 +63,7 @@ ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref =
poet = { module = "com.squareup:kotlinpoet", version.ref = "poet" }
poet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "poet" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
ksp-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" }

ssl-utils = { module = "io.github.hakky54:sslcontext-kickstart-for-pem", version.ref = "sslcontext" }
spring-starter = { module = "org.springframework.boot:spring-boot-starter", version.ref = "spring" }
Expand All @@ -71,12 +73,11 @@ redis = { module = "io.lettuce:lettuce-core", version.ref = "redis" }
env = { module = "dev.scottpierce:kotlin-env-var", version.ref = "env" }
toml = { module = "net.peanuuutz.tomlkt:tomlkt", version.ref = "toml" }


[plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-js-plain-objects = { id = "org.jetbrains.kotlin.plugin.js-plain-objects", version.ref = "kotlin" }
kotlin-compatability-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binvalid" }
gradle-publish = { id = "com.gradle.plugin-publish", version.ref = "gradle-publish"}
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
Expand Down
Loading
Loading