Skip to content

Commit 2bfbc49

Browse files
authored
First NuGet Release (#16)
* Added NuGet publish * Updated to only deploy when release is merged * Separating publish step * Added release to build process on PR
1 parent 0774fc4 commit 2bfbc49

File tree

2 files changed

+82
-15
lines changed

2 files changed

+82
-15
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
workflow_dispatch:
2020
branches:
2121
- main
22+
- release
2223
paths-ignore:
2324
- '**/*.md'
2425
- '**/*.gitignore'
@@ -73,18 +74,4 @@ jobs:
7374
$version=$nuspec.project.propertygroup.version
7475
$relnotes=$nuspec.project.propertygroup.packagereleasenotes
7576
echo "PKG_VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
76-
echo "RELNOTES=$relnotes" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
77-
78-
- name: Push to NuGet
79-
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref == 'refs/heads/release'
80-
run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
81-
82-
- name: Tag and Release
83-
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref == 'refs/heads/release'
84-
id: tag_release
85-
uses: softprops/action-gh-release@v0.1.13
86-
with:
87-
body: ${{ env.RELNOTES }}
88-
tag_name: ${{ env.PKG_VERSION }}
89-
files: |
90-
**/*.nupkg
77+
echo "RELNOTES=$relnotes" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: "Build and Deploy"
2+
3+
on:
4+
push:
5+
branches:
6+
- release
7+
paths-ignore:
8+
- '**/*.md'
9+
- '**/*.gitignore'
10+
- '**/*.gitattributes'
11+
workflow_dispatch:
12+
branches:
13+
- release
14+
paths-ignore:
15+
- '**/*.md'
16+
- '**/*.gitignore'
17+
- '**/*.gitattributes'
18+
19+
jobs:
20+
build:
21+
outputs:
22+
version: ${{ steps.set_proj_version.outputs.PKG_VERSION }}
23+
relnotes: ${{ steps.set_proj_version.outputs.RELNOTES }}
24+
name: Build
25+
runs-on: ubuntu-latest
26+
env:
27+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
28+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
29+
DOTNET_NOLOGO: true
30+
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
31+
DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false
32+
DOTNET_MULTILEVEL_LOOKUP: 0
33+
34+
steps:
35+
- uses: actions/checkout@v2
36+
37+
- name: Setup .NET Core SDK
38+
uses: actions/setup-dotnet@v1.9.0
39+
with:
40+
dotnet-version: 6.0.x
41+
42+
- name: Restore
43+
run: dotnet restore
44+
45+
- name: Build
46+
run: dotnet build --configuration Release --no-restore
47+
48+
- name: Test
49+
run: dotnet test
50+
51+
- name: Pack
52+
run: dotnet pack Fritz.InstantAPIs/Fritz.InstantAPIs.csproj --configuration Release -o finalpackage --no-build
53+
54+
- name: Publish artifact
55+
uses: actions/upload-artifact@master
56+
with:
57+
name: nupkg
58+
path: finalpackage
59+
60+
- name: Get version
61+
id: set_proj_version
62+
shell: pwsh
63+
run: |
64+
[xml]$nuspec = Get-Content Fritz.InstantAPIs/Fritz.InstantAPIs.csproj
65+
$version=$nuspec.project.propertygroup.version
66+
$relnotes=$nuspec.project.propertygroup.packagereleasenotes
67+
echo "PKG_VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
68+
echo "RELNOTES=$relnotes" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
69+
70+
- name: Push to NuGet
71+
run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
72+
73+
- name: Tag and Release
74+
id: tag_release
75+
uses: softprops/action-gh-release@v0.1.13
76+
with:
77+
body: ${{ env.RELNOTES }}
78+
tag_name: ${{ env.PKG_VERSION }}
79+
files: |
80+
**/*.nupkg

0 commit comments

Comments
 (0)