-
Notifications
You must be signed in to change notification settings - Fork 25
159 lines (156 loc) · 5.87 KB
/
release.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
name: Release
on:
push:
branches:
- master
- release-*
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-*"
pull_request:
workflow_dispatch:
env:
DOTNET_NOLOGO: true
jobs:
release:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: windows-2022
outputs:
version: ${{ steps.save-version.outputs.version }}
steps:
- name: Check for secrets
env:
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
shell: pwsh
run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 })
- name: Checkout
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: 7.0.x
- name: Set up Node.js
uses: actions/setup-node@v4.0.1
with:
node-version: 21.6.x
# Build AngularJS and Vue apps
- name: Build AngularJS and Vue.js
run: .\build.ps1
working-directory: src/ServicePulse.Host
- name: Run Vue component tests
run: npm run test:component
working-directory: src/ServicePulse.Host/vue
- name: Run Vue application tests
run: npm run test:application
working-directory: src/ServicePulse.Host/vue
# .NET Build and sign
- name: Build
run: dotnet build src --configuration Release
- id: save-version
name: Save version
run: echo "version=${{env.MinVerVersion}}" >> $env:GITHUB_OUTPUT
- name: Sign NuGet packages
uses: Particular/sign-nuget-packages-action@v1.0.0
with:
client-id: ${{ secrets.AZURE_KEY_VAULT_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_KEY_VAULT_TENANT_ID }}
client-secret: ${{ secrets.AZURE_KEY_VAULT_CLIENT_SECRET }}
certificate-name: ${{ secrets.AZURE_KEY_VAULT_CERTIFICATE_NAME }}
- name: Setup Advanced Installer
run: |
$version = "20.2.1"
choco install advanced-installer --version=$version
& "C:\Program Files (x86)\Caphyon\Advanced Installer $version\bin\x86\AdvancedInstaller.com" /register ${{ secrets.ADVANCED_INSTALLER_LICENSE_KEY }}
- name: Prepare AIP file
run: |
$content = Get-Content -Raw -Path src/Setup/ServicePulse.aip
$content = $content -replace "replace-tenant-id", "${{ secrets.AZURE_KEY_VAULT_TENANT_ID }}" -replace "replace-app-id", "${{ secrets.AZURE_KEY_VAULT_CLIENT_ID }}" -replace "replace-cert-name", "${{ secrets.AZURE_KEY_VAULT_CERTIFICATE_NAME }}"
Set-Content src/Setup/ServicePulse.aip $content
- name: Build Windows installer
env:
AZURE_KEY_VAULT_CLIENT_SECRET: ${{ secrets.AZURE_KEY_VAULT_CLIENT_SECRET }}
run: dotnet build src/Setup --configuration Release
# Upload artifacts
- name: Publish artifacts
uses: actions/upload-artifact@v4.3.1
with:
name: artifacts
path: |
assets/*
nugets/*
retention-days: 1
- name: Verify release artifact counts
shell: pwsh
run: |
$assetsCount = (Get-ChildItem -Recurse -File assets).Count
$nugetsCount = (Get-ChildItem -Recurse -File nugets).Count
$expectedAssetsCount = 1
$expectedNugetsCount = 1
if ($assetsCount -ne $expectedAssetsCount)
{
Write-Host Assets: Expected $expectedAssetsCount but found $assetsCount
exit -1
}
if ($nugetsCount -ne $expectedNugetsCount)
{
Write-Host Nugets: Expected $expectedNugetsCount but found $nugetsCount
exit -1
}
# Deploy to Octopus
- name: Deploy
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: Particular/push-octopus-package-action@v2.0.0
with:
octopus-deploy-api-key: ${{ secrets.OCTOPUS_DEPLOY_API_KEY }}
docker:
needs: release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-2019
image-name: servicepulse-windows
dockerfile: dockerfile.iis
- os: ubuntu-20.04
image-name: servicepulse
dockerfile: dockerfile.nginx
fail-fast: false
steps:
- name: Check for secrets
env:
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
shell: pwsh
run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 })
- name: Checkout
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4.0.1
with:
node-version: 21.6.x
# Build AngularJS and Vue apps
- name: Build AngularJS and Vue.js
run: .\build.ps1
shell: pwsh
working-directory: src/ServicePulse.Host
- name: Update app.constants.js
run: |
$filename = "src/ServicePulse.Host/app/js/app.constants.js"
(Get-Content $filename).replace("1.2.0", "${{ needs.release.outputs.version }}") | Set-Content $filename
shell: pwsh
- name: Build Docker image
if: ${{ matrix.image-name == 'servicepulse' || (github.event_name == 'push' && github.ref_type == 'tag') }}
run: docker build -t particular/${{ matrix.image-name }}:${{ needs.release.outputs.version }} -f ${{ matrix.dockerfile }} .
working-directory: src
- name: Login to Docker Hub
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
run: docker push particular/${{ matrix.image-name }}:${{ needs.release.outputs.version }}