-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (45 loc) · 1.56 KB
/
nuget.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
name: Nuget publish
on:
push:
branches: [ "main", "develop"]
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
env:
VERSION: none
defaults:
run:
working-directory: ./dotnet/SitecoreSend.SDK
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set Release Version Variable
if: ${{ github.ref_type == 'tag' }}
env:
TAG: ${{ github.ref_name }}
run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Set outputs
if: ${{ github.ref_type == 'branch' }}
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set Branch Version Variable
if: ${{ github.ref_type == 'branch' }}
env:
TAG: ${{ github.ref_name }}
MAJOR_VERSION: ${{ vars.MAJOR_VERSION }}
SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
run: echo "VERSION=${MAJOR_VERSION}-${TAG#v}-${SHA_SHORT}-preview" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore /p:Version=$VERSION
- name: pack nuget packages
run: dotnet pack --output nupkgs --no-restore --no-build /p:PackageVersion=$VERSION
- name: upload nuget package
# if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
run: dotnet nuget push nupkgs/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json