-
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (59 loc) · 2.1 KB
/
publish.yml
File metadata and controls
73 lines (59 loc) · 2.1 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Publish to NuGet
on:
push:
tags:
- 'v*'
jobs:
changelog:
name: Generate Changelog
uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main
publish:
name: Build and Publish
runs-on: windows-latest
needs: changelog
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Extract version from tag
id: version
run: |
$tag = "${{ github.ref_name }}"
$version = $tag -replace '^v', ''
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "TAG=$tag" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Restore dependencies
run: dotnet restore src/CodingWithCalvin.Otel4Vsix/CodingWithCalvin.Otel4Vsix.csproj
- name: Build
run: dotnet build src/CodingWithCalvin.Otel4Vsix/CodingWithCalvin.Otel4Vsix.csproj --configuration Release --no-restore -p:Version=${{ steps.version.outputs.VERSION }}
- name: Pack
run: dotnet pack src/CodingWithCalvin.Otel4Vsix/CodingWithCalvin.Otel4Vsix.csproj --configuration Release --no-build -p:Version=${{ steps.version.outputs.VERSION }} --output ./nupkg
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.TAG }}
name: v${{ steps.version.outputs.VERSION }}
body: ${{ needs.changelog.outputs.changelog }}
draft: false
prerelease: ${{ contains(steps.version.outputs.VERSION, '-') }}
files: |
./nupkg/*.nupkg
# Get a short-lived NuGet API key
- name: NuGet login (OIDC → temp API key)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USERNAME }}
- name: Push to NuGet
run: |
Get-ChildItem ./nupkg/*.nupkg | ForEach-Object {
dotnet nuget push $_.FullName --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate
}
shell: pwsh