Skip to content

Commit 8516917

Browse files
hf-kkleinKonstantin
andauthored
chore(CD): switch from secret API key to Trusted Publishing on nuget.org; drop pre-release pipeline (#142)
* chore(CD): switch from secret API key to Trusted Publishing on nuget.org + run CI on .net10 mostly * Update README to remove pre-release information Removed pre-release NuGet badge and release workflow instructions. --------- Co-authored-by: Konstantin <konstantin.klein+github@hochfrequenz.de>
1 parent 06eecef commit 8516917

5 files changed

Lines changed: 17 additions & 61 deletions

File tree

.github/workflows/formatter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v6
10-
- name: Setup .NET 9
10+
- name: Setup .NET
1111
uses: actions/setup-dotnet@v5
1212
with:
13-
dotnet-version: 9
13+
dotnet-version: 10
1414
- name: Restore .NET tools
1515
working-directory: ./ChronoJsonDiffPatch
1616
run: dotnet tool restore

.github/workflows/nuget_package_push.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ on:
77

88
jobs:
99
pushrelease:
10-
runs-on: windows-latest
10+
runs-on: ubuntu-latest
1111
env:
1212
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
13+
permissions:
14+
id-token: write # enable GitHub OIDC token issuance for this job
15+
environment: "release" # has to match the policy name in the nuget.org Trusted Publishing setup.
16+
# if the environment name is not set here, you'll run into an error message like "Error: Token exchange failed (401): Environment mismatch for policy 'release': expected 'release', actual ''"
1317
steps:
1418
- uses: actions/checkout@v6
1519
- name: Setup .NET Core
1620
uses: actions/setup-dotnet@v5
1721
with:
18-
dotnet-version: 8.0.100
22+
dotnet-version: 10
1923
- uses: olegtarasov/get-tag@v2.1
2024
id: tagChrono
2125
with:
@@ -29,12 +33,13 @@ jobs:
2933
- name: Create Package ChronoJsonDiffPatch (dotnet pack)
3034
working-directory: "ChronoJsonDiffPatch/ChronoJsonDiffPatch"
3135
run: dotnet pack ChronoJsonDiffPatch.csproj --configuration Release -p:PackageVersion="${{ steps.tagChrono.outputs.tag }}"
32-
- name: Setup Nuget.exe
33-
uses: warrenbuckley/Setup-Nuget@v1
36+
- name: NuGet login (OIDC → temp API key)
37+
uses: NuGet/login@v1
38+
id: login
39+
with:
40+
user: hf-kklein
41+
# because the package is owned by hf-kklein: https://www.nuget.org/packages/ChronoJsonDiffPatch/
3442
- name: Nuget push ChronoJsonDiffPatch
3543
working-directory: "ChronoJsonDiffPatch/ChronoJsonDiffPatch"
36-
# token: https://github.com/Hochfrequenz/chrono_json_diff_patch/settings/secrets/actions/NUGET_ORG_PUSH_TOKEN
37-
# expires 2026-09-21
3844
run: |
39-
nuget setApiKey ${{ secrets.NUGET_ORG_PUSH_TOKEN }}
40-
nuget push .\bin\Release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -NoSymbols
45+
dotnet nuget push ./bin/Release/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{steps.login.outputs.NUGET_API_KEY}} --skip-duplicate

.github/workflows/nuget_package_push_prerelease.yml

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

.github/workflows/unittests_and_coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
dotnet-version: [ "9" ]
10+
dotnet-version: [ "9", "10" ]
1111
steps:
1212
- uses: actions/checkout@v6
1313
- name: Setup .NET Core
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup .NET Core
2626
uses: actions/setup-dotnet@v5
2727
with:
28-
dotnet-version: 9
28+
dotnet-version: 10
2929
- name: Install dependencies
3030
working-directory: ./ChronoJsonDiffPatch
3131
run: dotnet restore

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ dotnet add package ChronoJsonDiffPatch
1515
| Version | Number |
1616
| ----------- | ----------------------------------------------------------------------- |
1717
| Stable | ![Nuget Package](https://badgen.net/nuget/v/ChronoJsonDiffPatch) |
18-
| Pre-Release | ![Nuget Prerelease](https://badgen.net/nuget/v/ChronoJsonDiffPatch/pre) |
1918

2019
## Usage / Minimal Working Example
2120

@@ -134,8 +133,5 @@ The patches then look like this:
134133
- The code has [at least a 90%](https://github.com/Hochfrequenz/chrono_json_diff_patch/blob/main/.github/workflows/unittests_and_coverage.yml#L34) unit test coverage. ✔️
135134
- The ChronoJsonDiffPatch package has no dependencies except for `TimePeriodLibrary.NET` and `JsonDiffPatch.NET`. ✔️
136135

137-
## Release Workflow
138-
139-
To create a **pre-release** nuget package, create a tag of the form `prerelease-vx.y.z` where `x.y.z` is the semantic version of the pre-release. This will create and push nuget packages with the specified version `x.y.z` and a `-betaYYYYMMDDHHmmss` suffix.
140136

141137
To create a **release** nuget package, create a tag of the form `vx.y.z` where `x.y.z` is the semantic version of the release. This will create and push nuget packages with the specified version `x.y.z`.

0 commit comments

Comments
 (0)