Skip to content

Commit 805c64f

Browse files
authored
Merge pull request #155 from Astn/nuget-trusted-publishing
Trusted Publishing on nuget.org; publish 2.0 as 2.0.0-preview.1
2 parents 1ec9694 + 9a821e4 commit 805c64f

31 files changed

Lines changed: 304 additions & 877 deletions

‎.github/workflows/build_publish_master.yml‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ on:
55
- "**/*.md"
66
branches: [ master ]
77

8+
# Publishing uses nuget.org Trusted Publishing: the job requests an OIDC token from GitHub, NuGet/login exchanges
9+
# it for an API key that lives one hour, and the push uses that key. No long-lived NuGet secret is stored here.
10+
# The nuget.org policy is bound to this repository and to this file's name (build_publish_master.yml); renaming
11+
# the file or moving the push to another workflow needs a new policy on nuget.org.
12+
permissions:
13+
id-token: write
14+
contents: read
15+
816
jobs:
917
build:
1018

@@ -24,13 +32,22 @@ jobs:
2432
run: dotnet restore AustinHarris.JsonRpc.sln
2533
# Building the solution packs every package project (GeneratePackageOnBuild); `dotnet pack` on the
2634
# solution would trip NU5026 with GeneratePackageOnBuild, so the packages come from the build.
35+
# ContinuousIntegrationBuild makes the build deterministic and lets Source Link map the symbols package
36+
# (.snupkg, pushed alongside each .nupkg) back to this commit on GitHub.
2737
- name: Build
28-
run: dotnet build AustinHarris.JsonRpc.sln --configuration Release --no-restore
38+
run: dotnet build AustinHarris.JsonRpc.sln --configuration Release --no-restore -p:ContinuousIntegrationBuild=true
2939
- name: Test
3040
run: dotnet test AustinHarris.JsonRpcTestN --configuration Release --no-build
41+
# The key is requested after the tests so it is fresh for the push (it expires after one hour). `user` is the
42+
# nuget.org profile that owns the packages and the trusted publishing policy.
43+
- name: NuGet login (OIDC to a temporary API key)
44+
uses: NuGet/login@v1
45+
id: nuget-login
46+
with:
47+
user: AustinHarris
3148
# Publish all four packages: the core and the three companions (Json.NET, System.Text.Json, ASP.NET Core).
3249
- name: publish nuget version change
3350
run: |
3451
for project in Json-Rpc AustinHarris.JsonRpc.Newtonsoft AustinHarris.JsonRpc.SystemTextJson AustinHarris.JsonRpc.AspNetCore; do
35-
dotnet nuget push "$project/bin/Release/"*.nupkg --skip-duplicate --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NugetKey }} # API key for the NuGet feed
52+
dotnet nuget push "$project/bin/Release/"*.nupkg --skip-duplicate --source "https://api.nuget.org/v3/index.json" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}"
3653
done

‎.github/workflows/build_pull_request.yml‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,8 @@ jobs:
2929
# Building the solution packs every package project (GeneratePackageOnBuild); `dotnet pack` on the
3030
# solution would trip NU5026 with GeneratePackageOnBuild, so the packages come from the build.
3131
- name: Build
32-
run: dotnet build AustinHarris.JsonRpc.sln --configuration Release --no-restore --version-suffix ci-${{ github.run_id }}-${{ github.run_number }}
32+
run: dotnet build AustinHarris.JsonRpc.sln --configuration Release --no-restore
3333
- name: Test
3434
run: dotnet test AustinHarris.JsonRpcTestN --configuration Release --no-build
35-
# Publish all four pre-release packages: the core and the three companions (Json.NET, System.Text.Json, ASP.NET Core).
36-
# Non-fatal: the build and tests are the pull-request verdict; a rejected key (403) or a fork's missing secret
37-
# shows as a warning here and fails loudly in the master workflow instead.
38-
- name: publish nuget version change
39-
if: ${{ matrix.os == 'ubuntu-latest' }}
40-
continue-on-error: true
41-
run: |
42-
for project in Json-Rpc AustinHarris.JsonRpc.Newtonsoft AustinHarris.JsonRpc.SystemTextJson AustinHarris.JsonRpc.AspNetCore; do
43-
dotnet nuget push "$project/bin/Release/"*.nupkg --skip-duplicate --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NugetKey }} # API key for the NuGet feed
44-
done
35+
# Pull requests do not publish. Packages go out from the master workflow through Trusted Publishing, whose
36+
# nuget.org policy is bound to build_publish_master.yml; nothing else can push.

‎AustinHarris.JsonRpc.AspNetCore/AustinHarris.JsonRpc.AspNetCore.csproj‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,34 @@
44
<Company>Austin Harris</Company>
55
<Authors>Austin Harris</Authors>
66
<Product>Json-Rpc.Net ASP.NET Core host</Product>
7-
<Description>ASP.NET Core / Kestrel hosting for JSON-RPC.Net: MapJsonRpc endpoint (PipeReader in, BodyWriter out, no strings), a raw Kestrel ConnectionHandler for JSON-RPC over TCP, and DI registration of services.</Description>
7+
<Description>ASP.NET Core hosting for AustinHarris.JsonRpc. Adds HTTP endpoints and raw Kestrel connections over TCP, Unix sockets and named pipes, with dependency injection.</Description>
88
<VersionPrefix>2.0.0</VersionPrefix>
9-
<PackageReleaseNotes>https://github.com/Astn/JSON-RPC.NET/blob/master/CHANGELOG.md</PackageReleaseNotes>
10-
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
9+
<VersionSuffix>preview.1</VersionSuffix>
10+
<PackageReleaseNotes>2.0.0-preview.1, released with the core package. What is new: https://astn.github.io/JSON-RPC.NET/changelog.html. Upgrading from 1.x: https://astn.github.io/JSON-RPC.NET/upgrading.html</PackageReleaseNotes>
1111
<Copyright>Austin Harris</Copyright>
12-
<PackageProjectUrl>https://github.com/Astn/JSON-RPC.NET</PackageProjectUrl>
12+
<PackageProjectUrl>https://astn.github.io/JSON-RPC.NET/aspnetcore.html</PackageProjectUrl>
1313
<RepositoryUrl>https://github.com/Astn/JSON-RPC.NET</RepositoryUrl>
1414
<RepositoryType>git</RepositoryType>
1515
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>
17-
<PackageTags>json-rpc;jsonrpc;json;rpc;server;aspnetcore;kestrel;pipelines</PackageTags>
17+
<PackageTags>json-rpc;jsonrpc;json;rpc;server;aspnetcore;asp.net-core;kestrel;pipelines;tcp;net8.0;net10.0</PackageTags>
1818
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
1919
<LangVersion>latest</LangVersion>
2020
<Nullable>disable</Nullable>
21+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
22+
<NoWarn>$(NoWarn);CS1591</NoWarn>
23+
<IncludeSymbols>true</IncludeSymbols>
24+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
25+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
26+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
27+
<PackageIcon>icon.png</PackageIcon>
2128
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2229
<RootNamespace>AustinHarris.JsonRpc.AspNetCore</RootNamespace>
2330
</PropertyGroup>
2431

2532
<ItemGroup>
2633
<None Include="README.md" Pack="true" PackagePath="\" />
34+
<None Include="..\icon.png" Pack="true" PackagePath="\" />
2735
</ItemGroup>
2836

2937
<ItemGroup>

‎AustinHarris.JsonRpc.AspNetCore/README.md‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
# AustinHarris.JsonRpc.AspNetCore
1+
# `AustinHarris.JsonRpc.AspNetCore`
22

3-
Hosts [JSON-RPC.Net](https://github.com/Astn/JSON-RPC.NET) in ASP.NET Core. The core processes requests as
4-
UTF-8 bytes, so the HTTP endpoint reads the body with `PipeReader` and writes straight into
5-
`Response.BodyWriter`; nothing is turned into a string on the way through. A `ConnectionHandler` does the
6-
same for JSON-RPC over a raw Kestrel connection (TCP, Unix socket, named pipe).
3+
`AustinHarris.JsonRpc.AspNetCore` hosts
4+
[`AustinHarris.JsonRpc`](https://www.nuget.org/packages/AustinHarris.JsonRpc) 2.0 in ASP.NET Core
5+
and registers services through dependency injection.
6+
Choose it for an HTTP endpoint or raw Kestrel connections over TCP, Unix sockets or named pipes.
7+
8+
The HTTP endpoint reads with `PipeReader` and writes to `Response.BodyWriter`
9+
without converting the document to a string.
710

811
## Install
912

10-
```
11-
dotnet add package AustinHarris.JsonRpc.AspNetCore
13+
```sh
14+
dotnet add package AustinHarris.JsonRpc.AspNetCore --prerelease
1215
```
1316

1417
Targets `net8.0` and `net10.0`; depends on the `AustinHarris.JsonRpc` core package and the ASP.NET Core shared

‎AustinHarris.JsonRpc.Client.WP7/AustinHarris.JsonRpc.Client.WP7.csproj‎

Lines changed: 0 additions & 109 deletions
This file was deleted.

‎AustinHarris.JsonRpc.Client.WP7/Properties/AssemblyInfo.cs‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)