Skip to content

Continuous Deployment #103

Continuous Deployment

Continuous Deployment #103

Workflow file for this run

name: Continuous Deployment
on:
workflow_run:
workflows: ["CI tests"]
types:
- completed
branches: [ "main" ]
permissions:
contents: write
discussions: write
jobs:
deploy:
# Only run if CI workflow was successful
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: windows-2022
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.sln*', '**/*.csproj*') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: nuget restore -PackagesDirectory ${{ github.workspace }}\packages
- name: Copy dependencies
run: |
Copy-Item -Path ${{ github.workspace }}\packages -Destination ${{ github.workspace }}\net481pb -Recurse
Copy-Item -Path ${{ github.workspace }}\packages -Destination ${{ github.workspace }}\net481SQL-server -Recurse
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build solution for release (without tests)
run: |
msbuild "simple-.net-Crypting-For-PowerBuilder.sln" /p:Configuration=Release
dotnet publish "D:\a\simple-.net-Crypting-For-PowerBuilder\simple-.net-Crypting-For-PowerBuilder\NET8\NET8.csproj" --configuration Release --arch x64
- name: Install ILMerge and ILRepack
run: |
nuget install ILMerge -Version 3.0.41 -OutputDirectory ${{ github.workspace }}\packages
dotnet tool install -g dotnet-ilrepack
- name: Merge and Create Release Files
run: |
# Merge NET 4.8 PB DLLs (using ILRepack)
ilrepack /out:${{ github.workspace }}\net481PB\bin\Release\SecureLibrary-PB-Merged.dll `
/lib:${{ github.workspace }}\net481PB\bin\Release `
/targetplatform:"v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319" `
/union `
/copyattrs `
/internalize `
${{ github.workspace }}\net481PB\bin\Release\SecureLibrary.dll `
${{ github.workspace }}\net481PB\bin\Release\BCrypt.Net-Next.dll `
${{ github.workspace }}\net481PB\bin\Release\System.Buffers.dll `
${{ github.workspace }}\net481PB\bin\Release\System.Memory.dll `
${{ github.workspace }}\net481PB\bin\Release\System.Numerics.Vectors.dll `
${{ github.workspace }}\net481PB\bin\Release\System.Runtime.CompilerServices.Unsafe.dll
# Merge NET 4.8 SQL DLLs (using ILMerge)
${{ github.workspace }}\packages\ILMerge.3.0.41\tools\net452\ILMerge.exe /out:${{ github.workspace }}\net481SQL-server\bin\Release\SecureLibrary-SQL-Merged.dll `
${{ github.workspace }}\net481SQL-server\bin\Release\SecureLibrary.SQL.dll `
${{ github.workspace }}\net481SQL-server\bin\Release\BCrypt.Net-Next.dll `
${{ github.workspace }}\net481SQL-server\bin\Release\System.Buffers.dll `
${{ github.workspace }}\net481SQL-server\bin\Release\System.Memory.dll `
${{ github.workspace }}\net481SQL-server\bin\Release\System.Numerics.Vectors.dll `
${{ github.workspace }}\net481SQL-server\bin\Release\System.Runtime.CompilerServices.Unsafe.dll `
${{ github.workspace }}\net481SQL-server\bin\Release\Microsoft.SqlServer.Server.dll
# Merge NET 8 DLLs (using ILRepack)
ilrepack /out:${{ github.workspace }}\NET8\bin\Release\net8.0\win-x64\NET8.dll `
/union `
/internalize `
${{ github.workspace }}\NET8\bin\Release\net8.0\win-x64\publish\NET8.dll `
${{ github.workspace }}\NET8\bin\Release\net8.0\win-x64\publish\BCrypt.Net-Next.dll
# Copy all release files to a single directory for easier release
New-Item -ItemType Directory -Path ${{ github.workspace }}\release-files -Force
Copy-Item ${{ github.workspace }}\net481PB\bin\Release\SecureLibrary-PB-Merged.dll ${{ github.workspace }}\release-files\SecureLibrary-PB.dll
Copy-Item ${{ github.workspace }}\net481SQL-server\bin\Release\SecureLibrary-SQL-Merged.dll ${{ github.workspace }}\release-files\SecureLibrary-SQL.dll
Copy-Item ${{ github.workspace }}\NET8\bin\Release\net8.0\win-x64\NET8.dll ${{ github.workspace }}\release-files\NET8.dll
- name: Get latest release version and Generate release notes
id: get_latest_release
run: |
$latest_release = (Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/releases/latest").tag_name
Write-Output "Latest release version: $latest_release"
echo "latest_release=$latest_release" >> $env:GITHUB_ENV
$versionParts = $latest_release.Split('.')
$versionParts[-1] = [int]$versionParts[-1] + 1
$newVersionString = $versionParts -join '.'
echo "new_release=$newVersionString" >> $env:GITHUB_ENV
$releaseNotes = "## Changes in " + $latest_release + "`n"
$releaseNotes += (git log HEAD ^$latest_release --oneline) -join "`n"
$releaseNotes += "`n"
$releaseNotes += "### File edited `n"
$releaseNotes += "`n"
$releaseNotes += (git diff HEAD ^$latest_release --compact-summary) -join "`n"
$releaseNotes | Out-File -FilePath releaseNotes.txt -Encoding utf8
$releaseNotesContent = Get-Content -Path releaseNotes.txt -Raw
echo "release_notes<<EOF" >> $env:GITHUB_ENV
echo "$releaseNotesContent" >> $env:GITHUB_ENV
echo "EOF" >> $env:GITHUB_ENV
- name: Explicit Version Order apply to create release
run: |
$latestCommitMessage = (git log -1 --pretty=%B)
foreach ($line in $latestCommitMessage) {
if ($line -match "Update Version to (\d+\.\d+\.\d+)") {
$messageParts = $line -split ' '
$lastPart = $messageParts[-1]
echo "new_release=$lastPart" >> $env:GITHUB_ENV
}
}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
${{ github.workspace }}\release-files\SecureLibrary-PB.dll
${{ github.workspace }}\release-files\SecureLibrary-SQL.dll
${{ github.workspace }}\release-files\NET8.dll
${{ github.workspace }}\release-files\NET8.comhost.dll
tag_name: ${{ env.new_release }}
name: ${{ env.new_release }}
body: ${{ env.release_notes }}