Compare commits

..

3 Commits
1.1.3 ... main

Author SHA1 Message Date
0e09aaef5c
Bumped dependencies 2022-11-30 23:33:48 +01:00
29b8c59c9e
Automatically get version number from project file 2022-11-23 00:35:14 +01:00
bbdd5ce586
Bump version to 1.1.4
Added build script to solution files
Added address to configure client connection destination (if proxied)
Added automatic semantic versioning build
2022-11-23 00:28:01 +01:00
6 changed files with 37 additions and 20 deletions

View File

@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE65C879-794A-4695-B659-7376FE7DB5E3}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE65C879-794A-4695-B659-7376FE7DB5E3}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore .gitignore = .gitignore
build.py = build.py
MinecraftDiscordBot\bin\Debug\net6.0\config.json = MinecraftDiscordBot\bin\Debug\net6.0\config.json MinecraftDiscordBot\bin\Debug\net6.0\config.json = MinecraftDiscordBot\bin\Debug\net6.0\config.json
EndProjectSection EndProjectSection
EndProject EndProject

View File

@ -11,8 +11,11 @@ public class BotConfiguration : IBotConfiguration, IBotConfigurator {
[JsonProperty("token", Required = Required.Always)] [JsonProperty("token", Required = Required.Always)]
[Option('t', "token", HelpText = "The Discord bot token", Required = true)] [Option('t', "token", HelpText = "The Discord bot token", Required = true)]
public string Token { get; init; } = default!; public string Token { get; init; } = default!;
[JsonProperty("address", Required = Required.Always)]
[Option('a', "address", HelpText = "The connection string for the websocket", Required = true)]
public string Address { get; init; } = default!;
[JsonProperty("port", Required = Required.DisallowNull)] [JsonProperty("port", Required = Required.DisallowNull)]
[Option('p', "port", Default = DEFAULT_PORT, HelpText = "The websocket server port")] [Option('p', "port", Default = DEFAULT_PORT, HelpText = "The websocket server listen port")]
public int Port { get; init; } = DEFAULT_PORT; public int Port { get; init; } = DEFAULT_PORT;
[JsonProperty("channels", Required = Required.Always)] [JsonProperty("channels", Required = Required.Always)]
[Option('c', "channel", HelpText = "The list of whitelisted channels", Required = true, Min = 1)] [Option('c', "channel", HelpText = "The list of whitelisted channels", Required = true, Min = 1)]

View File

@ -210,6 +210,7 @@ local function playerStatusEventListener(socket)
break break
end end
printError("playerDetector not connected!") printError("playerDetector not connected!")
sleep(5)
end end
while true do while true do
local pd = peripheral.find("playerDetector") local pd = peripheral.find("playerDetector")

View File

@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<Version>1.1.3</Version> <Version>1.1.5</Version>
<Authors>Michael Chen</Authors> <Authors>Michael Chen</Authors>
<Company>$(Authors)</Company> <Company>$(Authors)</Company>
<RepositoryUrl>https://gitlab.com/chenmichael/mcdiscordbot</RepositoryUrl> <RepositoryUrl>https://gitlab.com/chenmichael/mcdiscordbot</RepositoryUrl>
@ -20,11 +20,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" /> <PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Discord.Net" Version="3.1.0" /> <PackageReference Include="Discord.Net" Version="3.8.1" />
<PackageReference Include="Fleck" Version="1.2.0" /> <PackageReference Include="Fleck" Version="1.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -50,7 +50,7 @@ public class Program : IDisposable, ICommandHandler<ResponseType>, IUserRoleMana
if (stream is null) throw new FileNotFoundException("Client script could not be loaded!"); if (stream is null) throw new FileNotFoundException("Client script could not be loaded!");
using var sr = new StreamReader(stream); using var sr = new StreamReader(stream);
return sr.ReadToEnd() return sr.ReadToEnd()
.Replace("$HOST", $"ws://{config.SocketHost}:{config.Port}"); .Replace("$HOST", config.Address);
} }
private Task Broadcast(Func<ITextChannel, Task<IUserMessage>> message) private Task Broadcast(Func<ITextChannel, Task<IUserMessage>> message)

View File

@ -2,11 +2,12 @@
import subprocess import subprocess
import argparse import argparse
from itertools import chain from itertools import chain
import re
dockercmd = 'docker' dockercmd = 'docker'
parser = argparse.ArgumentParser(description='Create custom recumock images.') parser = argparse.ArgumentParser(description='Create custom recumock images.')
parser.add_argument('tags', metavar='TAG', nargs='+', help='Version tags to build.') parser.add_argument('tags', metavar='TAG', nargs='*', help='Version tags to build.')
args = parser.parse_args() args = parser.parse_args()
@ -15,20 +16,31 @@ platforms = ['linux/amd64', 'linux/arm64', 'linux/arm/v7']
def pull(image): def pull(image):
subprocess.run([dockercmd, 'pull', baseimage], check=True) subprocess.run([dockercmd, 'pull', baseimage], check=True)
def build(image, directory, platforms, build_args = None): def build(images, directory, platforms, build_args = None):
if build_args is None: if build_args is None:
build_args = [] build_args = []
build_args = list(chain.from_iterable(['--build-arg', f'{arg}={val}'] for (arg, val) in build_args)) build_args = list(chain.from_iterable(['--build-arg', f'{arg}={val}'] for (arg, val) in build_args))
tags = list(chain.from_iterable(['-t', image] for image in images))
platformlist = ','.join(platforms) platformlist = ','.join(platforms)
subprocess.run([dockercmd, 'buildx', 'build', '-f', 'MinecraftDiscordBot/Dockerfile', '--platform', platformlist, '-t', image] + build_args + ['--push', directory], check=True) command = [dockercmd, 'buildx', 'build', '-f', 'MinecraftDiscordBot/Dockerfile', '--platform', platformlist, *tags] + build_args + ['--push', directory]
print(' '.join(command))
subprocess.run(command, check=True)
def version_from_project():
with open(r'MinecraftDiscordBot\MinecraftDiscordBot.csproj', 'r') as f:
project = f.read()
for tag in args.tags: regex = r"<Version>\s*([^<]*?)\s*<\/Version>"
targetimage = f'chenio/mcdiscordbot:{tag}' matches = re.search(regex, project, re.IGNORECASE)
baseimage = f'mcr.microsoft.com/dotnet/runtime:6.0' if not matches:
raise Exception("Could not read version from project file!")
return matches.group(1)
#print(f'Pulling base image {baseimage}') if len(args.tags) == 0:
#pull(baseimage) args.tags.append(version_from_project())
print(f'Building image {targetimage} from {baseimage}.')
build(targetimage, '.', platforms, [('TAG', tag)])
for version in args.tags:
parts = version.split('.')
tags = list('.'.join(parts[:i]) for i in range(1, len(parts) + 1))
tags.append('latest')
build([f'chenio/mcdiscordbot:{tag}' for tag in tags], '.', platforms)