-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (104 loc) · 5.51 KB
/
pipeline.yml
File metadata and controls
124 lines (104 loc) · 5.51 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
name: SQL CLR Build
on:
workflow_dispatch:
inputs:
create_release:
description: 'Create Release'
required: true
default: 'true'
jobs:
build:
runs-on:
windows-latest # For a list of available runner types, refer to https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
env:
Solution_Name: "${{ github.workspace }}\\SqlServer.ClrCommon.sln" # Replace with your solution name, i.e. MyWpfApp.sln.
Test_Project_Path: "${{ github.workspace }}\\SqlServer.ClrCommon.Tests\\SqlServer.ClrCommon.Tests.csproj" # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.
configuration: Release
configuration45: Release4.5
binary_file: SqlServer.ClrCommon.dll
dacpac_file: SqlServer.ClrCommon.dacpac
bin_path: ${{ github.workspace }}\\SqlServer.ClrCommon\\bin
database_name: CommonDB
create_release: ${{ github.event.inputs.create_release }}
steps:
- name: SplitRepoName
shell: powershell
run: |
$repoVals = "${{github.repository}}" -split '/', 2
echo "REPO_OWNER=$($repoVals[0])" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "REPO_NAME=$($repoVals[1])" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
#- name: List Environment Variables
# shell: powershell
# run: dir env:* | Sort-Object Name
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x" # SDK Version to use; x will use the latest version of the 5.0 channel
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.0.2
# Execute all unit tests in the solution
#- name: Execute unit tests
# run: dotnet test
# https://archi-lab.net/code-signing-assemblies-with-github-actions/
- name: Create Code Signing Certificate
shell: powershell
run: |
New-Item -ItemType directory -Path certificate
Set-Content -Path certificate\certificate.txt -Value '${{ secrets.BASE64_ENCODED_PFX }}'
certutil -decode certificate\certificate.txt certificate\certificate.pfx
# Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Build the application
run: |
msbuild $env:Solution_Name /target:ReBuild /interactive:false /nologo /p:platform="any cpu" /p:configuration="$env:configuration" /clp:Summary /m
msbuild $env:Solution_Name /target:ReBuild /interactive:false /nologo /p:platform="any cpu" /p:configuration="$env:configuration45" /clp:Summary /m
- name: Code Sign The DLL
shell: powershell
run: |
$moduleName = "EnterDeveloperPowerShell"
$module = Get-InstalledModule $moduleName -ErrorAction SilentlyContinue
if (-not $module) {
Write-Host "Installing module: $moduleName"
Install-Module -Name $moduleName -Force
}
Import-Module $moduleName
Enter-VisualStudioDeveloperShell
. signtool.exe sign /f certificate\certificate.pfx /p '${{ secrets.CODE_SIGN_PASSWORD }}' /t http://timestamp.comodoca.com/authenticode "$env:bin_path\\$env:configuration\\$env:binary_file"
. signtool.exe sign /f certificate\certificate.pfx /p '${{ secrets.CODE_SIGN_PASSWORD }}' /t http://timestamp.comodoca.com/authenticode "$env:bin_path\\$env:configuration45\\$env:binary_file"
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v5.6
if: ${{ github.ref == 'refs/heads/master' && env.create_release == 'true' }}
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
- name: Generate The Setup Script
shell: powershell
if: ${{ github.ref == 'refs/heads/master' && env.create_release == 'true' }}
run: |
.\.github\workflows\generate_setup_script.ps1 `
-dacpacPath "$env:bin_path\\$env:configuration\\$env:dacpac_file" `
-binaryPath "$env:bin_path\\$env:configuration\\$env:binary_file" `
-pfxPath "${{ github.workspace }}\\certificate\certificate.pfx" `
-databaseName "$env:database_name" `
-releasePath "${{ github.workspace }}\\$($env:REPO_NAME).${{ steps.tag_version.outputs.new_tag }}.zip"
.\.github\workflows\generate_setup_script.ps1 `
-dacpacPath "$env:bin_path\\$env:configuration45\\$env:dacpac_file" `
-binaryPath "$env:bin_path\\$env:configuration45\\$env:binary_file" `
-pfxPath "${{ github.workspace }}\\certificate\certificate.pfx" `
-databaseName "$env:database_name" `
-releasePath "${{ github.workspace }}\\$($env:REPO_NAME).${{ steps.tag_version.outputs.new_tag }}.zip"
# Remove the pfx
- name: Remove the pfx
shell: powershell
run: Get-ChildItem -Path "certificate\" -File | Remove-Item -Force -Verbose
- name: Create Release
uses: ncipollo/release-action@v1
if: ${{ github.ref == 'refs/heads/master' && env.create_release == 'true' }}
with:
artifacts: "${{ github.workspace }}\\${{ env.REPO_NAME }}.${{ steps.tag_version.outputs.new_tag }}.zip"
token: "${{ secrets.GITHUB_TOKEN }}"
tag: "${{ steps.tag_version.outputs.new_tag }}"