/
action.yml
133 lines (125 loc) · 5.92 KB
/
action.yml
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
125
126
127
128
129
130
131
132
133
name: Push package to Octopus Deploy
description: 'Creates and pushes build output to Octopus Deploy for deployment.'
inputs:
octopus-deploy-api-key:
description: 'API key for Octopus Deploy, which should already be masked as a secret'
required: true
additional-metadata-paths:
description: 'Additional metadata files that should be copied to the root of the deployment package. File patterns are supported, one pattern per line.'
required: false
default: ''
runs:
using: "composite"
steps:
- name: Verify NuGet package signatures
run: Get-ChildItem -Recurse -File nugets -Filter *.nupkg -ErrorAction:Ignore | foreach {dotnet nuget verify $_.FullName}
shell: pwsh
- name: Setup signtool environment variable
if: runner.os == 'Windows'
run: |
$sdkMajor = Get-ChildItem 'C:\Program Files (x86)\Windows Kits\[0-9]*' | Select-Object -Property Name, @{Name = 'SortIndex'; Expression = {[int]$_.Name} } | Sort-Object -Descending -Property SortIndex | Select-Object -ExpandProperty Name -First 1
$sdkVersion = Get-ChildItem "C:\Program Files (x86)\Windows Kits\$sdkMajor\bin\[0-9]*" | Sort-Object -Descending $_.FullName | Select-Object -ExpandProperty Name -First 1
$signTool = "C:\Program Files (x86)\Windows Kits\{0}\bin\{1}\x64\signtool.exe" -f $sdkMajor,$sdkVersion
if (Test-Path -Path $signTool) {
echo "SIGNTOOL=$signTool" >> $Env:GITHUB_ENV
}
else {
echo "Sign tool not found"
exit 1
}
shell: pwsh
- name: Verify executable signatures
if: runner.os == 'Windows'
run: Get-ChildItem -Recurse -File assets -Filter *.exe -ErrorAction:Ignore | foreach {& "$($Env:SIGNTOOL)" verify /pa $_.FullName}
shell: pwsh
- name: Verify catalog file signatures
if: runner.os == 'Windows'
run: Get-ChildItem -Recurse -File deploy -Filter *.cat -ErrorAction:Ignore | foreach {& "$($Env:SIGNTOOL)" verify /pa $_.FullName}
shell: pwsh
- name: Create the files
env:
ADDITIONAL_METADATA_PATHS: ${{ inputs.additional-metadata-paths }}
run: |
# Check for required environment variables
Write-Output "Looking in env vars for version info, found Version ${{env.MinVerVersion}}, Major ${{env.MinVerMajor}}, Minor ${{env.MinVerMinor}}"
if ($env.MinVerVersion && $env.MinVerMajor && $env.MinVerMinor) {
Write-Output "Version info OK"
} else {
throw "Version information from build not found in environment variables."
}
# Parse repo name
$RepoFullName = "$env:GITHUB_REPOSITORY"
$Org,$RepoName = $RepoFullName.Split('/')
# Octopus actions will need the value in an environment variable
echo "PARTICULAR_REPO_NAME=$RepoName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Creating the expected file layout for the Octopus package, including intermediate directories
mkdir -p packaging/content
# Include NuGet packages in the `nugets` folder
# Octopus expects NuGet packages to have an extra .nzip extension for NuGet, .czip for Chocolatey
if (Test-Path -Path nugets) {
$nugets = Get-ChildItem -Path "./nugets/*.nupkg"
foreach ($file in $nugets) {
Copy-Item $file "./packaging/content/$($file.Name).nzip"
}
}
# Include executables in the `assets` folder - used for ServiceControl, ServicePulse, ServiceInsight, etc.
if (Test-Path -Path assets) {
Copy-Item -Recurse assets/* ./packaging/content
}
# Make sure we aren't creating a package with zero contents
$assetCount = (Get-ChildItem -Path ./packaging/content | Measure-Object).Count
if ($assetCount -eq 0) {
throw "No assets were found for the deployment package"
}
# Octopus Deploy scripts need an executable file to recreate this metadata
# $Branch is not really the branch name, when built from a tag it will be the tagged version string
@"
`$Branch = "${{github.ref_name}}"
`$Version = "${{env.MinVerVersion}}"
`$Product = "$RepoName"
`$Major = "${{env.MinVerMajor}}"
`$Minor = "${{env.MinVerMinor}}"
`$Commit = "${{github.sha}}"
"@ > packaging/Metadata.ps1
if ($env:ADDITIONAL_METADATA_PATHS) {
$patterns = ($env:ADDITIONAL_METADATA_PATHS -split '[\r\n]') -ne ''
$patterns | ForEach-Object {
Copy-Item $_ packaging
}
}
shell: pwsh
- name: Create an Octopus NuGet deployment package
id: package
uses: OctopusDeploy/create-nuget-package-action@v3.1.1
with:
package_id: ${{env.PARTICULAR_REPO_NAME}}.Deploy
version: ${{env.MinVerVersion}}
output_folder: octopus-package
base_path: packaging
files: |
**/*.*
nuspec_description: Deployment package for ${{env.PARTICULAR_REPO_NAME}} - not for nuget.org
nuspec_authors: Particular Software
- name: Publish Octopus Package Artifacts
uses: actions/upload-artifact@v4.3.3
with:
name: ${{steps.package.outputs.package_filename}}
path: ${{steps.package.outputs.package_file_path}}
retention-days: 1
- name: Push package to Octopus Deploy
uses: OctopusDeploy/push-package-action@v3.2.1
with:
server: https://deploy.particular.net
api_key: ${{ inputs.octopus-deploy-api-key }}
packages: ${{steps.package.outputs.package_file_path}}
space: "Default"
- name: Create Octopus Deploy release
uses: OctopusDeploy/create-release-action@v3.2.1
with:
server: https://deploy.particular.net
api_key: ${{ inputs.octopus-deploy-api-key }}
project: ${{env.PARTICULAR_REPO_NAME}}
release_number: ${{env.MinVerVersion}}
package_version: ${{env.MinVerVersion}}
packages: "GitReleaseManager:0.17.0"
space: "Default"