Skip to content
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/build-test-pack-push-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build Test Pack Push Release

on:
workflow_dispatch:
inputs:
release_notes:
description: "Release notes"
required: true
version:
description: "Release version (ex: 1.0.0)"
required: true

permissions:
contents: write
id-token: write
packages: write

jobs:
build-test-pack-push:
uses: ./.github/workflows/build-test-pack-push.yml
with:
release_notes: ${{ inputs.release_notes }}
version: ${{ inputs.version }}
secrets: inherit

release:
runs-on: ubuntu-latest
needs: [ build-test-pack-push ]
steps:
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ inputs.version }}
body: |
## Release Notes
${{ inputs.release_notes }}
prerelease: true
generate_release_notes: true
55 changes: 55 additions & 0 deletions .github/workflows/build-test-pack-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Test Pack Push

on:
workflow_call:
inputs:
wfl_call:
description: 'is called from workflow'
type: boolean
required: false
default: true
release_notes:
description: 'Release notes'
type: string
required: true
version:
description: 'Release version'
type: string
required: true
workflow_dispatch:
pull_request:
branches:
- main

env:
PROJECT_PATH: ./src/TgBotPlay.WebAPI
UNITTEST_PATH:
CONFIGURATION: Release
RELEASE_NOTES: ${{ inputs.release_notes }}
VERSION: ${{ inputs.version || '0.0.1'}}

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore $PROJECT_PATH
- name: Build
run: dotnet build $PROJECT_PATH --no-restore --configuration $CONFIGURATION -p:Version=$VERSION "-p:ReleaseNotes=\"$RELEASE_NOTES\""
# - name: Test
# run: dotnet test $UNITTEST_PATH --verbosity normal --configuration $CONFIGURATION
- name: Push Package to NuGet.org
if: ${{ inputs.wfl_call }}
run: dotnet nuget push **\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
- name: Tag and push
if: ${{ inputs.wfl_call }}
run: |
git tag v$VERSION
git push --tags
Binary file added logo/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 29 additions & 1 deletion src/TgBotPlay.WebAPI/TgBotPlay.WebAPI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;</TargetFrameworks>
<LangVersion>12.0</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>TgBotPlay.WebAPI</PackageId>
<Authors>Mohammad Mahdi Nazari</Authors>
<Company>IPdotSetAF</Company>
<Description>A comprehensive WebAPI integration library for Telegram Bot development with support for both polling and webhook modes, health checks, and flexible configuration options.</Description>
<PackageProjectUrl>https://github.com/IPdotSetAF/TgBotPlay.WebAPI</PackageProjectUrl>
<RepositoryUrl>https://github.com/IPdotSetAF/TgBotPlay.WebAPI</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>LGPL-2.1-or-later</PackageLicenseExpression>
<PackageTags>telegram;bot;webapi;aspnetcore;polling;webhook</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>logo.jpg</PackageIcon>
<Copyright>IPdotSetAF © 2025</Copyright>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(PackageId).xml</DocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -10,4 +33,9 @@
<PackageReference Include="Telegram.Bot.AspNetCore" Version="22.*" />
</ItemGroup>

<ItemGroup>
<None Include="../../README.md" Pack="true" PackagePath="\" />
<None Include="../../logo/logo.jpg" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
12 changes: 10 additions & 2 deletions src/TgBotPlay.WebAPI/TgBotPlayExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Http;
using Microsoft.Extensions.Options;
using Telegram.Bot;
using Telegram.Bot.AspNetCore;
Expand All @@ -24,8 +25,15 @@ public static IServiceCollection AddTgBotPlay<TUpdateHandler>(this IServiceColle
{
var settings = services.ConfigureSettings(options);

services.AddHttpClient("TgBotPlayClient").RemoveAllLoggers().AddTypedClient<ITelegramBotClient>(
httpClient => new TelegramBotClient(settings.Token!, httpClient));
services.AddHttpClient("TgBotPlayClient")
#if NET8_0_OR_GREATER
.RemoveAllLoggers()
#endif
.AddTypedClient<ITelegramBotClient>(
httpClient => new TelegramBotClient(new TelegramBotClientOptions(settings.Token!), httpClient));
#if NET6_0 || NET7_0
services.RemoveAll<IHttpMessageHandlerBuilderFilter>();
#endif

services.AddScoped<TgBotPlayUpdateHandlerBase, TUpdateHandler>();

Expand Down