-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (150 loc) · 5.1 KB
/
deploy.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
name: Deploy
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: windows-latest
outputs:
solution: ${{ steps.outvars.outputs.solution }}
fullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
updateAssemblyInfo: true
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 21
- name: Set environment variables
id: envvars
run: |
echo "solution=$([io.path]::GetFileNameWithoutExtension($(Get-ChildItem -Path .\* -Include *.sln)))" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "projectPath=$((Get-ChildItem -Path .\Src\ -Directory | Select-Object -First 1).Name)" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "sonar_key=$("${{ github.repository }}" -replace "/","_")" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build solution
run: dotnet build -c Release
- name: Run tests
run: dotnet test -c Release --no-build --no-restore
- name: Publish
run: dotnet publish -c Release -o Publish\Core --no-build --no-restore Src/${{ env.projectPath }}/${{ env.projectPath }}.csproj
- name: Set env variables to output
id: outvars
run: echo "solution=${{ env.solution }}" >> $env:GITHUB_OUTPUT
- name: Upload Core artifacts
uses: actions/upload-artifact@v4
with:
name: Core
path: Publish\Core
deploy_core:
name: Deploy Core
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: Core
- name: Upload to ftp
uses: sebastianpopp/ftp-action@releases/v2
with:
host: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
remoteDir: Core
forceSsl: true
create_release:
name: Create Release
needs: [build, deploy_core]
runs-on: ubuntu-latest
steps:
- name: Download artifact Core
uses: actions/download-artifact@v4
with:
name: Core
path: Core
- name: Zip artifact
run: |
zip -r Core.zip ./Core/*
- name: Create Release
uses: ncipollo/[email protected]
id: create_release
with:
allowUpdates: true
draft: false
makeLatest: true
tag: v${{ env.fullSemVer }}
name: Release v${{ env.fullSemVer }}
generateReleaseNotes: true
body: Release ${{ env.fullSemVer }} of ${{ github.repository }}
- name: Upload Core
id: upload_core
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Core.zip
asset_name: Core.zip
asset_content_type: application/zip
- name: Send Webhook
uses: distributhor/workflow-webhook@v3
with:
webhook_type: "json-extended"
event_name: "release"
webhook_url: ${{ secrets.RELEASE_WEBHOOK_URL }}
webhook_secret: '{"x-github-release-token": "${{ secrets.RELEASE_WEBHOOK_TOKEN }}"}'
data: '{ "tag_name": "v${{ env.fullSemVer }}", "assets": [{ "name" : "Core.zip", "browser_download_url": "${{ steps.upload_core.outputs.browser_download_url }}" } ] }'
cleanup:
name: Cleanup
needs: create_release
runs-on: ubuntu-latest
steps:
- name: Remove artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: "*"