-
Notifications
You must be signed in to change notification settings - Fork 7
83 lines (66 loc) · 2.8 KB
/
deploy-nuget.yml
File metadata and controls
83 lines (66 loc) · 2.8 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
73
74
75
76
77
78
79
80
81
82
83
name: "Deploy Nuget"
on:
workflow_dispatch: # Manual trigger
permissions:
contents: read
pull-requests: write
checks: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
env:
Solution_Name: "Finance.NET.sln"
Nuget_Project_Path: "src/Finance.NET.csproj"
Test_Project_Path: "tests/Tests.csproj"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Restore
run: dotnet restore "${{ env.Solution_Name }}"
- name: Build
run: dotnet build "${{ env.Solution_Name }}" --configuration Release --no-restore
- name: Run tests
run: dotnet test "${{ env.Test_Project_Path }}" --configuration Release --logger "console;verbosity=detailed" --logger "console;verbosity=detailed" --filter "TestCategory!=Long-Running"
env:
FinanceNet__AlphaVantageApiKey: ${{ secrets.ALPHAVANTAGEAPIKEY }}
- name: Pack NuGet Package
run: dotnet pack "${{ env.Nuget_Project_Path }}" --configuration Release --no-build --output ./nupkg
- name: Publish to NuGet
if: success()
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./nupkg/*.nupkg --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
- name: Extract Version
id: get_version
run: |
VERSION=$(grep '<Version>' ${{ env.Nuget_Project_Path }} | sed -E 's/.*<Version>(.*)<\/Version>.*/\1/')
echo "VERSION=$VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Configure Git Credentials
run: |
echo "https://${{ secrets.GH_APIKEY }}@github.com" > ~/.git-credentials
git config --global credential.helper store
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Create Git Tag
run: |
git tag -a "v${{ env.VERSION }}" -m "Release v${{ env.VERSION }}"
git push origin "v${{ env.VERSION }}"
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ env.VERSION }}"
release_name: "Finance.NET ${{ env.VERSION }}"
body_path: ./release-notes/v${{ env.VERSION }}.md
- name: Add GitHub Packages NuGet Source
run: |
dotnet nuget add source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --name github --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text
- name: Publish to GitHub Packages
run: dotnet nuget push ./nupkg/*.nupkg --source "github" --api-key ${{ secrets.GITHUB_TOKEN }}