-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (37 loc) · 1.4 KB
/
build-test-package.yml
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
name: Build, Test, and Publish NuGet Package
on:
push:
branches:
- master
tags:
- 'v*.*.*' # Ensure that NuGet publishing is triggered on version tags like v1.0.0
permissions:
contents: write
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Set API Key Environment Variable
run: echo "SOLCAST_API_KEY=${{ secrets.SOLCAST_API_KEY }}" >> $GITHUB_ENV
- name: Restore dependencies
run: dotnet restore
- name: Run tests
run: dotnet test
- name: Pack NuGet Package
run: dotnet pack --configuration Release --output ./nupkg --version ${{ github.ref_name }}
- name: Publish NuGet Package to GitHub Packages
if: startsWith(github.ref, 'refs/tags/') # Only publish on tag creation
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: dotnet nuget push ./nupkg/*.nupkg --source "https://nuget.pkg.github.com/OWNER/index.json" --api-key ${{ secrets.GITHUB_TOKEN }}
- name: Publish NuGet Package to NuGet.org
if: startsWith(github.ref, 'refs/tags/')
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json