-
Notifications
You must be signed in to change notification settings - Fork 15
148 lines (126 loc) · 3.94 KB
/
nuget.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Publish NuGet package
on:
workflow_dispatch:
inputs:
dry-run:
description: 'Dry run'
required: true
type: boolean
default: 'true'
schedule:
- cron: '21 3 * * 1' # 3:21 AM UTC every Monday
jobs:
preflight:
name: Preflight
runs-on: ubuntu-20.04
outputs:
dry-run: ${{ steps.get-dry-run.outputs.dry-run }}
steps:
- name: Get dry run
id: get-dry-run
shell: pwsh
run: |
Set-PSDebug -Trace 1
$IsDryRun = '${{ github.event.inputs.dry-run }}' -Eq 'true' -Or '${{ github.event_name }}' -Eq 'schedule'
if ($IsDryRun) {
echo "dry-run=true" >> $Env:GITHUB_OUTPUT
} else {
echo "dry-run=false" >> $Env:GITHUB_OUTPUT
}
build-native:
uses: ./.github/workflows/build-native.yml
build-managed:
name: Managed build
runs-on: windows-2022
needs: [build-native]
steps:
- name: Check out ${{ github.repository }}
uses: actions/checkout@v4
- name: Prepare dependencies
shell: pwsh
run: |
New-Item -ItemType Directory -Path "dependencies/runtimes" | Out-Null
- name: Download native components
uses: actions/download-artifact@v4
with:
path: dependencies/runtimes
- name: Rename dependencies
shell: pwsh
run: |
Set-PSDebug -Trace 1
Set-Location "dependencies/runtimes"
$(Get-Item ".\sspi-*-release") | ForEach-Object { Rename-Item $_ $_.Name.Replace("-release", "") }
$(Get-Item ".\sspi-*") | ForEach-Object { Rename-Item $_ $_.Name.Replace("sspi-", "") }
Get-ChildItem * -Recurse
- name: Build sspi (managed)
shell: pwsh
run: |
dotnet build .\ffi\dotnet\Devolutions.Sspi.sln -o package
- name: Upload managed components
uses: actions/upload-artifact@v4
with:
name: sspi-nupkg
path: package/*.nupkg
publish:
name: Publish NuGet package
runs-on: ubuntu-20.04
environment: nuget-publish
if: needs.preflight.outputs.dry-run == 'false'
needs:
- preflight
- build-managed
steps:
- name: Download NuGet package artifact
uses: actions/download-artifact@v4
with:
name: sspi-nupkg
path: package
- name: Publish to nuget.org
shell: pwsh
run: |
Set-PSDebug -Trace 1
$Files = Get-ChildItem -Recurse package/*.nupkg
foreach ($File in $Files) {
$PushCmd = @(
'dotnet',
'nuget',
'push',
"$File",
'--api-key',
'${{ secrets.NUGET_API_KEY }}',
'--source',
'https://api.nuget.org/v3/index.json',
'--skip-duplicate'
)
Write-Host "Publishing $($File.Name)..."
$PushCmd = $PushCmd -Join ' '
Invoke-Expression $PushCmd
}
notify:
name: Notify failure
runs-on: ubuntu-latest
if: ${{ always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule' }}
needs:
- preflight
- build-native
- build-managed
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_ARCHITECTURE }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
steps:
- name: Send slack notification
id: slack
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*${{ github.repository }}* :fire::fire::fire::fire::fire: \n The scheduled build for *${{ github.repository }}* is <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|broken>"
}
}
]
}