-
Notifications
You must be signed in to change notification settings - Fork 86
53 lines (49 loc) · 2.46 KB
/
Copy pathbuild_publish_master.yml
File metadata and controls
53 lines (49 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Build Master
on:
push:
paths-ignore:
- "**/*.md"
branches: [ master ]
# Publishing uses nuget.org Trusted Publishing: the job requests an OIDC token from GitHub, NuGet/login exchanges
# it for an API key that lives one hour, and the push uses that key. No long-lived NuGet secret is stored here.
# The nuget.org policy is bound to this repository and to this file's name (build_publish_master.yml); renaming
# the file or moving the push to another workflow needs a new policy on nuget.org.
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
# global.json pins the SDK; the 8.0 runtime is needed for the net8.0 test target.
global-json-file: global.json
dotnet-version: |
8.0.x
10.0.x
- name: Install dependencies
run: dotnet restore AustinHarris.JsonRpc.sln
# Building the solution packs every package project (GeneratePackageOnBuild); `dotnet pack` on the
# solution would trip NU5026 with GeneratePackageOnBuild, so the packages come from the build.
# ContinuousIntegrationBuild makes the build deterministic and lets Source Link map the symbols package
# (.snupkg, pushed alongside each .nupkg) back to this commit on GitHub.
- name: Build
run: dotnet build AustinHarris.JsonRpc.sln --configuration Release --no-restore -p:ContinuousIntegrationBuild=true
- name: Test
run: dotnet test AustinHarris.JsonRpcTestN --configuration Release --no-build
# The key is requested after the tests so it is fresh for the push (it expires after one hour). `user` is the
# nuget.org profile that owns the packages and the trusted publishing policy.
- name: NuGet login (OIDC to a temporary API key)
uses: NuGet/login@v1
id: nuget-login
with:
user: AustinHarris
# Publish all four packages: the core and the three companions (Json.NET, System.Text.Json, ASP.NET Core).
- name: publish nuget version change
run: |
for project in Json-Rpc AustinHarris.JsonRpc.Newtonsoft AustinHarris.JsonRpc.SystemTextJson AustinHarris.JsonRpc.AspNetCore; do
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 }}"
done