-
Notifications
You must be signed in to change notification settings - Fork 4
81 lines (75 loc) · 2.88 KB
/
dotnet.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# 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:
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
push:
branches: [ "master" ] # Run the workflow when pushing to the main branch
pull_request:
branches: [ "master" ]
release:
types:
- published # Run the workflow when a new GitHub release is published
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace }}/nuget
TagRelease: ${{ (github.event_name == 'push' || github.event.pull_request.merged == true) && github.ref == 'refs/heads/master' }}
jobs:
build-and-test:
environment: production
runs-on: ubuntu-latest
outputs:
calculatedVersion: ${{ steps.gitversion.outputs.majorMinorPatch }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
configFilePath: GitVersion.yml
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore /p:Version='${{ env.GitVersion_NuGetVersion }}'
- name: Test
run: dotnet test --no-build --verbosity normal
env:
Marqeta__BaseUrl: ${{ secrets.MARQETA__BASEURL }}
Marqeta__UserName: ${{ secrets.MARQETA__USERNAME }}
Marqeta__Password: ${{ secrets.MARQETA__PASSWORD }}
- name: Create Tag (master only)
if: env.TagRelease == 'true'
run: git tag ${{ env.GitVersion_SemVer }}
- name: Push Tag (master only)
if: env.TagRelease == 'true'
run: git push origin ${{ env.GitVersion_SemVer }}
publish:
# Publish only when creating a GitHub Release
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
# You can update this logic if you want to manage releases differently
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ build-and-test ]
environment: production
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Pack
run: dotnet pack --configuration Release /p:Version='${{ needs.build-and-test.outputs.calculatedVersion }}' --include-symbols --output ${{ env.NuGetDirectory }}
- name: Push
run: dotnet nuget push "${{ env.NuGetDirectory }}/*.nupkg" --api-key "${{ secrets.NUGETAPIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate