-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (128 loc) · 4.53 KB
/
ci.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
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
130
131
132
133
134
name: CI
on:
push:
branches:
- main
tags:
- v*
paths-ignore:
- '*.md'
- 'docs/**'
- '.github/workflows/purge-packages.yml'
pull_request:
paths-ignore:
- '*.md'
- 'docs/**'
- '.github/workflows/purge-packages.yml'
merge_group:
jobs:
init:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.resolve-version.outputs.version }}
publish-nuget-org: ${{ startsWith(github.ref, 'refs/tags/v') }}
publish-github: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dotnet-gitversion
run: |
echo ":/github/home/.dotnet/tools" >> $GITHUB_PATH
dotnet tool install -g GitVersion.Tool --version "5.12.0" --ignore-failed-sources
shell: bash
- name: Resolve Version
id: resolve-version
shell: pwsh
working-directory: ./
run: |
$rawVersion = dotnet-gitversion | ConvertFrom-Json
Write-Output $rawVersion
$semVer = $rawVersion.SemVer
Write-Output "Resolved version $semVer"
Write-Output "version=$semVer" >> $env:GITHUB_OUTPUT
Write-Output "Version = $semVer" >> $env:GITHUB_STEP_SUMMARY
build:
runs-on: ubuntu-latest
needs: init
env:
Configuration: Release
TreatWarningsAsErrors: true
Version: ${{ needs.init.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Restore
run: dotnet restore
- name: Check Format
run: dotnet format --no-restore --verify-no-changes
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-restore
working-directory: ./tests/Tests
- name: Pack
run: dotnet pack --no-build -o nugets/
- name: Validate NuGets
run: |
echo ':/github/home/.dotnet/tools' >> $env:GITHUB_PATH
dotnet tool install -g dotnet-validate --version '0.0.1-preview.304' --ignore-failed-sources
Get-ChildItem ./nugets -Filter '*.nupkg' | ForEach-Object { dotnet-validate package local $_ }
shell: pwsh
- name: Upload Nugets as Artifacts
uses: actions/upload-artifact@v4
if: ${{ needs.init.outputs.publish-nuget-org == 'true' || needs.init.outputs.publish-github == 'true'}}
with:
name: nugets
path: nugets
test-with-azure-infra:
runs-on: ubuntu-latest
environment: azure
if: ${{ github.secret_source == 'Actions' }}
permissions:
contents: read
id-token: write
env:
Configuration: Release
TreatWarningsAsErrors: true
steps:
- uses: actions/checkout@v4
- uses: azure/login@v2
with:
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- run: dotnet test
env:
SPOTFLOW_USE_AZURE: true
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_RESOURCE_GROUP_NAME: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
AZURE_STORAGE_ACCOUNT_NAME: ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }}
AZURE_SERVICE_BUS_NAMESPACE_NAME: ${{ secrets.AZURE_SERVICE_BUS_NAMESPACE_NAME }}
AZURE_KEY_VAULT_NAME: ${{ secrets.AZURE_KEY_VAULT_NAME }}
AZURE_EVENT_HUB_NAMESPACE_NAME: ${{ secrets.AZURE_EVENT_HUB_NAMESPACE_NAME }}
publish-nuget-org:
runs-on: ubuntu-latest
needs: [init, build, test-with-azure-infra]
if: ${{ needs.init.outputs.publish-nuget-org == 'true' }}
environment: nuget-org
steps:
- name: Download Nugets
uses: actions/download-artifact@v4
with:
name: nugets
- name: Push Nugets
run: dotnet nuget push '*.nupkg' --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
publish-github:
runs-on: ubuntu-latest
needs: [init, build, test-with-azure-infra]
permissions:
packages: write
if: ${{ needs.init.outputs.publish-github == 'true' }}
steps:
- name: Download Nugets
uses: actions/download-artifact@v4
with:
name: nugets
- name: Push Nugets
run: dotnet nuget push '*.nupkg' --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/spotflow-io/index.json --skip-duplicate