forked from PowerShell/AIShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease-publish-github.yml
More file actions
173 lines (156 loc) · 5.92 KB
/
Copy pathrelease-publish-github.yml
File metadata and controls
173 lines (156 loc) · 5.92 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
parameters:
- name: publish
default: false
type: boolean
jobs:
- job: GithubReleaseDraft
displayName: Create GitHub Release Draft
condition: succeeded()
pool:
type: release
os: windows
templateContext:
inputs:
- input: pipelineArtifact
pipeline: AIShellPackagePipeline
artifactName: drop_windows_package_arm64
- input: pipelineArtifact
pipeline: AIShellPackagePipeline
artifactName: drop_windows_package_x64
- input: pipelineArtifact
pipeline: AIShellPackagePipeline
artifactName: drop_windows_package_x86
- input: pipelineArtifact
pipeline: AIShellPackagePipeline
artifactName: drop_linux_package_arm64
- input: pipelineArtifact
pipeline: AIShellPackagePipeline
artifactName: drop_linux_package_x64
- input: pipelineArtifact
pipeline: AIShellPackagePipeline
artifactName: macos-pkgs
variables:
- name: ob_outputDirectory
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
- name: ob_sdl_tsa_configFile
value: $(Build.SourcesDirectory)\AIShell\.config\tsaoptions.json
steps:
- task: PowerShell@2
inputs:
targetType: inline
script: |
Get-ChildItem Env: | Out-String -Width 500
displayName: 'Capture Environment Variables'
- task: PowerShell@2
inputs:
targetType: inline
script: |
$packagesRoot = '$(Pipeline.Workspace)/release'
$null = New-Item -ItemType Directory -Path $packagesRoot
Get-ChildItem -Path '$(Pipeline.Workspace)/*' -Include *.zip,*.tar.gz |
Copy-Item -Destination $packagesRoot -Force -Verbose
Write-Verbose -Verbose "List all packages to be published to GitHub release page:"
Get-ChildItem -Path $packagesRoot | Out-String -Width 500
$vstsCommandString = "vso[task.setvariable variable=PackagesRoot]$packagesRoot"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: Capture downloaded artifacts
- task: PowerShell@2
inputs:
targetType: inline
script: |
$hashPath = Join-Path $(PackagesRoot) 'hashes.sha256'
$checksums = Get-ChildItem -Path $(PackagesRoot) |
ForEach-Object {
$packageName = $_.Name
$fullPath = $_.FullName
Write-Verbose -Verbose "Generating checksum for $fullPath"
$hash = (Get-FileHash -Path $fullPath -Algorithm SHA256).Hash.ToLower()
# the '*' before the packagename signifies it is a binary
"$hash *$packageName"
}
$checksums | Out-File -FilePath $hashPath -Force
Get-Content -Path $hashPath -Raw | Out-String -Width 500
displayName: Add sha256 hashes
- task: PowerShell@2
inputs:
targetType: inline
script: |
$macX64File = (Get-Item "$(PackagesRoot)/AIShell-*-osx-x64.tar.gz").Name
$releaseVersion = $macX64File.Replace("AIShell-", "").Replace("-osx-x64.tar.gz", "")
$vstsCommandString = "vso[task.setvariable variable=ReleaseVersion]$releaseVersion"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: 'Set release version'
- task: PowerShell@2
inputs:
targetType: inline
script: |
$content = '<!-- TODO: Generate release notes on GitHub! -->'
$StringBuilder = [System.Text.StringBuilder]::new($content, $content.Length + 2kb)
$StringBuilder.AppendLine().AppendLine() > $null
$StringBuilder.AppendLine("#### SHA256 Hashes of the release artifacts").AppendLine() > $null
Get-ChildItem -Path $(PackagesRoot) -File | ForEach-Object {
$PackageName = $_.Name
$SHA256 = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
$StringBuilder.AppendLine("- $PackageName").AppendLine(" - $SHA256") > $null
}
$content = $StringBuilder.ToString()
Write-Verbose -Verbose "Selected content: `n$content"
$releaseNotesFilePath = "$(Pipeline.Workspace)/release-notes.md"
$content | Out-File -FilePath $releaseNotesFilePath -Encoding utf8
Write-Host "##vso[task.setvariable variable=ReleaseNotesFilePath;]$releaseNotesFilePath"
# If it's prelease then make prerelease true as a variable
if ('$(ReleaseVersion)' -like '*-*') {
Write-Host "##vso[task.setvariable variable=IsPreRelease;]true"
} else {
Write-Host "##vso[task.setvariable variable=IsPreRelease;]false"
}
displayName: Set variables for GitHub release task
- task: PowerShell@2
inputs:
targetType: inline
script: |
Write-Host "ReleaseNotes content:"
Get-Content $(ReleaseNotesFilePath) | Out-String -width 500
displayName: Verify Release Notes
- task: GitHubRelease@1
displayName: 'Publish Release Draft'
condition: and(ne('${{ parameters.publish }}', 'false'), succeeded())
inputs:
gitHubConnection: ReleaseToAIShellRepo
repositoryName: PowerShell/AIShell
target: main
assets: '$(PackagesRoot)/*'
tagSource: 'userSpecifiedTag'
tag: 'v$(ReleaseVersion)'
title: 'v$(ReleaseVersion) Release of AIShell'
isDraft: true
addChangeLog: false
action: 'create'
releaseNotesFilePath: '$(ReleaseNotesFilePath)'
isPrerelease: '$(IsPreRelease)'
- job: PushGitTag
dependsOn: GithubReleaseDraft
displayName: Push Git Tag
pool:
type: server
timeoutInMinutes: 1440
steps:
- task: ManualValidation@0
displayName: Push Git Tag
inputs:
instructions: Push the git tag to upstream
timeoutInMinutes: 1440
- job: DraftPublic
dependsOn: PushGitTag
displayName: Make Draft Public
pool:
type: server
timeoutInMinutes: 1440
steps:
- task: ManualValidation@0
displayName: Make Draft Public
inputs:
instructions: Make the GitHub Release Draft Public
timeoutInMinutes: 1440