Skip to content

July 2025 Release SP3 #24

July 2025 Release SP3

July 2025 Release SP3 #24

Workflow file for this run

name: Release
on:
release:
types: [published]
jobs:
buildlinux:
name: "Release"
env:
ASPNETCORE_ENVIRONMENT: "Production"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Install NET 9
uses: actions/setup-dotnet@v4.0.1
with:
dotnet-version: '9.0.x'
- name: Restore Nuget Packages
run: dotnet restore MobileConfiguration.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}
- name: Build Code
run: dotnet build MobileConfiguration.sln --configuration Release
#- name: Run Unit Tests
# run: |
# echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
# dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj"
- name: Publish Images to Docker Hub - Pre Release
if: ${{ github.event.release.prerelease == true }}
run: |
docker build . --file MobileConfiguration/Dockerfile --tag stuartferguson/mobileconfiguration:dev
docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }}
docker push stuartferguson/mobileconfiguration:dev
- name: Publish Images to Docker Hub - Formal Release
if: ${{ github.event.release.prerelease == false }}
run: |
docker build . --file MobileConfiguration/Dockerfile --tag stuartferguson/mobileconfiguration:latest
docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }}
docker push stuartferguson/mobileconfiguration:latest
- name: Publish API
if: ${{ github.event.release.prerelease == false }}
run: dotnet publish "MobileConfiguration\MobileConfiguration.csproj" --configuration Release --output publishOutput -r linux-x64 --self-contained
- name: Build Release Package
run: |
cd /home/runner/work/MobileConfiguration/MobileConfiguration/publishOutput
zip -r ../mobileconfiguration.zip ./*
- name: Upload the artifact
uses: actions/upload-artifact@4.4.0
with:
name: mobileconfiguration
path: mobileconfiguration.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.MYGET_APIKEY }} --source https://www.myget.org/F/transactionprocessing/api/v2/package
deploystaging:
runs-on: [stagingserver, linux]
needs: buildlinux
environment: staging
name: "Deploy to Staging"
steps:
- name: Download the artifact
uses: actions/download-artifact@v4.1.8
with:
name: mobileconfiguration
path: /tmp/mobileconfiguration # Download to a temporary directory
- name: Remove existing service (if applicable)
run: |
SERVICE_NAME="mobileconfiguration"
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo "Stopping existing service..."
sudo systemctl stop "$SERVICE_NAME"
fi
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
echo "Disabling existing service..."
sudo systemctl disable "$SERVICE_NAME"
fi
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
echo "Removing existing service unit file..."
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
sudo systemctl daemon-reload
fi
- name: Unzip the files
run: |
sudo mkdir -p /opt/txnproc/transactionprocessing/mobileconfiguration
sudo unzip -o /tmp/mobileconfiguration/mobileconfiguration.zip -d /opt/txnproc/transactionprocessing/mobileconfiguration
# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
# This assumes it's not already there. If your base image already has it, you can skip this.
- name: Install .NET Runtime
run: |
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
# and if you need the SDK or just the runtime.
# This uses Microsoft's package repository for the latest versions.
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y aspnetcore-runtime-9.0
- name: Install and Start as a Linux service
run: |
SERVICE_NAME="mobileconfiguration"
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/mobileconfiguration"
DLL_NAME="MobileConfiguration.dll" # Your application's DLL
SERVICE_DESCRIPTION="Transaction Processing - Mobile Configuration"
# Create a systemd service file
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# IMPORTANT: Use 'dotnet' to run your DLL
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# Reload systemd, enable, and start the service
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification
deployproduction:
runs-on: [productionserver, linux]
needs: [buildlinux, deploystaging]
environment: production
name: "Deploy to Production"
steps:
- name: Download the artifact
uses: actions/download-artifact@v4.1.8
with:
name: mobileconfiguration
path: /tmp/mobileconfiguration # Download to a temporary directory
- name: Remove existing service (if applicable)
run: |
SERVICE_NAME="mobileconfiguration"
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo "Stopping existing service..."
sudo systemctl stop "$SERVICE_NAME"
fi
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
echo "Disabling existing service..."
sudo systemctl disable "$SERVICE_NAME"
fi
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
echo "Removing existing service unit file..."
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
sudo systemctl daemon-reload
fi
- name: Unzip the files
run: |
sudo mkdir -p /opt/txnproc/transactionprocessing/mobileconfiguration
sudo unzip -o /tmp/mobileconfiguration/mobileconfiguration.zip -d /opt/txnproc/transactionprocessing/mobileconfiguration
# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
# This assumes it's not already there. If your base image already has it, you can skip this.
- name: Install .NET Runtime
run: |
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
# and if you need the SDK or just the runtime.
# This uses Microsoft's package repository for the latest versions.
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y aspnetcore-runtime-9.0
- name: Install and Start as a Linux service
run: |
SERVICE_NAME="mobileconfiguration"
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/mobileconfiguration"
DLL_NAME="MobileConfiguration.dll" # Your application's DLL
SERVICE_DESCRIPTION="Transaction Processing - Mobile Configuration"
# Create a systemd service file
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# IMPORTANT: Use 'dotnet' to run your DLL
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# Reload systemd, enable, and start the service
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification