-
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (53 loc) · 2.03 KB
/
Copy pathpackage-build.yaml
File metadata and controls
63 lines (53 loc) · 2.03 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
name: Build
on:
workflow_call:
inputs:
dotnet-version:
type: string
default: "8.0.x"
hasTests:
description: "Determines if tests should be run"
required: false
default: true
type: boolean
jobs:
build:
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup .NET SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ inputs.dotnet-version}}
- name: Extract Version from Directory.Build.props
id: version
run: |
VERSION_PREFIX=$(grep -m1 '<VersionPrefix>' Directory.Build.props | sed -E 's/.*<VersionPrefix>(.*)<\/VersionPrefix>.*/\1/')
VERSION="$VERSION_PREFIX.${{ github.run_number }}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore /p:Version=${{ env.VERSION }} /p:InformationalVersion=${{ env.VERSION }}
- name: Test Code
if: inputs.hasTests == true
run: dotnet test --no-restore
- name: Pack
run: dotnet pack --configuration Release -o artifacts --no-build /p:Version=${{ env.VERSION }} /p:InformationalVersion=${{ env.VERSION }}
- name: Publish to Nuget
run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
- name: Tag Commit
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag v${{ env.VERSION }}
git push origin v${{ env.VERSION }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.VERSION }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}