-
Notifications
You must be signed in to change notification settings - Fork 6
61 lines (52 loc) · 1.79 KB
/
PackNuget.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
name: 00_Publish_Nuget_Pkg
on:
workflow_dispatch:
push:
branches: [main]
jobs:
version_01:
name: Set Project Version
runs-on: ubuntu-latest
steps:
- name: Set version
id: set_version
run: |
repoDateTime=${{github.event.repository.updated_at}}
versionNumber=$(echo $repoDateTime | cut -d "T" -f1 | sed 's/-/./g')
buildNumber=${{github.run_number}}
echo "Version is $versionNumber.$buildNumber"
echo "version=$versionNumber.$buildNumber" >> $GITHUB_OUTPUT
outputs:
version: ${{steps.set_version.outputs.version}}
build_02:
name: Build & Publish Nuget Package
runs-on: ubuntu-latest
needs: version_01
timeout-minutes: 15
env:
PROJECT_NAME: OkonkwoOandaV20
PROJECT_FOLDER: ./OkonkwoOandaV20
PROJECT_FILE: ./OkonkwoOandaV20/OkonkwoOandaV20.csproj
VERSION: ${{needs.version_01.outputs.version}}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "8.0.x"
- name: Build
working-directory: ${{env.PROJECT_FOLDER}}
run: |
dotnet build -c Release -p:Version=${{env.VERSION}}
- name: Pack
working-directory: ${{env.PROJECT_FOLDER}}
run: |
dotnet pack -c Release -p:PackageVersion=${{env.VERSION}} --no-build --output .
- name: Publish Nuget package
if: github.event_name == 'workflow_dispatch' && github.ref_name == 'main'
working-directory: ${{env.PROJECT_FOLDER}}
run: |
packageName="${{env.PROJECT_NAME}}.${{env.VERSION}}.nupkg"
sourceUrl="https://api.nuget.org/v3/index.json"
dotnet nuget push $packageName -s $sourceUrl -k ${{secrets.NUGET_API_KEY}}