Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
garyng committed Nov 14, 2020
2 parents b8bcba6 + 2cf9ef7 commit 3ae45be
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 62 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Docker Image Build and Publish
on: push

jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.5
with:
versionSpec: "5.x"

- name: Versioning
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.5


- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./src/
file: ./src/Tss.Api/Dockerfile
push: true
tags: garyng/tss:latest, garyng/tss:${{ steps.gitversion.outputs.fullSemVer }}

- name: Release Github
uses: softprops/action-gh-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
name: ${{ steps.gitversion.outputs.fullSemVer }}
tag_name: ${{ steps.gitversion.outputs.fullSemVer }}
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Tss

[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/garyng/tss)](https://hub.docker.com/r/garyng/tss)
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/garyng/tss/latest)

> This Song S**ks
A dumb playlist management tool.

# (My) workflow
# (My) Workflow

1. Gather a bunch of tracks into a Spotify playlist, normally called `xxx (pending)`
1. Create two more playlists:
Expand Down
6 changes: 2 additions & 4 deletions src/Tss.Api/Controllers/TssController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Tss.Core;
Expand Down Expand Up @@ -41,7 +39,7 @@ public async Task<ActionResult<string>> Callback([FromQuery] string? code, [From
return Unauthorized($"Error: {error}");
}

await _service.CompleteLogin(code);
await _service.CompleteLogin(code!);
return Ok("Spotify Authorization was successful. You can close this tab now.");
}

Expand Down
14 changes: 14 additions & 0 deletions src/Tss.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Serilog;
using Tss.Core;

namespace Tss.Api
Expand All @@ -31,6 +32,19 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
}

})
.ConfigureLogging((context, builder) =>
{
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Console(
outputTemplate:
"{Level:u3}: [{Timestamp:HH:mm:ss}] {SourceContext} {Scope:lj} {NewLine} {Message:lj}{NewLine}{Exception}{NewLine}")
.ReadFrom.Configuration(context.Configuration)
.CreateLogger();

builder.ClearProviders()
.AddSerilog();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
Expand Down
8 changes: 4 additions & 4 deletions src/Tss.Api/Tss.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitVersionTask" Version="5.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.0" NoWarn="NU1605" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="2.0.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>

Expand Down
8 changes: 1 addition & 7 deletions src/Tss.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}

}
18 changes: 10 additions & 8 deletions src/Tss.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
},
"AllowedHosts": "*"
}
26 changes: 16 additions & 10 deletions src/Tss.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Tss.Core;
using Serilog;

namespace Tss.Cli
{
Expand All @@ -23,6 +25,19 @@ static async Task Main(string[] args)
config.AddYamlFile(tssConfig.MappingsPath, optional: false, reloadOnChange: true);
}
})
.ConfigureLogging((context, builder) =>
{
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Console(
outputTemplate:
"{Level:u3}: [{Timestamp:HH:mm:ss}] {SourceContext} {Scope:lj} {NewLine} {Message:lj}{NewLine}{Exception}{NewLine}")
.ReadFrom.Configuration(context.Configuration)
.CreateLogger();

builder.ClearProviders()
.AddSerilog();
})
.ConfigureServices((context, services) =>
{
var tssConfig = context.Configuration.GetSection(nameof(TssConfig));
Expand All @@ -45,15 +60,6 @@ static async Task Main(string[] args)
public class Startup
{
private readonly StandaloneTssService _service;
//private readonly IOptions<TssConfig> _config;
//private readonly IOptionsMonitor<TssPlaylistMapping> _mappings;

//public Startup(IOptions<TssConfig> config, IOptionsMonitor<TssPlaylistMapping> mappings)
//{
// _config = config;
// _mappings = mappings;
// //_service = service;
//}

public Startup(StandaloneTssService service)
{
Expand All @@ -63,7 +69,7 @@ public Startup(StandaloneTssService service)
public async Task Run()
{
await _service.Login();
// await _service.MoveCurrentToGood();
await _service.MoveCurrentToGood();
// await _service.MoveCurrentToNotGood();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Tss.Cli/Tss.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GitVersionTask" Version="5.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="2.0.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tss.Core\Tss.Core.csproj" />
Expand Down
20 changes: 14 additions & 6 deletions src/Tss.Cli/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
},
"TssConfig": {
"ClientId": "<replace>",
"CredentialsPath": "./credentials.json",
"MappingsPath": "mappings.yml",
"CallbackPort": 8124
}
}
}
9 changes: 4 additions & 5 deletions src/Tss.Core/StandaloneTssService.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using SpotifyAPI.Web.Auth;

namespace Tss.Core
{
public class StandaloneTssService : TssService
{
protected const int CALLBACK_PORT = 8123;

public StandaloneTssService(IOptions<TssConfig> config, IOptionsMonitor<TssMappings> mappings) :
base(config, mappings)
public StandaloneTssService(IOptions<TssConfig> config, IOptionsMonitor<TssMappings> mappings,
ILogger<TssService> logger) : base(config, mappings, logger)
{
}

Expand All @@ -19,7 +18,7 @@ public StandaloneTssService(IOptions<TssConfig> config, IOptionsMonitor<TssMappi
/// </summary>
public async Task Login()
{
var server = new EmbedIOAuthServer(new Uri(CALLBACK_URL), CALLBACK_PORT);
var server = new EmbedIOAuthServer(new Uri(_callbackUrl), _callbackPort);
await server.Start();

var auth = new TaskCompletionSource();
Expand Down
5 changes: 1 addition & 4 deletions src/Tss.Core/Tss.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitVersionTask" Version="5.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
<PackageReference Include="SpotifyAPI.Web" Version="6.0.0-beta.12" />
<PackageReference Include="SpotifyAPI.Web.Auth" Version="6.0.0-beta.12" />
Expand Down
1 change: 1 addition & 0 deletions src/Tss.Core/TssConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public class TssConfig
public string ClientId { get; set; }
public string CredentialsPath { get; set; }
public string MappingsPath { get; set; }
public int CallbackPort { get; set; } = 8123;
}
}
Loading

0 comments on commit 3ae45be

Please sign in to comment.