-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (112 loc) · 6.4 KB
/
createrelease.yml
File metadata and controls
137 lines (112 loc) · 6.4 KB
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
name: Release
on:
release:
types: [published]
jobs:
build:
name: "Release"
env:
ASPNETCORE_ENVIRONMENT: "Production"
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Restore Nuget Packages
run: dotnet restore TransactionProcessor.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}
- name: Build Code
run: dotnet build TransactionProcessor.sln --configuration Release
- name: Publish Images to Docker Hub - Pre Release
if: ${{ github.event.release.prerelease == true }}
run: |
docker build . --file TransactionProcessor/Dockerfile --tag stuartferguson/transactionprocessor:dev
docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }}
docker push stuartferguson/transactionprocessor:dev
- name: Publish Images to Docker Hub - Formal Release
if: ${{ github.event.release.prerelease == false }}
run: |
docker build . --file TransactionProcessor/Dockerfile --tag stuartferguson/transactionprocessor:latest
docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }}
docker push stuartferguson/transactionprocessor:latest
- name: Publish API
if: ${{ github.event.release.prerelease == false }}
run: dotnet publish "TransactionProcessor\TransactionProcessor.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained
-p:Version=${{ steps.get_version.outputs.VERSION }}
-p:AssemblyVersion=${{ steps.get_version.outputs.VERSION }}
-p:FileVersion=${{ steps.get_version.outputs.VERSION }}
-p:InformationalVersion=${{ steps.get_version.outputs.VERSION }}
- name: Build Release Package
run: |
cd /home/runner/work/TransactionProcessor/TransactionProcessor/publishOutput
zip -r ../transactionprocessor.zip ./*
- name: Upload the artifact
uses: actions/[email protected]
with:
name: transactionprocessor
path: transactionprocessor.zip
- name: Build and Publish Nuget Packages
if: ${{ github.event.release.prerelease == false }}
run: |
dotnet pack "TransactionProcessor.Client\TransactionProcessor.Client.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets
dotnet nuget push Nugets/TransactionProcessor.Client.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate
dotnet pack "TransactionProcessor.DomainEvents\TransactionProcessor.DomainEvents.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets
dotnet nuget push Nugets/TransactionProcessor.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate
dotnet pack "TransactionProcessor.IntegrationTesting.Helpers\TransactionProcessor.IntegrationTesting.Helpers.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets
dotnet nuget push Nugets/TransactionProcessor.IntegrationTesting.Helpers.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate
dotnet pack "TransactionProcessor.Database\TransactionProcessor.Database.csproj" /p:PackageVersion=${{ steps.get_version.outputs.VERSION }} --output Nugets -c Release
dotnet nuget push Nugets/TransactionProcessor.Database.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate
deploystaging:
runs-on: [stagingserver,windows]
needs: build
environment: staging
name: "Deploy to Staging"
steps:
- name: Download the artifact
uses: actions/[email protected]
with:
name: transactionprocessor
- name: Remove existing Windows service
run: |
$serviceName = "Transaction Processing - Transaction Processor"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}
- name: Unzip the files
run: |
Expand-Archive -Path transactionprocessor.zip -DestinationPath "C:\txnproc\transactionprocessing\transactionprocessor" -Force
- name: Install as a Windows service
run: |
$serviceName = "Transaction Processing - Transaction Processor"
$servicePath = "C:\txnproc\transactionprocessing\transactionprocessor\TransactionProcessor.exe"
New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic
Start-Service -Name $serviceName
deployproduction:
runs-on: [productionserver, windows]
needs: [build, deploystaging]
environment: production
name: "Deploy to Production"
steps:
- name: Download the artifact
uses: actions/[email protected]
with:
name: transactionprocessor
- name: Remove existing Windows service
run: |
$serviceName = "Transaction Processing - Transaction Processor"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}
- name: Unzip the files
run: |
Expand-Archive -Path transactionprocessor.zip -DestinationPath "C:\txnproc\transactionprocessing\transactionprocessor" -Force
- name: Install as a Windows service
run: |
$serviceName = "Transaction Processing - Transaction Processor"
$servicePath = "C:\txnproc\transactionprocessing\transactionprocessor\TransactionProcessor.exe"
New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic
Start-Service -Name $serviceName