-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (54 loc) · 1.92 KB
/
build-and-push-nuget-packages.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
65
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET
on:
push:
branches: [ "**" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Work out last successful commit
id: setSHAs
uses: nrwl/nx-set-shas@v4
- name: Determine affected projects
id: dotnet_affected
run: |
dotnet new tool-manifest && dotnet tool install dotnet-affected
if dotnet affected -f text traversal \
--from "${{ steps.setSHAs.outputs.base }}" \
--to "${{ github.sha }}"; then
if [ -s affected.txt ]; then
cat affected.txt
echo "Number of affected projects: " $(wc -l < affected.txt)
echo "has_output=true" >> $GITHUB_OUTPUT
else
echo "No affected projects."
echo "has_output=false" >> $GITHUB_OUTPUT
fi
elif [ $? -ne 166 ]; then
echo "Exiting, error occurred"
exit 1
else
echo "No affected projects."
echo "has_output=false" >> $GITHUB_OUTPUT
fi
- name: Test affected projects
if: steps.dotnet_affected.outputs.has_output == 'true'
run: dotnet test affected.proj
- name: Pack affected projects
if: steps.dotnet_affected.outputs.has_output == 'true'
run: |
if [ "${{ github.ref_name }}" == "main" ]; then
dotnet pack affected.proj
else
VERSION=$(date +"%Y.%m.%d.%H%M")
dotnet pack affected.proj /p:Version=${VERSION}-dev
fi
- name: Push NuGet packages
if: steps.dotnet_affected.outputs.has_output == 'true'
run: dotnet nuget push **/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json