Skip to content

Commit

Permalink
Publish Workflow (#6)
Browse files Browse the repository at this point in the history
* added publish workflow
* added ToString override for result object
  • Loading branch information
skrasekmichael authored Mar 16, 2024
1 parent 35f26a6 commit 10e09e7
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
run: dotnet build ${{ env.SOLUTION }} -c Release --no-restore

- name: Test
run: dotnet test ${{env.SOLUTION }} -c Release --no-build --verbosity minimal
run: dotnet test ${{ env.SOLUTION }} -c Release --no-build --verbosity minimal
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish

on:
push:
tags:
- "*.*.*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set VERSION variable from tag
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x

- name: Build
run: dotnet build ${{ env.SOLUTION }} -c Release

- name: Test
run: dotnet test ${{ env.SOLUTION }} -c Release --no-build --verbosity minimal

- name: Pack
run: dotnet pack -c Release --no-build --output nuget

- name: Publish NuGet packages
run: |
foreach ($file in (Get-ChildItem nuget -Include *.nupkg)) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}
2 changes: 1 addition & 1 deletion src/RailwayResult/RailwayResult.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Title>Railway Result</Title>
<Version>1.0.0-alpha</Version>
<Version>1.0.0-alpha-2</Version>
<PackageId>Skrasek.RailwayResult</PackageId>
<Description>Simple extensible result pattern for .NET</Description>
<PackageTags>result;railway-result;result-pattern;c#</PackageTags>
Expand Down
9 changes: 9 additions & 0 deletions src/RailwayResult/Result.Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ public TOut Match<TOut>(Func<TValue, TOut> successMap, Func<Error, TOut> failure
return IsSuccess ? successMap(_value!) : failureMap(_error!);
}

public override string ToString()
{
return IsSuccess switch
{
true => "Result SUCCESS" + _value!.ToString(),
false => "Result FAILURE " + _error!.ToString()
};
}

public static Result<TValue> Success(TValue value) => new(value);

public static implicit operator Result<TValue>(TValue? value) => new(value);
Expand Down
9 changes: 9 additions & 0 deletions src/RailwayResult/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ private Result()
_error = null;
}

public override string ToString()
{
return IsSuccess switch
{
true => "Result SUCCESS",
false => "Result FAILURE " + _error!.ToString()
};
}

public static readonly Result Success = new();

public static implicit operator Result(Error error) => new(error);
Expand Down

0 comments on commit 10e09e7

Please sign in to comment.