Skip to content

Commit

Permalink
Merge pull request #47 from Zastai/update-build-sdk
Browse files Browse the repository at this point in the history
Update the build SDK to version 3.1.0
  • Loading branch information
Zastai authored Dec 14, 2023
2 parents 1a4e90c + 884ec33 commit 9eec129
Show file tree
Hide file tree
Showing 23 changed files with 755 additions and 59 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ updates:
directory: "/"
schedule:
interval: "daily"
labels:
- "dependencies"
- "nuget"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- "dependencies"
- "gh-actions"
8 changes: 8 additions & 0 deletions .github/github-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
color: '008672'
description: "Changes related to unit tests"

# Additional Labels Used by Dependabot
- name: gh-actions
color: '1d0128'
description: "Version updates for GitHub actions"
- name: nuget
color: '1d0128'
description: "Version updates for NuGet packages"

# Additional Labels for Release Drafter Version Resolution
- name: bump-major-version
color: 'cf996b'
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build

on:
push:
branches:
- 'main'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- 'main'

jobs:
build:
runs-on: ubuntu-latest
env:
dotnet-version: 8.0.x
strategy:
matrix:
configuration: ['Debug', 'Release']

steps:
- name: Check out the project
uses: actions/checkout@v4
- name: Set up .NET ${{env.dotnet-version}}
uses: actions/setup-dotnet@v4
id: setup
with:
dotnet-version: ${{env.dotnet-version}}
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Create global.json to force use of .NET SDK ${{steps.setup.outputs.dotnet-version}}
run: echo '{"sdk":{"version":"${{steps.setup.outputs.dotnet-version}}"}}' > ./global.json
- name: Run build script (${{matrix.configuration}})
run: pwsh ./build-package.ps1 -ContinuousIntegration -WithBinLog -Configuration ${{matrix.configuration}}
- name: "Artifact: MSBuild Logs"
uses: actions/upload-artifact@v3
if: failure()
with:
name: MSBuild Logs (${{matrix.configuration}})
path: msbuild.*.binlog
- name: "Artifact: NuGet Packages"
uses: actions/upload-artifact@v3
with:
name: NuGet Packages (${{matrix.configuration}})
path: "output/package/${{matrix.configuration}}/*.*nupkg"
- name: Publish (NuGet - GitHub Packages)
if: matrix.configuration == 'Release' && startsWith(github.ref, 'refs/tags/v')
run: "dotnet nuget push output/package/${{matrix.configuration}}/*.nupkg -s https://nuget.pkg.github.com/zastai/index.json -k ${{secrets.GITHUB_TOKEN}}"
- name: Publish (NuGet - nuget.org)
if: matrix.configuration == 'Release' && startsWith(github.ref, 'refs/tags/v')
run: "dotnet nuget push output/package/${{matrix.configuration}}/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}}"
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5.15.0
- uses: release-drafter/release-drafter@v5.25.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/update-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run Labeler
if: success()
uses: crazy-max/ghaction-github-labeler@v3
uses: crazy-max/ghaction-github-labeler@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/github-labels.yml
Expand Down
7 changes: 3 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

<!-- Package Versions -->
<ItemGroup>
<PackageVersion Include="JetBrains.Annotations" Version="2023.2.0" />
<PackageVersion Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageVersion Include="MetaBrainz.Common" Version="1.0.0" />
<PackageVersion Include="MetaBrainz.Common.Json" Version="5.1.0" />
<PackageVersion Include="System.Drawing.Common" Version="6.0.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Text.Json" Version="6.0.0" />
<PackageVersion Include="System.Drawing.Common" Version="6.0.0" Condition=" '$(TargetFramework)' == 'net6.0' " />
<PackageVersion Include="System.Drawing.Common" Version="8.0.0" Condition=" '$(TargetFramework)' == 'net8.0' " />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2021 Tim Van Holder
Copyright (c) 2016-2023 Tim Van Holder

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions MetaBrainz.MusicBrainz.CoverArt.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Support Files", "Support Fi
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
appveyor.yml = appveyor.yml
build-package.ps1 = build-package.ps1
Directory.Packages.props = Directory.Packages.props
global.json = global.json
LICENSE.md = LICENSE.md
package-icon.png = package-icon.png
README.md = README.md
Expand All @@ -26,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub", "GitHub", "{5E6BB8
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Actions", "Actions", "{47A089B9-B7FA-435A-8771-9AD4BE1D1D5C}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build.yml = .github\workflows\build.yml
.github\workflows\release-drafter.yml = .github\workflows\release-drafter.yml
.github\workflows\update-labels.yml = .github\workflows\update-labels.yml
EndProjectSection
Expand Down
13 changes: 1 addition & 12 deletions MetaBrainz.MusicBrainz.CoverArt/CoverArt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,8 @@ private async Task<CoverArtImage> FetchImageAsync(string entity, Guid mbid, stri
if (contentLength > CoverArt.MaxImageSize) {
throw new ArgumentException($"The requested image is too large ({contentLength} > {CoverArt.MaxImageSize}).");
}
#if NET
var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
await using var _ = stream.ConfigureAwait(false);
#elif NETSTANDARD2_1_OR_GREATER
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
await using var _ = stream.ConfigureAwait(false);
#else
using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
#endif
if (stream == null) {
throw new WebException("No data received.", WebExceptionStatus.ReceiveFailure);
}
Expand All @@ -719,14 +712,10 @@ private async Task<CoverArtImage> FetchImageAsync(string entity, Guid mbid, stri
await stream.CopyToAsync(data, 64 * 1024, cancellationToken).ConfigureAwait(false);
}
catch {
#if NET || NETSTANDARD2_1_OR_GREATER
await data.DisposeAsync().ConfigureAwait(false);
#else
data.Dispose();
#endif
throw;
}
return new CoverArtImage(id, size, response.Content?.Headers?.ContentType?.MediaType, data);
return new CoverArtImage(id, size, response.Content.Headers.ContentType?.MediaType, data);
}

private async Task<IRelease> FetchReleaseAsync(string entity, Guid mbid, CancellationToken cancellationToken) {
Expand Down
2 changes: 0 additions & 2 deletions MetaBrainz.MusicBrainz.CoverArt/CoverArtImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ internal CoverArtImage(string id, CoverArtImageSize size, string? type, Stream d
/// When the image data is not valid (or not supported by the <see cref="System.Drawing.Image"/> class).
/// </exception>
/// <exception cref="PlatformNotSupportedException">When not running on Windows.</exception>
#if NET
[SupportedOSPlatform("windows")]
#endif
public Image Decode(bool useEmbeddedColorManagement = false, bool validateImageData = false)
=> Image.FromStream(this.Data, useEmbeddedColorManagement, validateImageData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace MetaBrainz.MusicBrainz.CoverArt.Json.Readers;

internal sealed class ImageReader : ObjectReader<Image> {

public static readonly ImageReader Instance = new ImageReader();
public static readonly ImageReader Instance = new();

protected override Image ReadObjectContents(ref Utf8JsonReader reader, JsonSerializerOptions options) {
var approved = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace MetaBrainz.MusicBrainz.CoverArt.Json.Readers;

internal sealed class ReleaseReader : ObjectReader<Release> {

public static readonly ReleaseReader Instance = new ReleaseReader();
public static readonly ReleaseReader Instance = new();

protected override Release ReadObjectContents(ref Utf8JsonReader reader, JsonSerializerOptions options) {
IReadOnlyList<IImage>? images = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace MetaBrainz.MusicBrainz.CoverArt.Json.Readers;

internal sealed class ThumbnailsReader : ObjectReader<Thumbnails> {

public static readonly ThumbnailsReader Instance = new ThumbnailsReader();
public static readonly ThumbnailsReader Instance = new();

protected override Thumbnails ReadObjectContents(ref Utf8JsonReader reader, JsonSerializerOptions options) {
Uri? small = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="MetaBrainz.Build.Sdk">
<Project>

<Sdk Name="MetaBrainz.Build.Sdk" Version="3.1.0" />

<PropertyGroup>
<Authors>Zastai</Authors>
<Title>CoverArt Archive Web Service Client Library</Title>
<Description>
This package provides classes for accessing the CoverArt Archive (CAA), enabling the retrieval of cover art for music releases
based on their MusicBrainz ID.
</Description>
<PackageCopyrightOwners>Tim Van Holder</PackageCopyrightOwners>
<PackageCopyrightYears>2016-2023</PackageCopyrightYears>
<PackageRepositoryName>MetaBrainz.MusicBrainz.CoverArt</PackageRepositoryName>
<PackageTags>MusicBrainz album cover art archive CAA libcoverart</PackageTags>
<Version>5.1.1-pre</Version>
<Version>6.0.0-pre</Version>
</PropertyGroup>

<PropertyGroup>
<AssemblyIsComVisible>false</AssemblyIsComVisible>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" IncludeAssets="compile" PrivateAssets="all" />
<PackageReference Include="MetaBrainz.Common" />
<PackageReference Include="MetaBrainz.Common.Json" />
<PackageReference Include="System.Drawing.Common" />
<PackageReference Include="System.Net.Http" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

</Project>
12 changes: 6 additions & 6 deletions MetaBrainz.MusicBrainz.CoverArt/Objects/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ public Image(int edit, string id, IThumbnails thumbnails, CoverArtType types) {
this.Types = types;
}

public bool Approved { get; set; }
public bool Approved { get; init; }

public bool Back { get; set; }
public bool Back { get; init; }

public string? Comment { get; set; }
public string? Comment { get; init; }

public int Edit { get; }

public bool Front { get; set; }
public bool Front { get; init; }

public string Id { get; }

public Uri? Location { get; set; }
public Uri? Location { get; init; }

public IThumbnails Thumbnails { get; }

public CoverArtType Types { get; }

public IReadOnlyList<string>? UnknownTypes { get; set; }
public IReadOnlyList<string>? UnknownTypes { get; init; }

}
10 changes: 5 additions & 5 deletions MetaBrainz.MusicBrainz.CoverArt/Objects/Thumbnails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ namespace MetaBrainz.MusicBrainz.CoverArt.Objects;

internal sealed class Thumbnails : JsonBasedObject, IThumbnails {

public Uri? Small { get; set; }
public Uri? Small { get; init; }

public Uri? Large { get; set; }
public Uri? Large { get; init; }

public Uri? Size250 { get; set; }
public Uri? Size250 { get; init; }

public Uri? Size500 { get; set; }
public Uri? Size500 { get; init; }

public Uri? Size1200 { get; set; }
public Uri? Size1200 { get; init; }

}
3 changes: 0 additions & 3 deletions MetaBrainz.MusicBrainz.CoverArt/Properties/AssemblyInfo.cs

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This is a .NET implementation of the libcoverart library (wrapping the
[CoverArtArchive API][api-reference]).
An attempt has been made to keep the same basic class hierarchy.

[CI-S]: https://img.shields.io/appveyor/build/zastai/metabrainz-musicbrainz-coverart
[CI-L]: https://ci.appveyor.com/project/Zastai/metabrainz-musicbrainz-coverart
[CI-S]: https://github.com/Zastai/MetaBrainz.MusicBrainz.CoverArt/actions/workflows/build.yml/badge.svg
[CI-L]: https://github.com/Zastai/MetaBrainz.MusicBrainz.CoverArt/actions/workflows/build.yml
[NuGet-S]: https://img.shields.io/nuget/v/MetaBrainz.MusicBrainz.CoverArt
[NuGet-L]: https://www.nuget.org/packages/MetaBrainz.MusicBrainz.CoverArt

Expand Down
6 changes: 0 additions & 6 deletions appveyor.yml

This file was deleted.

11 changes: 10 additions & 1 deletion build-package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[CmdletBinding()]
param (
[string] $Configuration = 'Release',
[switch] $ContinuousIntegration = $false,
[switch] $WithBinLog = $false
)

Expand Down Expand Up @@ -41,7 +42,15 @@ if ($LASTEXITCODE -ne 0) {
}

Write-Host "Building the solution (Configuration: $Configuration)..."
dotnet build $opts --no-restore "-c:$Configuration" '-p:ContinuousIntegrationBuild=true' '-p:Deterministic=true'
$props = @()
if ($ContinuousIntegration) {
$props += '-p:ContinuousIntegrationBuild=true'
$props += '-p:Deterministic=true'
}
if ($Configuration -eq 'Debug') {
$props += '-p:DebugMessageImportance=high'
}
dotnet build $opts --no-restore "-c:$Configuration" $props
Complete-BuildStep 'build'
if ($LASTEXITCODE -ne 0) {
Write-Error "SOLUTION BUILD FAILED"
Expand Down
5 changes: 0 additions & 5 deletions global.json

This file was deleted.

Loading

0 comments on commit 9eec129

Please sign in to comment.