Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pipelines/PowerShell-Release-Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ extends:
tsaOptionsFile: .config\tsaoptions.json

stages:
- stage: setReleaseTagAndUploadTools
displayName: 'Set Release Tag and Upload Tools'
- stage: setReleaseTagAndChangelog
displayName: 'Set Release Tag and Upload Changelog'
jobs:
- template: /.pipelines/templates/release-SetTagAndTools.yml@self
- template: /.pipelines/templates/release-SetTagAndChangelog.yml@self

- stage: msixbundle
displayName: 'Create MSIX Bundle'
Expand Down Expand Up @@ -281,9 +281,9 @@ extends:
This step is required for creating GitHub draft release.

- stage: PublishGitHubRelease
displayName: Publish GitHub Release
dependsOn:
- setReleaseTagAndUploadTools
displayName: Publish GitHub and Nuget Release
dependsOn:
- setReleaseTagAndChangelog
- UpdateChangeLog
variables:
ob_release_environment: Production
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
jobs:
- job: SetTagAndTools
displayName: Set Tag and Tools
- job: setTagAndChangelog
displayName: Set Tag and Upload Changelog
condition: succeeded()
pool:
type: windows
Expand All @@ -19,32 +19,6 @@ jobs:
clean: true
env:
ob_restore_phase: true

- checkout: PSInternalTools
clean: true
env:
ob_restore_phase: true

- pwsh: |
New-Item -ItemType Directory -Path '$(Pipeline.Workspace)/ToolArtifact'
Get-ChildItem -Path '$(Build.SourcesDirectory)/Internal-PowerShellTeam-Tools/Scripts' -Filter 'GitHubRelease.psm1' -ErrorAction SilentlyContinue |
Copy-Item -Destination '$(Pipeline.Workspace)/ToolArtifact' -Verbose
displayName: Move GitHub Tool
- task: onebranch.pipeline.signing@1
displayName: Sign Tools
inputs:
command: 'sign'
signing_profile: internal_azure_service
files_to_sign: '*.ps1;*.psm1'
search_root: '$(Pipeline.Workspace)/ToolArtifact'

- pwsh: |
Write-Verbose -Verbose "Creating output directory for release tools: $(ob_outputDirectory)/ToolArtifact"
New-Item -Path $(ob_outputDirectory)/ToolArtifact -ItemType Directory -Force
Get-ChildItem -Path "$(Pipeline.Workspace)/ToolArtifact/*" -Recurse |
Copy-Item -Destination $(ob_outputDirectory)/ToolArtifact -Recurse -Verbose
displayName: Upload Tools

- pwsh: |
Write-Verbose -Verbose "Release Tag: $(OutputReleaseTag.releaseTag)"
Expand Down
89 changes: 84 additions & 5 deletions .pipelines/templates/release-githubtasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
templateContext:
inputs:
- input: pipelineArtifact
artifactName: drop_setReleaseTagAndUploadTools_SetTagAndTools
artifactName: drop_setReleaseTagAndChangelog_SetTagAndChangelog
- input: pipelineArtifact
pipeline: PSPackagesOfficial
artifactName: drop_upload_upload_packages
variables:
- template: ./variable/release-shared.yml@self
parameters:
RELEASETAG: $[ stageDependencies.setReleaseTagAndUploadTools.SetTagAndTools.outputs['OutputReleaseTag.releaseTag'] ]
RELEASETAG: $[ stageDependencies.setReleaseTagAndChangelog.setTagAndChangelog.outputs['OutputReleaseTag.releaseTag'] ]

steps:
- task: PowerShell@2
Expand Down Expand Up @@ -62,7 +62,6 @@ jobs:
targetType: inline
pwsh: true
script: |
Import-module '$(Pipeline.Workspace)/ToolArtifact/GitHubRelease.psm1'
$releaseVersion = '$(ReleaseTag)' -replace '^v',''
Write-Verbose -Verbose "Available modules: "
Get-Module | Write-Verbose -Verbose
Expand All @@ -84,5 +83,85 @@ jobs:

Write-Verbose -Verbose "Selected content: `n$clContent"

Publish-ReleaseDraft -Tag '$(ReleaseTag)' -Name '$(ReleaseTag) Release of PowerShell' -Description $clContent -User PowerShell -Repository PowerShell -PackageFolder "$(Pipeline.Workspace)/GitHubPackages" -Token $(GitHubReleasePat)
displayName: Publish Release Draft
$releaseNotesFilePath = "$(Pipeline.Workspace)/release-notes.md"
$clContent | Out-File -FilePath $releaseNotesFilePath -Encoding utf8

Write-Host "##vso[task.setvariable variable=ReleaseNotesFilePath;]$releaseNotesFilePath"

#if name has 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

- pwsh: |
Write-Host "ReleaseNotes content:"
Get-Content "$(Pipeline.Workspace)/release-notes.md" -Raw | Out-String -width 9999 | Write-Host
displayName: Verify Release Notes

- task: GitHubRelease@1
inputs:
gitHubConnection: GitHubReleasePAT
repositoryName: PowerShell/PowerShell
target: master
assets: '$(Pipeline.Workspace)/GitHubPackages/*'
tagSource: 'userSpecifiedTag'
tag: '$(ReleaseTag)'
isDraft: true
addChangeLog: false
action: 'create'
releaseNotesFilePath: '$(ReleaseNotesFilePath)'
isPrerelease: '$(IsPreRelease)'

- job: NuGetPublish
displayName: Publish to NuGet
condition: succeeded()
pool:
type: release
os: windows
templateContext:
inputs:
- input: pipelineArtifact
pipeline: PSPackagesOfficial
artifactName: drop_upload_upload_packages
variables:
- template: ./variable/release-shared.yml@self
parameters:
VERSION: $[ stageDependencies.setReleaseTagAndChangelog.SetTagAndChangelog.outputs['OutputVersion.Version'] ]

steps:
- template: release-install-pwsh.yml

- pwsh: |
Write-Verbose -Verbose "Version: $(Version)"
Get-ChildItem Env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
displayName: 'Capture Environment Variables'

- pwsh: |
#Exclude all global tool packages. Their names start with 'PowerShell.'
$null = New-Item -ItemType Directory -Path "$(Pipeline.Workspace)/release"
Copy-Item "$(Pipeline.Workspace)/NuGetPackages/*.nupkg" -Destination "$(Pipeline.Workspace)/release" -Exclude "PowerShell.*.nupkg" -Force -Verbose

$releaseVersion = '$(Version)'
$globalToolPath = "$(Pipeline.Workspace)/NuGetPackages/PowerShell.$releaseVersion.nupkg"

if ($releaseVersion -notlike '*-*') {
# Copy the global tool package for stable releases
Copy-Item $globalToolPath -Destination "$(Pipeline.Workspace)/release"
}

Write-Verbose -Verbose "The .nupkgs below will be pushed:"
Get-ChildItem "$(Pipeline.Workspace)/release" -recurse
displayName: Download and capture nupkgs
condition: and(ne('${{ parameters.skipPublish }}', 'false'), succeeded())

- task: NuGetCommand@2
displayName: 'NuGet push'
condition: and(ne('${{ parameters.skipPublish }}', 'false'), succeeded())
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/release/*.nupkg'
nuGetFeedType: external
publishFeedCredentials: PowerShellNuGetOrgPush
Loading