-
Notifications
You must be signed in to change notification settings - Fork 13
241 lines (203 loc) · 6.57 KB
/
publish-libraries.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: Publish libraries
on:
workflow_dispatch:
inputs:
dry-run:
description: 'Dry run'
required: true
type: boolean
default: true
schedule:
- cron: '49 3 * * 1' # 3:49 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
}
nuget-build:
name: NuGet package build [${{matrix.library}}]
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
library: [ dotnet-client, dotnet-subscriber, utils, pedm-dotnet-client ]
include:
- library: dotnet-client
libpath: ./devolutions-gateway/openapi/dotnet-client
- library: dotnet-subscriber
libpath: ./devolutions-gateway/openapi/dotnet-subscriber
- library: utils
libpath: ./utils/dotnet
- library: pedm-dotnet-client
libpath: ./crates/devolutions-pedm/openapi/dotnet-client
steps:
- name: Check out ${{ github.repository }}
uses: actions/checkout@v4
- name: Build
shell: pwsh
run: |
Set-PSDebug -Trace 1
$Path = '${{matrix.libpath}}'
& "$Path/build.ps1"
New-Item -ItemType "directory" -Path . -Name "nuget-packages"
Get-ChildItem -Path $Path -Recurse -Include '*.nupkg' | ForEach { Copy-Item $_ "./nuget-packages" }
Get-ChildItem -Path $Path -Recurse -Include '*.snupkg' | ForEach { Copy-Item $_ "./nuget-packages" }
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: nupkg-${{matrix.library}}
path: |
nuget-packages/*.nupkg
nuget-packages/*.snupkg
nuget-merge:
name: NuGet merge artifacts
runs-on: ubuntu-latest
needs: nuget-build
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: nupkg
pattern: nupkg-*
delete-merged: true
npm-build:
name: NPM package build
runs-on: ubuntu-20.04
steps:
- name: Check out ${{ github.repository }}
uses: actions/checkout@v4
- name: Build
shell: pwsh
run: |
Set-PSDebug -Trace 1
$Path = './devolutions-gateway/openapi/ts-angular-client'
& "$Path/build.ps1"
New-Item -ItemType "directory" -Path . -Name "npm-packages"
Get-ChildItem -Path $Path -Recurse *.tgz | ForEach { Copy-Item $_ "./npm-packages" }
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: npm
path: npm-packages/*.tgz
nuget-publish:
name: Publish NuGet packages
runs-on: ubuntu-20.04
environment: publish-prod
if: needs.preflight.outputs.dry-run == 'false'
needs:
- preflight
- nuget-merge
steps:
- name: Download NuGet packages artifact
uses: actions/download-artifact@v4
with:
name: nupkg
path: nuget-packages
- name: Publish to nuget.org
shell: pwsh
run: |
Set-PSDebug -Trace 1
$Files = Get-ChildItem -Recurse nuget-packages/*.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
}
npm-publish:
name: Publish NPM packages
runs-on: ubuntu-20.04
environment: publish-prod
if: needs.preflight.outputs.dry-run == 'false'
needs:
- preflight
- npm-build
steps:
- name: Check out ${{ github.repository }}
uses: actions/checkout@v4
- name: Download NPM packages artifact
uses: actions/download-artifact@v4
with:
name: npm
path: npm-packages
- name: Configure NPM
shell: pwsh
run: npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
- name: Publish
shell: pwsh
run: |
Set-PSDebug -Trace 1
$Files = Get-ChildItem -Recurse npm-packages/*.tgz
foreach ($File in $Files) {
Write-Host "Publishing $($File.Name)..."
./ci/npm-publish.ps1 -Tarball "$File" -Access 'public'
}
- name: Update Artifactory Cache
run: gh workflow run update-artifactory-cache.yml --repo Devolutions/scheduled-tasks --field package_name="gateway-client"
env:
GH_TOKEN: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}
remove-labels:
name: Remove publish-required labels
runs-on: ubuntu-latest
if: needs.preflight.outputs.dry-run == 'false'
needs:
- nuget-build
- npm-publish
steps:
- name: Check out ${{ github.repository }}
uses: actions/checkout@v4
- name: Remove labels
shell: pwsh
env:
GITHUB_TOKEN: ${{ github.token }}
run: ./ci/remove-labels.ps1 -Label 'publish-required'
notify:
name: Notify failure
runs-on: ubuntu-latest
if: ${{ always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule' }}
needs:
- npm-build
- nuget-merge
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.24.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>"
}
}
]
}