-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.ps1
More file actions
63 lines (53 loc) · 2.15 KB
/
Copy pathrelease.ps1
File metadata and controls
63 lines (53 loc) · 2.15 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
<#
generated with CMTools 0.0.46 fa5af45
.SYNOPSIS
Release script for CMTools on GitHub using gh CLI.
#>
# Determine repository and group IDs
$repoId = Split-Path -Leaf -Path (Get-Location)
$groupId = (git config --get remote.origin.url) -replace '.*github\.com[:/]([^/]+)/.*', '$1'
$repoUrl = "https://github.com/${groupId}/${repoId}"
Write-Output "REPO_URL -> ${repoUrl}"
# Generate release tag and notes
$releaseTag = "v$(jq -r .version codemeta.json)"
if ($releaseTag -notmatch '^v[0-9a-zA-Z._-]+$') {
Write-Error "error: version contains unexpected characters: ${releaseTag}"
exit 1
}
Write-Output "tag: ${releaseTag}, notes:"
jq -r .releaseNotes codemeta.json | Out-File -FilePath release_notes.tmp -Encoding utf8
Get-Content release_notes.tmp
# Generate checksums for distribution zip files
$checksumFile = "${repoId}-${releaseTag}-checksums.txt"
$hashes = Get-ChildItem -Path dist -Filter *.zip | ForEach-Object {
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash.ToLower()
"$hash $($_.Name)"
}
$hashes | Out-File -FilePath "dist/${checksumFile}" -Encoding utf8
Write-Output "Checksums written to dist/${checksumFile}"
# Prompt user to push release to GitHub
$yesNo = Read-Host -Prompt "Push release to GitHub with gh? (y/N)"
if ($yesNo -eq "y") {
Write-Output "Saving working state for ${releaseTag}"
git commit -am "prep for ${releaseTag}"
git push
Write-Output "Pushing release ${releaseTag} to GitHub"
gh release create "${releaseTag}" `
--draft `
--notes-file release_notes.tmp `
--generate-notes
Write-Output "Uploading distribution files and checksums"
Write-Output " Starting upload: dist/${checksumFile}"
gh release upload "${releaseTag}" "dist/${checksumFile}"
Write-Output " Completed upload: dist/${checksumFile}"
foreach ($file in (Get-ChildItem -Path dist -Filter *.zip)) {
Write-Output " Starting upload: $($file.Name)"
gh release upload "${releaseTag}" $file.FullName
Write-Output " Completed upload: $($file.Name)"
}
Write-Output @"
Now go to repo release and finalize draft.
${repoUrl}/releases
"@
Remove-Item release_notes.tmp
}