Skip to content

Commit c74bd6b

Browse files
ci: Add manual NuGet publishing workflow for first-time publish. (#48)
Signed-off-by: Philip Conrad <philip@chariot-chaser.net>
1 parent c39a738 commit c74bd6b

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Manually Publish Package to NuGet"
2+
3+
# This workflow is intended for populating the initial NuGet package.
4+
on:
5+
# Allows you to run this workflow manually from the Actions tab
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
concurrency: ${{ github.workflow }}-${{ github.ref }}
11+
12+
env:
13+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
14+
DOTNET_NOLOGO: true
15+
NuGetDirectory: ${{ github.workspace }}/nuget
16+
17+
jobs:
18+
manual-build-and-publish:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v5
22+
with:
23+
fetch-depth: 0 # Get all history for automatic versioning
24+
25+
- name: Setup dotnet
26+
uses: actions/setup-dotnet@v4
27+
with:
28+
dotnet-version: "8.0.x"
29+
30+
- name: Restore dependencies
31+
run: dotnet restore
32+
33+
- name: Build
34+
run: dotnet build --configuration Release --no-restore
35+
36+
- name: Test
37+
run: dotnet test --no-restore --verbosity normal
38+
39+
- name: Get current version
40+
id: current_version
41+
run: |
42+
$currentVersion = (Select-Xml -Path src/OpenPolicyAgent.Ucast.Linq/OpenPolicyAgent.Ucast.Linq.csproj -XPath "//PackageVersion").Node.InnerText
43+
echo "CURRENT_VERSION=$currentVersion" >> $env:GITHUB_OUTPUT
44+
shell: pwsh
45+
46+
- name: Pack
47+
run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} --no-build
48+
49+
- name: Publish NuGet package
50+
run: |
51+
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Filter *.nupkg)) {
52+
dotnet nuget push $file --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
53+
}
54+
shell: pwsh

0 commit comments

Comments
 (0)