Skip to content

Commit

Permalink
Github Action fixes
Browse files Browse the repository at this point in the history
Fix nuget deployment
Add .NET 4.7.2 example
Fix package output path to reduce filesize.
Use semantic-version
Get rid of .NET 3.1 on build (for now?)
Remove `GeneratePackageOnBuild`: dotnet/sdk#10335
Move test to it's own step
Use GitHubActionsTestLogger for tests
Force win target for PictSharp.drawing

Try combining actions

Add .net core needed for .net standard?

Fix project path

Fix msbuild

Another fix of actions

Remove msbuild path from windows build

Add BuildNetCore option to prevent net472 tests running

Fix readme and try fix dotnet test under linux

Add Manual Build process

Fix all warnings, and add XML comments

MsBuild package fixes

Fix up license to MIT
  • Loading branch information
pgodwin committed Jan 5, 2022
1 parent b4fd1c4 commit 4c9d9a2
Show file tree
Hide file tree
Showing 28 changed files with 441 additions and 169 deletions.
130 changes: 124 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,88 @@
name: build
on: [push, pull_request]
jobs:
build:
core-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET Core SDK 6.0
uses: actions/[email protected]
with:
dotnet-version: 6.0.x
- uses: paulhatch/[email protected]
id: semantic_version
with:
tag_prefix: "v"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: dotnet restore
- name: Build Core
run: dotnet build --configuration Release --no-restore PictSharp.Core -o ./bin
- name: Build ImageSharp
run: dotnet build --configuration Release --no-restore PictSharp.ImageSharpAdaptor -o ./bin /p:Version=${{ steps.semantic_version.outputs.VERSION }}
- name: Pack Core
run: dotnet pack --configuration Release --no-restore PictSharp.Core -o ./nupkgs /p:Version=${{ steps.semantic_version.outputs.VERSION }}
- name: Pack ImageSharpAdaptor
run: dotnet pack --configuration Release --no-restore PictSharp.ImageSharpAdaptor -o ./nupkgs /p:Version=${{ steps.semantic_version.outputs.VERSION }}
- name: Upload Compiled Binaries
uses: actions/upload-artifact@v2
with:
name: dotnetcore-bin
path: bin/
- name: Upload PictSharp.Core Package
uses: actions/upload-artifact@v2
with:
name: PictSharp.Core.nupkg
path: nupkgs/PictSharp.Core.*
- name: Upload PictSharp.ImageSharpAdaptor Package
uses: actions/upload-artifact@v2
with:
name: PictSharp.ImageSharpAdaptor.nupkg
path: nupkgs/PictSharp.ImageSharpAdaptor.*
windows-build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- uses: paulhatch/[email protected]
id: semantic_version
with:
tag_prefix: "v"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET Core SDK 6.0
uses: actions/[email protected]
with:
dotnet-version: 6.0.x
- name: Restore NuGet Packages
run: nuget restore PictSharp.sln
- name: Build PictSharp.Drawing
run: msbuild .\PictSharp.Drawing\PictSharp.Drawing.csproj /p:Configuration=Release /p:OutputPath=..\bin
- name: Package
run: msbuild -t:pack /p:Configuration=Release /p:PackageOutputPath=..\nupkgs .\PictSharp.Drawing\PictSharp.Drawing.csproj /p:Version=${{ steps.semantic_version.outputs.VERSION }}
- name: Upload Compiled
uses: actions/upload-artifact@v2
with:
name: dotnet-4-7-2-bin
path: bin\*
- name: Upload Packages
uses: actions/upload-artifact@v2
with:
name: PictSharp.Drawing.nupkg
path: .\nupkgs\*
test:
needs: [core-build, windows-build]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Setup .NET Core SDK 3.1
uses: actions/[email protected]
with:
Expand All @@ -15,9 +93,49 @@ jobs:
dotnet-version: 6.0.x
- name: Install dependencies
run: dotnet restore
- name: Build Core
run: dotnet build --configuration Release --no-restore PictSharp.Core
- name: Build ImageSharp
run: dotnet build --configuration Release --no-restore PictSharp.ImageSharpAdaptor
- name: Test
run: dotnet test --no-restore --verbosity normal PictSharp.Tests
run: dotnet test PictSharp.Tests --no-restore --logger GitHubActions
publish:
needs: [test]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Verify commit exists in origin/master
run: git branch --remote --contains | grep origin/master
- name: Set VERSION variable from tag
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Download PictSharp.Core.nupkg
uses: actions/download-artifact@v2
with:
name: 'PictSharp.Core.nupkg'
path: ./nupkgs
- name: Download PictSharp.ImageSharpAdaptor.nupkg Package
uses: actions/download-artifact@v2
with:
name: 'PictSharp.ImageSharpAdaptor.nupkg'
path: ./nupkgs
- name: Download PictSharp.Drawing.nupkg
uses: actions/download-artifact@v2
with:
name: 'PictSharp.Drawing.nupkg'
path: ./nupkgs
- name: Setup .NET Core SDK 6.0
uses: actions/[email protected]
with:
dotnet-version: 6.0.x
- name: Push to Github Repository
run: dotnet nuget push ./nupkgs/*.nupkg --source https://nuget.pkg.github.com/pgodwin/index.json --api-key ${GITHUB_TOKEN} --skip-duplicate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish the package to nuget.org
run: dotnet nuget push ./nupkgs/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json --skip-duplicate
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}



6 changes: 6 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildNetCoreOnly>false</BuildNetCoreOnly>
</PropertyGroup>
</Project>
44 changes: 19 additions & 25 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
BSD 3-Clause License
The MIT License (MIT)

Copyright (c) 2017, Peter Godiwn
All rights reserved.
Copyright (c) 2017-2021 Peter Godwin
Copyright (c) 2018-2021 yigolden

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions PictSharp.Core/ColorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace PictSharp
{
/// <summary>
/// Eventual color model support
/// </summary>
public class ColorModel
{
}
Expand Down
3 changes: 3 additions & 0 deletions PictSharp.Core/ComponentColorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace PictSharp
{
/// <summary>
/// For the eventual colour model support
/// </summary>
public class ComponentColorModel : ColorModel
{
}
Expand Down
18 changes: 17 additions & 1 deletion PictSharp.Core/Extensions/ArrayExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,33 @@

namespace PictSharp.Extensions
{
/// <summary>
/// Contains extensions for array types (mostly byte[])
/// </summary>
public static class ArrayExtensions
{
/// <summary>
/// Returns a new array from a slice out of the current array that begins at a specified index..
/// </summary>
/// <param name="source">Source array</param>
/// <param name="start">The index at which to begin the slice.</param>
/// <returns>A new array containing the just the items in the slice.</returns>
public static byte[] Slice(this byte[] source, int start)
{
var arrayLength = source.Length;
var length = arrayLength - start;
byte[] dest = new byte[length];
Array.Copy(source, start, dest, 0, length);
return dest;
return dest;
}

/// <summary>
/// Retunrs a new array of the specified array starting at a specified index for a specified length.
/// </summary>
/// <param name="source">Source array</param>
/// <param name="start">The index at which to begin the slice.</param>
/// <param name="length">The desired length for the slice.</param>
/// <returns>A new byte[] array with a copy of the items in the range</returns>
public static byte[] Slice(this byte[] source, int start, int length)
{
byte[] dest = new byte[length];
Expand Down
12 changes: 12 additions & 0 deletions PictSharp.Core/Extensions/MemoryStreamExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@

namespace PictSharp.Extensions
{
/// <summary>
/// MemoryStream extension
/// </summary>
public static class MemoryStreamExtensions
{
/// <summary>
/// Sets the length of the memory stream back to 0, effectively erasing it.
/// </summary>
/// <param name="stream"></param>
public static void Clear(this MemoryStream stream)
{
stream.SetLength(0);
}

/// <summary>
/// Returns the remaining bytes in the array, assuming length and position are set correctly
/// </summary>
/// <param name="stream"></param>
/// <returns></returns>
public static long Remaining(this MemoryStream stream)
{
return stream.Length - stream.Position;
Expand Down
23 changes: 23 additions & 0 deletions PictSharp.Core/Extensions/StreamWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,48 @@

namespace PictSharp.Extensions
{
/// <summary>
/// Contains extensions for BeBinaryWriter
/// </summary>
public static class StreamExtensions
{


/// <summary>
/// Writes an Int16 to the stream
/// </summary>
/// <param name="writer"></param>
/// <param name="value"></param>
public static void WriteShort(this BeBinaryWriter writer, object value)
{
writer.Write(Convert.ToInt16(value));
}

/// <summary>
/// Writes an unsigned Int16 to the stream
/// </summary>
/// <param name="writer"></param>
/// <param name="value"></param>
public static void WriteUShort(this BeBinaryWriter writer, object value)
{
writer.Write(Convert.ToUInt16(value));
}

/// <summary>
/// Writes a signed int32 to the stream
/// </summary>
/// <param name="writer"></param>
/// <param name="value"></param>
public static void WriteInt(this BeBinaryWriter writer, object value)
{
writer.Write(Convert.ToInt32(value));
}

/// <summary>
/// Writes an unsigned int32 to the stream
/// </summary>
/// <param name="writer"></param>
/// <param name="value"></param>
public static void WriteUInt(this BeBinaryWriter writer, object value)
{
writer.Write(Convert.ToUInt32(value));
Expand Down
14 changes: 14 additions & 0 deletions PictSharp.Core/IEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,24 @@

namespace PictSharp
{
/// <summary>
/// PICT Encoder interface
/// </summary>
public interface IEncoder
{
/// <summary>
/// Saves the Bitmap as a PICT image
/// </summary>
/// <param name="image">Source Image Details</param>
/// <param name="output">Output stream to write to</param>
void Encode(Stream output, ImageDetails image);

/// <summary>
/// Encodes the image to the specified output
/// </summary>
/// <param name="output">Stream to output the image to</param>
/// <param name="image">Source image details</param>
/// <param name="cancellationToken">Cancellation token for async operations</param>
void Encode(Stream output, ImageDetails image, CancellationToken cancellationToken);
}
}
Loading

0 comments on commit 4c9d9a2

Please sign in to comment.