-
-
Notifications
You must be signed in to change notification settings - Fork 119
66 lines (53 loc) · 1.73 KB
/
dotnet-build-on-tag.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build, Pack and Release on Tag
on:
push:
tags:
- '*'
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
permissions:
contents: write
discussions: write
jobs:
build-pack-release:
runs-on: ubuntu-latest
if: |
(!startsWith(github.event.head_commit.message, 'skip-ci')
&& !startsWith(github.event.head_commit.message, 'chore:'))
|| startsWith(github.ref, 'refs/tags/')
defaults:
run:
working-directory: ./src
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
- name: Get the tag version
id: get_version
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
- name: Build and Pack
run: |
dotnet build --configuration Release /p:Version=$TAG_NAME /p:AssemblyVersion=$TAG_NAME /p:FileVersion=$TAG_NAME
dotnet pack --configuration Release /p:PackageVersion=$TAG_NAME /p:Version=$TAG_NAME /p:AssemblyVersion=$TAG_NAME /p:FileVersion=$TAG_NAME --output nupkgs
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: src/nupkgs/*.nupkg
- name: Push NuGet Package
run: |
dotnet nuget push nupkgs/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v2
with:
files: src/nupkgs/*.nupkg
generate_release_notes: true