Skip to content

Commit

Permalink
Merge pull request #57 from Jack-Edwards/update
Browse files Browse the repository at this point in the history
Update dependencies and add .NET 9.0 as target
  • Loading branch information
Jack-Edwards authored Dec 21, 2024
2 parents 463fe88 + 849e848 commit ca8a42a
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 18 deletions.
12 changes: 8 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@

version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "weekly"

interval: "monthly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
51 changes: 51 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: publish
on:
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
release:
types:
- published # Run the workflow when a new GitHub release is published

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace }}/nuget

defaults:
run:
shell: pwsh

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer

- name: Install pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d #v3
with:
version: 9

- name: Setup .NET
uses: actions/setup-dotnet@e4c228a8417679d13c6a1e7131e3e8d82dff4cd3 #v4
with:
dotnet-version: 9.0.x

- name: Install wasm-tools
run: dotnet workload install wasm-tools

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore

- name: Pack
run: dotnet pack -c Release --no-build --output ${{ env.NuGetDirectory }}

- name: Push nupkg
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.nupkg --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate

- name: Push snupkg
run: dotnet nuget push ${{ env.NuGetDirectory }}/*.snupkg --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
5 changes: 3 additions & 2 deletions BlazorSodium.Demo/BlazorSodium.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.11" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Sdk.WebAssembly.Pack" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
36 changes: 30 additions & 6 deletions BlazorSodium/BlazorSodium.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
<Title>BlazorSodium</Title>
<Authors>Jack Edwards</Authors>
<Description>Simple wrapper over libsodium.js to use in Blazor WASM projects</Description>
Expand All @@ -16,17 +16,29 @@
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>1.3.2</Version>
<PackageVersion>1.3.2</PackageVersion>
<LangVersion>12</LangVersion>
<DisableBuildCompression>true</DisableBuildCompression>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<NoWarn>1701;1702;NU5105;CS1591;NU5105;NU5105;CS1584</NoWarn>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<NoWarn>1701;1702;NU5105;CS1591;NU5105;NU5105;CS1584</NoWarn>
</PropertyGroup>

<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" Condition="'$(TargetFramework)' == 'net9.0'" />
<PackageReference Include="MinVer" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand All @@ -35,9 +47,21 @@
</None>
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Target Name="PreBuild" BeforeTargets="DispatchToInnerBuilds">
<Exec Command="pnpm install" />
<Exec Command="pnpm run build" />
</Target>

<Target Name="AfterClean" AfterTargets="Clean">
<Delete Files="wwwroot\blazorSodium.bundle.js" ContinueOnError="true" />
<Delete Files="wwwroot\blazorSodium.bundle.js.gz" ContinueOnError="true" />
<Delete Files="wwwroot\blazorSodium.bundle.js.br" ContinueOnError="true" />
</Target>

<PropertyGroup Label="MinVer">
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
<MinVerDefaultPreReleaseIdentifiers>preview.0</MinVerDefaultPreReleaseIdentifiers>
<MinVerTagPrefix>v</MinVerTagPrefix>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion BlazorSodium/Sodium/GenericHash.Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static partial class GenericHash
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_generichash_init.json"/>
[JSImport("sodium.crypto_generichash_init", "blazorSodium")]
internal static partial int Crypto_GenericHash_Init_Interop(byte[] key, [JSMarshalAs<JSType.Number>] long hashLength);
internal static partial int Crypto_GenericHash_Init_Interop(byte[]? key, [JSMarshalAs<JSType.Number>] long hashLength);

/// <summary>
/// Internal method.
Expand Down
2 changes: 1 addition & 1 deletion BlazorSodium/Sodium/PublicKeySignature.Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static partial class PublicKeySignature
/// <returns></returns>
/// <see cref="https://github.com/jedisct1/libsodium.js/blob/master/wrapper/symbols/crypto_sign_init.json"/>
/// <remarks>
/// Switching the return type to 'long' and applying a [return: JSMarshalAs<JSType.Number>]
/// Switching the return type to 'long' and applying a [return: JSMarshalAs&lt;JSType.Number&gt;]
/// attribute does not work any better than simply returning an 'int'.
///
/// A 'System.Runtime.InteropServices.JavaScript.JSException' exception is thrown when
Expand Down
8 changes: 4 additions & 4 deletions BlazorSodium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"devDependencies": {
"path": "^0.12.7",
"vite": "^4.4.9",
"vite-plugin-compression2": "^0.10.3"
"vite": "^6.0.5",
"vite-plugin-compression2": "^1.3.3"
},
"dependencies": {
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"libsodium-wrappers-sumo": "^0.7.11",
"crypto-browserify": "^3.12.1",
"libsodium-wrappers-sumo": "^0.7.15",
"stream-browserify": "^3.0.0"
}
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ Now use the static wrapper methods from anywhere in your application.

When a Sodium methods returns `byte[]` data, you often need to use `Array.CopyTo(Array array, int index)` to copy the data to an initialized array if you intend to use the data outside of the current scope.
Otherwise the `byte[]` may be garbage collected and your variable will be `null`.

## Useful developer documentation

[Supported JSInterop types](https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/import-export-interop)

0 comments on commit ca8a42a

Please sign in to comment.