💚 Change auto-merge method to MERGE in workflow #117
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Continuous Deployment | |
| on: | |
| push: | |
| branches: | |
| - main # main 브랜치로의 모든 push 이벤트 (PR 병합 포함) 에 실행 | |
| workflow_dispatch: | |
| repository_dispatch: | |
| types: [dependabot-auto-merged, non-dependabot-auto-merged] | |
| permissions: | |
| contents: write | |
| discussions: write | |
| jobs: | |
| deploy: | |
| runs-on: windows-2022 | |
| # Only run if this was triggered by a push OR if the CI workflow completed successfully OR repository_dispatch | |
| if: github.event_name == 'push' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-tags: true | |
| fetch-depth: 0 | |
| # If triggered by workflow_run, checkout the specific commit that was tested | |
| ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }} | |
| - name: Get USERPROFILE and set CACHE_PATH | |
| id: set_cache_path | |
| shell: pwsh | |
| run: | | |
| $cachePath = "$env:USERPROFILE\.nuget\packages" | |
| echo "CACHE_PATH=$cachePath" >> $env:GITHUB_ENV | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.nuget/packages | |
| ${{ env.CACHE_PATH }} | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore dependencies | |
| run: dotnet restore simple-.net-Crypting-For-PowerBuilder.slnx | |
| - name: Build solution for release (without tests) | |
| run: dotnet publish simple-.net-Crypting-For-PowerBuilder.slnx --configuration Release | |
| - 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: | | |
| New-Item -ItemType Directory -Path ${{ github.workspace }}\release-files -Force | |
| # Merge NET 4.8 PB DLLs (using ILRepack) | |
| ilrepack /out:${{ github.workspace }}\release-files\SecureLibrary-PB.dll ` | |
| /lib:${{ github.workspace }}\net481PB\bin\Release\net481\publish ` | |
| /targetplatform:"v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319" ` | |
| /union ` | |
| /copyattrs ` | |
| /internalize ` | |
| /keyfile:${{ github.workspace }}\Simple-Crypt4PB.snk ` | |
| ${{ github.workspace }}\net481PB\bin\Release\net481\publish\SecureLibrary.dll ` | |
| ${{ github.workspace }}\net481PB\bin\Release\net481\publish\BCrypt.Net-Next.dll ` | |
| ${{ github.workspace }}\net481PB\bin\Release\net481\publish\System.Buffers.dll ` | |
| ${{ github.workspace }}\net481PB\bin\Release\net481\publish\System.Memory.dll ` | |
| ${{ github.workspace }}\net481PB\bin\Release\net481\publish\System.Numerics.Vectors.dll ` | |
| ${{ github.workspace }}\net481PB\bin\Release\net481\publish\System.Runtime.CompilerServices.Unsafe.dll | |
| # Merge NET 4.8 SQL DLLs (using ILMerge) | |
| ${{ github.workspace }}\packages\ILMerge.3.0.41\tools\net452\ILMerge.exe ` | |
| /lib:${{ github.workspace }}\net481SQL-server\bin\Release\net481\publish ` | |
| /out:${{ github.workspace }}\release-files\SecureLibrary-SQL.dll ` | |
| /keyfile:${{ github.workspace }}\Simple-Crypt4PB.snk ` | |
| ${{ github.workspace }}\net481SQL-server\bin\Release\net481\publish\SecureLibrary.SQL.dll ` | |
| ${{ github.workspace }}\net481SQL-server\bin\Release\net481\publish\BCrypt.Net-Next.dll ` | |
| ${{ github.workspace }}\net481SQL-server\bin\Release\net481\publish\System.Buffers.dll ` | |
| ${{ github.workspace }}\net481SQL-server\bin\Release\net481\publish\System.Memory.dll ` | |
| ${{ github.workspace }}\net481SQL-server\bin\Release\net481\publish\System.Numerics.Vectors.dll ` | |
| ${{ github.workspace }}\net481SQL-server\bin\Release\net481\publish\System.Runtime.CompilerServices.Unsafe.dll ` | |
| ${{ github.workspace }}\net481SQL-server\bin\Release\net481\publish\Microsoft.SqlServer.Server.dll | |
| # Merge NET 8 DLLs (using ILRepack) | |
| ilrepack /out:${{ github.workspace }}\release-files\SecureLibrary-Core.dll ` | |
| /union ` | |
| /internalize ` | |
| /keyfile:${{ github.workspace }}\Simple-Crypt4PB.snk ` | |
| ${{ github.workspace }}\NET8\bin\Release\net8.0\publish\SecureLibrary-Core.dll ` | |
| ${{ github.workspace }}\NET8\bin\Release\net8.0\publish\BCrypt.Net-Next.dll | |
| # copy Comhost and runtimeconfig.json to release-files | |
| Copy-Item ${{ github.workspace }}\NET8\bin\Release\net8.0\publish\SecureLibrary-Core.comhost.dll ${{ github.workspace }}\release-files\SecureLibrary-Core.comhost.dll | |
| Copy-Item ${{ github.workspace }}\NET8\bin\Release\net8.0\publish\SecureLibrary-Core.runtimeconfig.json ${{ github.workspace }}\release-files\SecureLibrary-Core.runtimeconfig.json | |
| - 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\SecureLibrary-Core.dll | |
| ${{ github.workspace }}\release-files\SecureLibrary-Core.comhost.dll | |
| ${{ github.workspace }}\release-files\SecureLibrary-Core.runtimeconfig.json | |
| tag_name: ${{ env.new_release }} | |
| name: ${{ env.new_release }} | |
| body: ${{ env.release_notes }} | |