Skip to content

Commit 014df2e

Browse files
Merge pull request #200 from TransactionProcessing/task/#199_linux_release_workflow
release workflow added for linux
2 parents 1d607fd + 01d5b95 commit 014df2e

File tree

16 files changed

+155
-206
lines changed

16 files changed

+155
-206
lines changed

.github/workflows/createrelease.yml

Lines changed: 131 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
5454
- name: Publish API
5555
if: ${{ github.event.release.prerelease == false }}
56-
run: dotnet publish "MessagingService\MessagingService.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained
56+
run: dotnet publish "MessagingService\MessagingService.csproj" --configuration Release --output publishOutput -r linux-x64 --self-contained
5757

5858
- name: Build Release Package
5959
run: |
@@ -79,7 +79,7 @@ jobs:
7979
dotnet nuget push Nugets/MessagingService.IntegrationTesting.Helpers.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate
8080
8181
deploystaging:
82-
runs-on: stagingserver
82+
runs-on: [stagingserver, linux]
8383
needs: buildlinux
8484
environment: staging
8585
name: "Deploy to Staging"
@@ -88,31 +88,77 @@ jobs:
8888
- name: Download the artifact
8989
uses: actions/[email protected]
9090
with:
91-
name: messagingservice
92-
93-
- name: Remove existing Windows service
91+
name: securityservice
92+
path: /tmp/securityservice # Download to a temporary directory
93+
94+
- name: Remove existing service (if applicable)
9495
run: |
95-
$serviceName = "Transaction Processing - Messaging Service"
96-
# Check if the service exists
97-
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
98-
Stop-Service -Name $serviceName
99-
sc.exe delete $serviceName
100-
}
101-
96+
SERVICE_NAME="securityservice"
97+
if systemctl is-active --quiet "$SERVICE_NAME"; then
98+
echo "Stopping existing service..."
99+
sudo systemctl stop "$SERVICE_NAME"
100+
fi
101+
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
102+
echo "Disabling existing service..."
103+
sudo systemctl disable "$SERVICE_NAME"
104+
fi
105+
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
106+
echo "Removing existing service unit file..."
107+
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
108+
sudo systemctl daemon-reload
109+
fi
110+
102111
- name: Unzip the files
103112
run: |
104-
Expand-Archive -Path messagingservice.zip -DestinationPath "C:\txnproc\transactionprocessing\messagingservice" -Force
105-
106-
- name: Install as a Windows service
113+
sudo mkdir -p /opt/txnproc/transactionprocessing/securityservice
114+
sudo unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice
115+
116+
# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
117+
# This assumes it's not already there. If your base image already has it, you can skip this.
118+
- name: Install .NET Runtime
119+
run: |
120+
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
121+
# and if you need the SDK or just the runtime.
122+
# This uses Microsoft's package repository for the latest versions.
123+
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
124+
sudo dpkg -i packages-microsoft-prod.deb
125+
rm packages-microsoft-prod.deb
126+
sudo apt update
127+
sudo apt install -y aspnetcore-runtime-9.0
128+
129+
- name: Install and Start as a Linux service
107130
run: |
108-
$serviceName = "Transaction Processing - Messaging Service"
109-
$servicePath = "C:\txnproc\transactionprocessing\messagingservice\MessagingService.exe"
110-
111-
New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Messaging Service" -DisplayName "Transaction Processing - Messaging Service" -StartupType Automatic
112-
Start-Service -Name $serviceName
131+
SERVICE_NAME="securityservice"
132+
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
133+
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/securityservice"
134+
DLL_NAME="SecurityService.dll" # Your application's DLL
135+
SERVICE_DESCRIPTION="Transaction Processing - Security Service"
136+
137+
# Create a systemd service file
138+
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
139+
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
140+
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
141+
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
142+
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
143+
# IMPORTANT: Use 'dotnet' to run your DLL
144+
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
145+
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
146+
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
147+
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
148+
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
149+
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
150+
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
151+
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
152+
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
153+
154+
# Reload systemd, enable, and start the service
155+
sudo systemctl daemon-reload
156+
sudo systemctl enable "$SERVICE_NAME"
157+
sudo systemctl start "$SERVICE_NAME"
158+
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification
113159

114160
deployproduction:
115-
runs-on: productionserver
161+
runs-on: [productionserver, linux]
116162
needs: [buildlinux, deploystaging]
117163
environment: production
118164
name: "Deploy to Production"
@@ -121,25 +167,71 @@ jobs:
121167
- name: Download the artifact
122168
uses: actions/[email protected]
123169
with:
124-
name: messagingservice
125-
126-
- name: Remove existing Windows service
170+
name: securityservice
171+
path: /tmp/securityservice # Download to a temporary directory
172+
173+
- name: Remove existing service (if applicable)
127174
run: |
128-
$serviceName = "Transaction Processing - Messaging Service"
129-
# Check if the service exists
130-
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
131-
Stop-Service -Name $serviceName
132-
sc.exe delete $serviceName
133-
}
134-
175+
SERVICE_NAME="securityservice"
176+
if systemctl is-active --quiet "$SERVICE_NAME"; then
177+
echo "Stopping existing service..."
178+
sudo systemctl stop "$SERVICE_NAME"
179+
fi
180+
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
181+
echo "Disabling existing service..."
182+
sudo systemctl disable "$SERVICE_NAME"
183+
fi
184+
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
185+
echo "Removing existing service unit file..."
186+
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
187+
sudo systemctl daemon-reload
188+
fi
189+
135190
- name: Unzip the files
136191
run: |
137-
Expand-Archive -Path messagingservice.zip -DestinationPath "C:\txnproc\transactionprocessing\messagingservice" -Force
138-
139-
- name: Install as a Windows service
192+
sudo mkdir -p /opt/txnproc/transactionprocessing/securityservice
193+
sudo unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice
194+
195+
# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
196+
# This assumes it's not already there. If your base image already has it, you can skip this.
197+
- name: Install .NET Runtime
198+
run: |
199+
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
200+
# and if you need the SDK or just the runtime.
201+
# This uses Microsoft's package repository for the latest versions.
202+
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
203+
sudo dpkg -i packages-microsoft-prod.deb
204+
rm packages-microsoft-prod.deb
205+
sudo apt update
206+
sudo apt install -y aspnetcore-runtime-9.0
207+
208+
- name: Install and Start as a Linux service
140209
run: |
141-
$serviceName = "Transaction Processing - Messaging Service"
142-
$servicePath = "C:\txnproc\transactionprocessing\messagingservice\MessagingService.exe"
143-
144-
New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Messaging Service" -DisplayName "Transaction Processing - Messaging Service" -StartupType Automatic
145-
Start-Service -Name $serviceName
210+
SERVICE_NAME="securityservice"
211+
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
212+
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/securityservice"
213+
DLL_NAME="SecurityService.dll" # Your application's DLL
214+
SERVICE_DESCRIPTION="Transaction Processing - Security Service"
215+
216+
# Create a systemd service file
217+
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
218+
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
219+
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
220+
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
221+
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
222+
# IMPORTANT: Use 'dotnet' to run your DLL
223+
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
224+
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
225+
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
226+
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
227+
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
228+
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
229+
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
230+
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
231+
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
232+
233+
# Reload systemd, enable, and start the service
234+
sudo systemctl daemon-reload
235+
sudo systemctl enable "$SERVICE_NAME"
236+
sudo systemctl start "$SERVICE_NAME"
237+
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification

MessagingService.Client/MessagingService.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="ClientProxyBase" Version="2025.6.1" />
9+
<PackageReference Include="ClientProxyBase" Version="2025.6.2" />
1010
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
11-
<PackageReference Include="Shared.Results" Version="2025.6.1" />
11+
<PackageReference Include="Shared.Results" Version="2025.6.2" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
11-
<PackageReference Include="Shared.EventStore" Version="2025.6.1" />
11+
<PackageReference Include="Shared.EventStore" Version="2025.6.2" />
1212
<PackageReference Include="Shouldly" Version="4.3.0" />
1313
<PackageReference Include="xunit" Version="2.9.3" />
1414
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">

MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Shared" Version="2025.6.1" />
10-
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.6.1" />
9+
<PackageReference Include="Shared" Version="2025.6.2" />
10+
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.6.2" />
1111
</ItemGroup>
1212

1313
</Project>

MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
<ItemGroup>
88
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
9-
<PackageReference Include="Shared" Version="2025.6.1" />
10-
<PackageReference Include="Shared.EventStore" Version="2025.6.1" />
9+
<PackageReference Include="Shared" Version="2025.6.2" />
10+
<PackageReference Include="Shared.EventStore" Version="2025.6.2" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

MessagingService.IntegrationTesting.Helpers/MessagingService.IntegrationTesting.Helpers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.1" />
10+
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.2" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

MessagingService.IntegrationTests/Common/DockerHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper
5050
/// <param name="testingContext">The testing context.</param>
5151
public DockerHelper()
5252
{
53-
this.TestingContext = new TestingContext();
53+
this.TestingContext = new TestingContext();
54+
this.TestId = Guid.NewGuid();
5455
}
5556

5657
#endregion

MessagingService.IntegrationTests/Common/GenericSteps.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public GenericSteps(ScenarioContext scenarioContext,
2828
[BeforeScenario]
2929
public async Task StartSystem()
3030
{
31+
3132
// Initialise a logger
3233
String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", "");
3334
NlogLogger logger = new NlogLogger();

MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="ClientProxyBase" Version="2025.6.1" />
9+
<PackageReference Include="ClientProxyBase" Version="2025.6.2" />
1010
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
1212
<PackageReference Include="Reqnroll.Tools.MsBuild.Generation" Version="2.4.1" />
@@ -16,7 +16,7 @@
1616
<PackageReference Include="Reqnroll.NUnit" Version="2.4.1" />
1717
<PackageReference Include="SecurityService.Client" Version="2025.5.1" />
1818
<PackageReference Include="SecurityService.IntegrationTesting.Helpers" Version="2025.5.1" />
19-
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.1" />
19+
<PackageReference Include="Shared.IntegrationTesting" Version="2025.6.2" />
2020
<PackageReference Include="Shouldly" Version="4.3.0" />
2121
<PackageReference Include="coverlet.collector" Version="6.0.4">
2222
<PrivateAssets>all</PrivateAssets>
@@ -30,15 +30,20 @@
3030
<ProjectReference Include="..\MessagingService.IntegrationTesting.Helpers\MessagingService.IntegrationTesting.Helpers.csproj" />
3131
</ItemGroup>
3232

33-
<ItemGroup>
33+
<!--<ItemGroup>
3434
<Compile Update="Email\SendEmail.feature.cs">
3535
<DesignTime>True</DesignTime>
3636
</Compile>
3737
<Compile Update="SMS\SendSMS.feature.cs">
3838
<DesignTime>True</DesignTime>
3939
</Compile>
40+
</ItemGroup>-->
41+
<ItemGroup>
42+
<None Update="**\*.feature">
43+
<Generator>ReqnrollSingleFileGenerator</Generator>
44+
<LastGenOutput>%(Filename).feature.cs</LastGenOutput>
45+
</None>
4046
</ItemGroup>
41-
4247
<ItemGroup>
4348
<None Update="nlog.config">
4449
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.6.1" />
9+
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.6.2" />
1010
</ItemGroup>
1111

1212
</Project>

0 commit comments

Comments
 (0)