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
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2

updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "11:00"

- package-ecosystem: nuget
directory: "/"
schedule:
interval: daily
time: "11:00"
41 changes: 36 additions & 5 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ on:

env:
GLOBAL_JSON_PATH: './src/global.json'
DOTNET_VERSION: '10.0.x'
PROJECT_PATH: './src/signal.sln'
PACKAGE_OUTPUT_DIRECTORY: './packages'
TEST_OUTPUT_DIRECTORY: './testresults'

permissions:
contents: write
deployments: write

jobs:
build:
permissions:
contents: read
# For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: ubuntu-latest
Expand Down Expand Up @@ -48,13 +54,32 @@ jobs:
run: dotnet restore ${{ env.PROJECT_PATH }}

- name: Build
run: dotnet build --configuration Release --no-restore ${{ env.PROJECT_PATH }} /p:Version=${{ steps.gitversion.outputs.semVer }}
run: >
dotnet build
--configuration Release
--no-restore
${{ env.PROJECT_PATH }}
/p:Version=${{ steps.gitversion.outputs.semVer }}

- name: Run tests
run: dotnet test --configuration Release --no-build --verbosity normal ${{ env.PROJECT_PATH }}
run: >
dotnet test
--configuration Release
--no-build
--collect:"XPlat Code Coverage;Format=opencover"
--logger trx
--results-directory ${{ env.TEST_OUTPUT_DIRECTORY }}
--verbosity normal
${{ env.PROJECT_PATH }}

- name: Create NuGet package
run: dotnet pack --configuration Release --no-build --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }} ${{ env.PROJECT_PATH }} /p:PackageVersion=${{ steps.gitversion.outputs.semVer }}
run: >
dotnet pack
--configuration Release
--no-build
--output ${{ env.PACKAGE_OUTPUT_DIRECTORY }}
${{ env.PROJECT_PATH }}
/p:PackageVersion=${{ steps.gitversion.outputs.semVer }}

- name: Upload package artifacts
uses: actions/upload-artifact@v4
Expand All @@ -63,8 +88,14 @@ jobs:
path: ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg

publish:
permissions:
contents: write
deployments: write
runs-on: ubuntu-latest
needs: build
environment:
name: production
url: https://www.nuget.org/packages/Signal.Bot
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

steps:
Expand All @@ -82,7 +113,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
global-json-file: ${{ env.GLOBAL_JSON_PATH }}

- name: Publish to NuGet
run: |
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main", feature/*, ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '38 2 * * 2'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v6

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v4

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
> A .NET Signal Messenger Bot Client - because sometimes Telegram isn't enough

[![NuGet](https://img.shields.io/nuget/v/Signal.Bot.svg)](https://www.nuget.org/packages/Signal.Bot/)
[![Build Status](https://img.shields.io/github/actions/workflow/status/st0o0/signal.bot/dotnet.yml?branch=main)](https://github.com/st0o0/signal.bot/actions)
[![License](https://img.shields.io/github/license/st0o0/signal.bot)](LICENSE)
[![Build Status](https://img.shields.io/github/actions/workflow/status/st0o0/signal.bot/build-and-release.yml?branch=main)](https://github.com/st0o0/Signal.Bot/actions)
[![License](https://img.shields.io/github/license/st0o0/Signal.Bot)](LICENSE)
[![Downloads](https://img.shields.io/nuget/dt/Signal.Bot.svg)](https://www.nuget.org/packages/Signal.Bot/)


Expand Down
2 changes: 2 additions & 0 deletions src/Signal.Bot.Example.Env/Apphost.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var builder = DistributedApplication.CreateBuilder(args);
var number = builder.AddParameter("NUMBER", secret: true);

var signalCli = builder
.AddContainer("signal-cli-rest-api", "bbernhard/signal-cli-rest-api")
Expand All @@ -10,6 +11,7 @@

var signalClient = builder
.AddProject<Projects.Signal_Bot_Example>("signal-bot-example")
.WithEnvironment("NUMBER", number)
.WaitFor(signalCli);

await builder.Build().RunAsync();
2 changes: 1 addition & 1 deletion src/Signal.Bot.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Signal.Bot.Example;

var builder = WebApplication.CreateBuilder(args);
Console.WriteLine($"Phone {Environment.GetEnvironmentVariable("NUMBER")!}");
Console.WriteLine($"Phone {Environment.GetEnvironmentVariable("NUMBER")! }");
builder.Services
.AddHttpClient("signalbot_client", client => client.BaseAddress = new Uri("http://localhost:1337"))
.AddTypedClient<ISignalBotClient>((httpClient, sp) =>
Expand Down
13 changes: 5 additions & 8 deletions src/Signal.Bot.Example/Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
//var t1 = await client.GetAboutAsync(stoppingToken);
//var t2 = await client.GetAccountsAsync(stoppingToken);
//var t4 = await client.GetContactsAsync(stoppingToken);
var t3 = await client.GetDevicesAsync(stoppingToken);
foreach (var device in t3)
{
var created = DateTimeOffset.FromUnixTimeMilliseconds(device.Created ?? 0);
logger.LogInformation("Created: {DateTimeOffset}", created.UtcDateTime);
var lastSeen = DateTimeOffset.FromUnixTimeMilliseconds(device.LastSeen ?? 0);
logger.LogInformation("LastSeen: {DateTimeOffset}", lastSeen.UtcDateTime);
}
//var t3 = await client.GetDevicesAsync(stoppingToken);
//var t5 = await client.GetGroupsAsync(stoppingToken);
var t6 = await client.GetIdentitiesAsync(stoppingToken);
var t7 = (await client.GetAttachmentsAsync(stoppingToken)).ToArray();
var t8 = await client.GetAttachmentAsync(t7[0], stoppingToken);
}
}
1 change: 0 additions & 1 deletion src/Signal.Bot.Example/Signal.Bot.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.2" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.2.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Signal.Bot.Tests/Signal.Bot.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
<PackageReference Include="Moq" Version="4.20.72"/>
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="xunit" Version="2.9.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4"/>
</ItemGroup>
Expand Down
Loading