Skip to content
This repository has been archived by the owner on Mar 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from corenting/update_net_5_0
Browse files Browse the repository at this point in the history
Update to .NET 5.0
  • Loading branch information
corenting committed Nov 13, 2020
2 parents c74432b + d70fe91 commit d236987
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 61 deletions.
31 changes: 7 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,17 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
runtime-identifier: [ "win-x64", "win-arm64", "linux-x64", "linux-musl-x64", "linux-arm64", "linux-arm"]
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Build (win-x64)
run: make release
env:
RUNTIME_IDENTIFIER: win-x64
- name: Build (win-arm64)
run: make release
env:
RUNTIME_IDENTIFIER: win-arm64
- name: Build (linux-x64)
run: make release
- name: Build (linux-musl-x64)
run: make release
env:
RUNTIME_IDENTIFIER: linux-musl-x64
- name: Build (linux-arm64)
run: make release
env:
RUNTIME_IDENTIFIER: linux-arm64
- name: Build (linux-arm)
dotnet-version: 5.0.x
- name: Build app
run: make release
env:
RUNTIME_IDENTIFIER: linux-arm
RUNTIME_IDENTIFIER: ${{ matrix.runtime-identifier }}
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
RUNTIME_IDENTIFIER?=linux-x64
BUILD_FOLDER=src/MumbleServerStatsd/bin/Release/netcoreapp3.1/$(RUNTIME_IDENTIFIER)/publish
VERSION=$(shell git rev-parse --short HEAD)
BUILD_FOLDER=src/MumbleServerStatsd/bin/Release/net5.0/$(RUNTIME_IDENTIFIER)/publish

.PHONY: release
release:
dotnet publish src/MumbleServerStatsd -p:PublishTrimmed=true -r $(RUNTIME_IDENTIFIER) -c Release /p:PublishSingleFile=true
rm src/MumbleServerStatsd/bin/Release/netcoreapp3.1/$(RUNTIME_IDENTIFIER)/publish/MumbleServerStatsd.pdb
dotnet publish src/MumbleServerStatsd -r $(RUNTIME_IDENTIFIER) -c Release /p:PublishTrimmed=true /p:PublishSingleFile=true /p:IncludeNativeLibrariesInSingleFile=true
rm src/MumbleServerStatsd/bin/Release/net5.0/$(RUNTIME_IDENTIFIER)/publish/MumbleServerStatsd.pdb
mkdir -p build
zip -r -j build/mumble_server_statsd_$(VERSION)_$(RUNTIME_IDENTIFIER).zip $(BUILD_FOLDER)/MumbleServerStatsd*
zip -r -j build/mumble_server_statsd_$(RUNTIME_IDENTIFIER).zip $(BUILD_FOLDER)/MumbleServerStatsd*

.PHONY: release-all
release-all:
RUNTIME_IDENTIFIER=linux-x64 make release
RUNTIME_IDENTIFIER=linux-musl-x64 make release
RUNTIME_IDENTIFIER=linux-arm make release
RUNTIME_IDENTIFIER=linux-arm64 make release
RUNTIME_IDENTIFIER=win-x64 make release
RUNTIME_IDENTIFIER=win-arm64 make release

.PHONY: clean
clean:
dotnet clean
rm -rf build
rm -rf build
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MumbleServerStatsd

![Build](https://github.com/corenting/MumbleServerStatsd/workflows/Build/badge.svg) ![Latest Release](https://img.shields.io/github/v/release/corenting/MumbleServerStatsd) ![License](https://img.shields.io/github/license/corenting/MumbleServerStatsd)
![Build](https://github.com/corenting/MumbleServerStatsd/workflows/Build/badge.svg?branch=master) ![Latest Release](https://img.shields.io/github/v/release/corenting/MumbleServerStatsd) ![License](https://img.shields.io/github/license/corenting/MumbleServerStatsd)

Send the number of connected users of a mumble server as a statsd gauge.

Expand All @@ -25,4 +25,4 @@ Available in [Github releases](https://github.com/corenting/MumbleServerStatsd/r
- Linux arm64
- Linux arm
- Windows x64
- Windows arm64
- Windows arm64
8 changes: 0 additions & 8 deletions StyleCopeRules.ruleset

This file was deleted.

14 changes: 7 additions & 7 deletions src/MumbleServerStatsd/MumbleServerStatsd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<CodeAnalysisRuleSet>..\..\StyleCopeRules.ruleset</CodeAnalysisRuleSet>
<TargetFramework>net5.0</TargetFramework>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>

<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<Version>1.1.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EndianBitConverter" Version="1.1.0" />
<PackageReference Include="JustEat.StatsD" Version="4.2.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.3.0-alpha.20303.1" />
<PackageReference Include="CommandLineParser" Version="2.8.0" />
</ItemGroup>

</Project>
47 changes: 33 additions & 14 deletions src/MumbleServerStatsd/Program.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
namespace MumbleServerStatsd
{
using System;
using CommandLine;
using CommandLine.Text;
using MumbleServerStatsd.Ping;

/// <summary>
/// CLI Entrypoint.
/// </summary>
public class Program
{
/// <summary>
/// statsd client for mumble-server.
/// </summary>
/// <param name="mumbleHostname">hostname or IP of the mumble server.</param>
/// <param name="statsdHostname">hostname or IP of the statsd server.</param>
/// <param name="statsdPort">port of the statsd server (optional, 8125 if not set).</param>
/// <param name="mumblePort">port of the server (optional, 64738 if not set).</param>
public static void Main(string mumbleHostname, string statsdHostname, int statsdPort = 8125, int mumblePort = 64738)
public class Options
{
if (mumbleHostname == null)
[Option("mumble-hostname", Required = true, HelpText = "Hostname or IP of the mumble server.")]
public string MumbleHostname { get; set; }

[Option("statsd-hostname", Required = true, HelpText = "Hostname or IP of the statsd server.")]
public string StatsdHostname { get; set; }

[Option("statsd-port", Default = 8125, HelpText = "Port of the statsd server (optional, 8125 if not set).")]
public int StatsdPort { get; set; }

[Option("mumble-port", Default = 64738, HelpText = "Port of the mumble server (optional, 64738 if not set).")]
public int MumblePort { get; set; }
}

public static void Main(string[] args)
{
var parser = new CommandLine.Parser(with => with.HelpWriter = null);
var parserResult = parser.ParseArguments<Options>(args);
var helpText = HelpText.AutoBuild(parserResult, h =>
{
Console.Error.WriteLine("Error: you need to specify an hostname (see --help for help).");
Environment.Exit(1);
}
h.AdditionalNewLineAfterOption = false;
h.Copyright = "";
return h;
}, e => e);

PingResponse ping = PingUtils.PingServer(mumbleHostname, mumblePort);
Statsd.SendGauge(statsdHostname, statsdPort, ping.ConnectedUsers);
parserResult
.WithParsed<Options>(options => {
PingResponse ping = PingUtils.PingServer(options.MumbleHostname, options.MumblePort);
Statsd.SendGauge(options.StatsdHostname, options.StatsdPort, ping.ConnectedUsers);
})
.WithNotParsed(errs => {
Console.Error.WriteLine(helpText);
});
}
}
}

0 comments on commit d236987

Please sign in to comment.