Skip to content

Commit

Permalink
Debug release script
Browse files Browse the repository at this point in the history
Adds missing exec function to release notes script

Add author names to git, change branch logic

Also change checkout branch variable

Change release notes so they're output to a file

Add a bunch of extra debugging

Fix yaml syntax error

Work done for #196

[release]
  • Loading branch information
atruskie committed Apr 6, 2020
1 parent b651940 commit 4176273
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
13 changes: 7 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ stages:
displayName: Reconstitute variables
- pwsh: |
git checkout $env:BUILD_SOURCEBRANCH
./build/release_notes.ps1 v${env:AP_Version} -update_changelog
git checkout $env:BUILD_SOURCEBRANCHNAME
Get-ChildItem env:
./build/release_notes.ps1 v${env:AP_Version} '$(System.ArtifactsDirectory)/release_notes.txt' -update_changelog
git config --global user.email "[email protected]"
git config --global user.name "QUT Ecoaocustics"
git add CHANGELOG.md
git commit -m "Update changelog for v${env:AP_Version}" -m "[skip_ci]"
env:
AP_Version: $(AP_Version)
displayName: Generate release notes, commit changelog
- task: GitHubRelease@0
Expand All @@ -106,8 +107,8 @@ stages:
tagSource: auto
tag: v$(AP_Version)
title: $(AP_ReleaseTitle)
releaseNotesSource: inputs
releaseNotes: $(AP_ReleaseMessage)
releaseNotesSource: file
releaseNotesFile: '$(System.ArtifactsDirectory)/release_notes.txt'
assets: |
$(Build.ArtifactsDirectory)/**/*.zip
$(Build.ArtifactsDirectory)/**/*.tar.xz
Expand Down
28 changes: 22 additions & 6 deletions build/release_notes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
param(
[Parameter(Position = 0, mandatory = $true)]
$tag_name,
[Parameter(Position = 1, mandatory = $true)]
$output_file,
[switch]$update_changelog
)

$ErrorActionPreference = "Stop"
$DebugPreference = 'Continue'

Write-Debug "`$tag_name:$tag_name"
Write-Debug "`$output_file:$output_file"
Write-Debug "`$update_changelog:$update_changelog"

function formatIssueList {
process {
#Write-debug $_.Issues.Count #+ ($_.Issues -join ","))
Expand All @@ -25,6 +31,19 @@ function formatIssueList {
}
}

function script:exec {
[CmdletBinding()]

param(
[Parameter(Position = 0, Mandatory = 1)][scriptblock]$cmd,
[Parameter(Position = 1, Mandatory = 0)][string]$errorMessage = ("Error executing command: {0}" -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw $errorMessage
}
}

Write-Output "Creating release message"
# we assumed we've already tagged before describing this release
$old_tag_name = exec { git describe --abbrev=0 --always "HEAD^" }
Expand Down Expand Up @@ -84,8 +103,7 @@ $commit_list

$changelog_changes = "$changelog_title`n`n$release_message"
if ($update_changelog) {
$replace = "<!--manual-content-insert-here-->`n`n`n`n<!--generated-con
tent-insert-here-->`n`n$changelog_changes"
$replace = "<!--manual-content-insert-here-->`n`n`n`n<!--generated-content-insert-here-->`n`n$changelog_changes"
$changelog -replace $changelog_regex, $replace | Out-File $changelog_path -Encoding utf8NoBOM
}
else {
Expand All @@ -97,10 +115,8 @@ else {
# $env:ApReleaseTitle = $release_title

Write-Debug "Release message:`n$release_title`n$release_message"



Write-Debug "commit count: $($commits.Count)"

Write-Output "##vso[task.setvariable variable=AP_ReleaseTitle]$release_title"
Write-Output "##vso[task.setvariable variable=AP_ReleaseMessage]$release_message"
Write-Output "Writing release notes to $output_file"
$release_message | Out-File $output_file -Encoding utf8NoBOM
4 changes: 2 additions & 2 deletions src/git_version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $self_contained = if ($self_contained -eq 'true') { 'true' } else { 'false' }

$commit_hash = git show -s --format="%H"

$branch = ((git log -n 1 --pretty=%d HEAD) | Select-String ", ([^,]*)\)").Matches[0].Groups[1].Value
$branch = ((git log -n 1 --pretty=%d HEAD) | Select-String "-> ([\w-]+)").Matches[0].Groups[1].Value

$describe = git describe --dirty --abbrev --long --always

Expand Down Expand Up @@ -60,7 +60,7 @@ $prefix = ''
$seperator = '='
if ($set_ci) {
$prefix = "##vso[task.setvariable variable=AP_"
$seperator = ";isoutput=true]"
$seperator = "]"
}

$props = @"
Expand Down

0 comments on commit 4176273

Please sign in to comment.