diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3b9b8d6..ddf3005 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,31 +1,35 @@ -name: Publish - -on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 9.0.x - - - name: Restore - run: dotnet restore - - - name: Build - run: dotnet build -c Release --no-restore - - - name: Pack - run: dotnet pack -c Release -o ./nuget --no-build - - - name: Publish - run: dotnet nuget push ./nuget/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json +name: Publish + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+" + +jobs: + publish: + if: github.repository == 'rameel/ramstack.structures' + runs-on: ubuntu-latest + steps: + - name: Install .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 9.0.x + + - name: Checkout + uses: actions/checkout@v4 + + - name: Build + run: dotnet build -c Release + + - name: Create NuGet Packages + run: dotnet pack -c Release -o ./nuget --no-build + + - name: Publish NuGet Packages + run: dotnet nuget push ./nuget/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + draft: true + files: nuget/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8df697e..ecbf4c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Build & Test +name: Build & Test on: pull_request: @@ -6,28 +6,24 @@ on: jobs: build-and-test: - - name: build-and-test-${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] + name: "Test project" + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 2 + - name: Checkout + uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 9.0.x - - - name: Restore dependencies - run: dotnet restore + dotnet-version: | + 6.x + 7.x + 8.x + 9.x - - name: Build - run: dotnet build -c Release --no-restore + - name: Test (Debug) + run: dotnet test -c Debug - - name: Test - run: dotnet test --no-restore --verbosity normal + - name: Test (Release) + run: dotnet test -c Release diff --git a/Directory.Build.props b/Directory.Build.props index ed14ea7..bf61882 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - - - true - - + + + true + + diff --git a/Ramstack.Structures.sln b/Ramstack.Structures.sln index cb84108..c921cff 100644 --- a/Ramstack.Structures.sln +++ b/Ramstack.Structures.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 diff --git a/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs b/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs index 3041f0f..5da1490 100644 --- a/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs +++ b/Ramstack.Structures/Collections/ImmutableArrayExtensions.cs @@ -1,4 +1,4 @@ -using System.Collections.Immutable; +using System.Collections.Immutable; using System.Runtime.InteropServices; namespace Ramstack.Collections; diff --git a/Ramstack.Structures/Collections/ReadOnlyArray`1.cs b/Ramstack.Structures/Collections/ReadOnlyArray`1.cs index ccfa27c..5cf79e0 100644 --- a/Ramstack.Structures/Collections/ReadOnlyArray`1.cs +++ b/Ramstack.Structures/Collections/ReadOnlyArray`1.cs @@ -140,8 +140,8 @@ public Enumerator GetEnumerator() [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyArray Slice(int start) { - var array = Inner!; - _ = array.Length; + var array = Inner; + _ = array!.Length; return start != 0 ? new ReadOnlyArray(array.AsSpan(start)) @@ -159,8 +159,8 @@ public ReadOnlyArray Slice(int start) [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyArray Slice(int start, int length) { - var array = Inner!; - var count = array.Length; + var array = Inner; + var count = array!.Length; if (start == 0 && length == count) return this; @@ -266,8 +266,8 @@ public ref readonly T GetPinnableReference() => /// The span to copy items into. public void CopyTo(Span destination) { - var array = this; - _ = array.Length; + var array = Inner; + _ = array!.Length; array.AsSpan().CopyTo(destination); } @@ -282,8 +282,8 @@ public void CopyTo(Span destination) /// public bool TryCopyTo(Span destination) { - var array = this; - _ = array.Length; + var array = Inner; + _ = array!.Length; return array.AsSpan().TryCopyTo(destination); } diff --git a/Ramstack.Structures/Properties/AssemblyInfo.cs b/Ramstack.Structures/Properties/AssemblyInfo.cs index 8fc4963..63851e9 100644 --- a/Ramstack.Structures/Properties/AssemblyInfo.cs +++ b/Ramstack.Structures/Properties/AssemblyInfo.cs @@ -1,32 +1,32 @@ -// ReSharper disable UnusedMember.Global - -[module: System.Runtime.CompilerServices.SkipLocalsInit] - -#if !NET8_0_OR_GREATER - -// ReSharper disable once CheckNamespace -namespace System.Runtime.CompilerServices -{ - /// - /// The type of the builder to use to construct the collection. - /// The name of the method on the builder to use to construct the collection. - [AttributeUsage( - AttributeTargets.Class - | AttributeTargets.Struct - | AttributeTargets.Interface, - Inherited = false)] - internal sealed class CollectionBuilderAttribute(Type builderType, string methodName) : Attribute - { - /// - /// Gets the type of the builder to use to construct the collection. - /// - public Type BuilderType => builderType; - - /// - /// Gets the name of the method on the builder to use to construct the collection. - /// - public string MethodName => methodName; - } -} - -#endif +// ReSharper disable UnusedMember.Global + +[module: System.Runtime.CompilerServices.SkipLocalsInit] + +#if !NET8_0_OR_GREATER + +// ReSharper disable once CheckNamespace +namespace System.Runtime.CompilerServices +{ + /// + /// The type of the builder to use to construct the collection. + /// The name of the method on the builder to use to construct the collection. + [AttributeUsage( + AttributeTargets.Class + | AttributeTargets.Struct + | AttributeTargets.Interface, + Inherited = false)] + internal sealed class CollectionBuilderAttribute(Type builderType, string methodName) : Attribute + { + /// + /// Gets the type of the builder to use to construct the collection. + /// + public Type BuilderType => builderType; + + /// + /// Gets the name of the method on the builder to use to construct the collection. + /// + public string MethodName => methodName; + } +} + +#endif diff --git a/Ramstack.Structures/Ramstack.Structures.csproj b/Ramstack.Structures/Ramstack.Structures.csproj index 5b285dc..732bef6 100644 --- a/Ramstack.Structures/Ramstack.Structures.csproj +++ b/Ramstack.Structures/Ramstack.Structures.csproj @@ -53,7 +53,7 @@ Ramstack.Collections.ReadOnlyArray<T> - +