Skip to content

Commit bd1894d

Browse files
Merge pull request #20 from Stravaig-Projects/#19-fix-mark-release
#19 Fix "Mark Release" build task
2 parents ab80d95 + 403e4d5 commit bd1894d

File tree

5 files changed

+139
-15
lines changed

5 files changed

+139
-15
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
- '.vscode/**'
1111
- '.gitignore'
1212
- 'contributors.md'
13-
- 'release-notes/**'
1413
- '.github/PULL_REQUEST_TEMPLATE/**'
1514
- 'src/.idea/**'
1615

@@ -54,6 +53,7 @@ jobs:
5453

5554
- name: Display workflow state
5655
run: |
56+
echo "GITHUB_SHA: $GITHUB_SHA"
5757
echo "Solution: $STRAVAIG_SOLUTION"
5858
echo "Project: $STRAVAIG_PROJECT"
5959
echo "Tests: $STRAVAIG_TESTS"
@@ -67,7 +67,7 @@ jobs:
6767
- uses: actions/setup-dotnet@v1
6868
name: Setup .NET Core
6969
with:
70-
dotnet-version: 3.1.404
70+
dotnet-version: 3.1.405
7171

7272
- name: Build Solution
7373
run: dotnet build $STRAVAIG_SOLUTION --configuration Release
@@ -123,19 +123,22 @@ jobs:
123123
release-notes/full-release-notes.md
124124
release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md
125125
out/**
126-
127-
- name: Mark Release
126+
127+
- name: Create Release
128128
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }}
129-
uses: ncipollo/release-action@v1
130-
with:
131-
artifacts: "./out/*.nupkg,./out/*.snupkg,LICENSE,contributors.md,readme.md,./release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md"
132-
token: ${{ secrets.GITHUB_TOKEN }}
133-
bodyFile: "release-body.md"
134-
prerelease: ${{ env.STRAVAIG_IS_PREVIEW }}
135-
commit: ${{ env.GITHUB_SHA }}
136-
tag: v${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}
137-
draft: false
138-
129+
shell: pwsh
130+
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
run: |
133+
$assets = @();
134+
$assets += "./out/*.nupkg"
135+
$assets += "./out/*.snupkg"
136+
$assets += "LICENSE"
137+
$assets += "contributors.md"
138+
$assets += "README.md"
139+
$assets += "./release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md"
140+
./Create-Release.ps1 -IsDraft -NotesFile "./release-body.md" -Assets $assets
141+
139142
- name: Bump version
140143
#IF Publishing & Stable release
141144
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }}

.vscode/settings.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
{
2-
"restructuredtext.confPath": ""
2+
"restructuredtext.confPath": "",
3+
"cSpell.words": [
4+
"Dependabot",
5+
"Dependabots",
6+
"Nuget",
7+
"Stravaig",
8+
"commitish",
9+
"nupkg",
10+
"pwsh",
11+
"snupkg"
12+
]
313
}

Create-Release.ps1

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
[CmdletBinding()]
2+
param
3+
(
4+
[parameter(Mandatory=$false)]
5+
[switch]$IsDraft,
6+
7+
[ValidateScript({Test-Path $_ -PathType Leaf})]
8+
[parameter(Mandatory=$true)]
9+
[string]$NotesFile,
10+
11+
[ValidateScript({Test-Path $_ -PathType Leaf})]
12+
[parameter(Mandatory=$false)]
13+
[string[]]$Assets
14+
)
15+
16+
function Invoke-GitHub([string]$ghArgs)
17+
{
18+
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
19+
$pinfo.FileName = "gh"
20+
$pinfo.UseShellExecute = $false
21+
$pinfo.Arguments = $ghArgs
22+
Write-Verbose -Message $pinfo.Arguments
23+
$ghProcess = New-Object System.Diagnostics.Process
24+
$ghProcess.StartInfo = $pinfo
25+
$null = $ghProcess.Start();
26+
$ghProcess.WaitForExit();
27+
return $ghProcess.ExitCode;
28+
}
29+
30+
if ([string]::IsNullOrWhiteSpace($Env:GITHUB_TOKEN))
31+
{
32+
Write-Error "GITHUB_TOKEN environment variable is missing."
33+
Exit 1;
34+
}
35+
36+
if ([string]::IsNullOrWhiteSpace($Env:GITHUB_SHA))
37+
{
38+
Write-Error "GITHUB_SHA is missing."
39+
Exit 2;
40+
}
41+
$Commitish = $Env:GITHUB_SHA;
42+
43+
if ([string]::IsNullOrWhiteSpace($Env:STRAVAIG_PACKAGE_FULL_VERSION))
44+
{
45+
Write-Error "STRAVAIG_PACKAGE_FULL_VERSION is missing."
46+
Exit 3;
47+
}
48+
$TagName = "v" + $Env:STRAVAIG_PACKAGE_FULL_VERSION
49+
50+
51+
if ([string]::IsNullOrWhiteSpace($Env:STRAVAIG_IS_PREVIEW))
52+
{
53+
Write-Error "STRAVAIG_IS_PREVIEW is missing."
54+
Exit 4;
55+
}
56+
$IsPrerelease = [System.Convert]::ToBoolean($Env:STRAVAIG_IS_PREVIEW);
57+
58+
59+
$ghArgs = "release create `"$TagName`""
60+
foreach($assetPath in $Assets)
61+
{
62+
$specificAssets = Get-Item $assetPath;
63+
foreach($specificAsset in $specificAssets)
64+
{
65+
if (-not $specificAsset.PSIsContainer)
66+
{
67+
$fileName = $specificAsset.FullName;
68+
$ghArgs += " `"$fileName`""
69+
}
70+
else
71+
{
72+
Write-Verbose "Skipping `"$specificAsset`" as it refers to a directory. Must provide paths to files."
73+
}
74+
}
75+
}
76+
77+
78+
79+
$ghArgs += " --title `"Release of $TagName`" --target $Commitish --notes-file `"$NotesFile`""
80+
if ($IsDraft)
81+
{
82+
$ghArgs += " --draft"
83+
}
84+
if ($IsPrerelease)
85+
{
86+
$ghArgs += " --prerelease"
87+
}
88+
$exitCode = Invoke-GitHub $ghArgs
89+
if ($exitCode -ne 0)
90+
{
91+
Write-Error "Failed to create a release."
92+
Exit $exitCode;
93+
}
94+

Reset-WipReleaseNotes.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ $content = @(
1010
"### Features",
1111
"",
1212
"### Miscellaneous",
13+
"",
14+
"### Dependabot"
15+
"",
1316
""
1417
)
1518

release-notes/wip-release-notes.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,17 @@ Date: ???
1010

1111
### Miscellaneous
1212

13+
* #19: Fix release process.
14+
* Bump SDK version
15+
* Create release to PowerShell/GitHub CLI
16+
* Release notes now includes a Dependabots section
17+
18+
### Dependabot
19+
20+
* Bump `NUnit` from 3.12.0 to 3.13.0
21+
* Bump `Microsoft.Extensions.Configuration.Json` from 3.1.10 to 3.1.11
22+
* Bump `Microsoft.Extensions.DependencyInjection.Abstractions` from 3.1.10 to 3.1.11
23+
* Bump `Microsoft.Extensions.Logging.Abstractions` from 3.1.10 to 3.1.11
24+
* Bump `Microsoft.Extensions.Options` from 3.1.10 to 3.1.11
25+
* Bump `Microsoft.Extensions.Options.ConfigurationExtensions` from 3.1.10 to 3.1.11
26+
* Bump `Stravaig.Extensions.Logging.Diagnostics` from 0.3.0 to 0.3.1

0 commit comments

Comments
 (0)