-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (129 loc) · 5.03 KB
/
wfnetcorev2.yaml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: .NET Core V2
on:
push:
pull_request:
release:
types:
- published
env:
# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true
# Project name to pack and publish
PROJECT_NAME: SharpHelpers
# GitHub Packages Feed settings
GITHUB_FEED: https://nuget.pkg.github.com/shaprcode-it/
GITHUB_USER: iscifoni
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSONAL_TOKEN: ${{ secrets.PACKAGESTOKEN }}
# Official NuGet Feed settings
NUGET_FEED: https://api.nuget.org/v3/index.json
NUGET_KEY: ${{ secrets.NUGET_TOKEN }}
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
- name: Checkout
uses: actions/checkout@v3
- run: git fetch --unshallow
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.100
source-url: https://nuget.pkg.github.com/shaprcode-it/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Setup .NET Core 2.2
uses: actions/setup-dotnet@v3
with:
dotnet-version: 2.2.402
source-url: https://nuget.pkg.github.com/shaprcode-it/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v0
- run: |
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.CommitsSinceVersionSourcePadded }}"
- name: Restore
run: dotnet restore ./SharpHelpers/SharpHelpers.sln
- name: Build
run: dotnet build -c Release --no-restore ./SharpHelpers/SharpHelpers.sln
- name: Test
run: dotnet test ./SharpHelpers/SharpHelpers.sln -c Release --no-build
- name: Pack
if: matrix.os == 'ubuntu-latest'
run: dotnet pack -v normal -c Release --no-restore --no-build -p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }} ./SharpHelpers/SharpHelpers.sln
- name: Upload Artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: nupkg
path: ./SharpHelpers/${{ env.PROJECT_NAME }}/bin/Release/*.nupkg
prerelease:
needs: build
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: nupkg
- name: Display structure of downloaded files
run: ls -R
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
# source-url: https://nuget.pkg.github.com/shaprcode-it/index.json
# - name: Add Github feed
# run: dotnet nuget add source --username iscifoni --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/shaprcode-it/index.json"
# - name: List sources
# run: dotnet nuget list source
# - name: Push to GitHub Feed
# run: |
# for f in *.nupkg
# do
# curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
# done
- name: Publish the package to GitHub
run: dotnet nuget push "*.nupkg" --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key ${{ secrets.GITHUB_TOKEN }}
deploy:
needs: build
if: github.event_name == 'release' && startsWith(github.ref, 'refs/heads/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
source-url: https://nuget.pkg.github.com/shaprcode-it/index.json
- name: Create Release NuGet package
run: |
arrTag=(${GITHUB_REF//\// })
VERSION="${arrTag[2]}"
echo Version: $VERSION
VERSION="${VERSION//v}"
echo Clean Version: $VERSION
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }} -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.*proj
# - name: Push to GitHub Feed
# run: |
# for f in ./nupkg/*.nupkg
# do
# curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
# done
- name: Publish the package to GitHub
run: dotnet nuget push "*.nupkg" --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key ${{ secrets.GITHUB_TOKEN }}
- name: Push to NuGet Feed
run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY