Skip to content

Commit daf8a23

Browse files
Merge pull request #78 from Stravaig-Projects/#71-build-process
#71 Update build process
2 parents 9433742 + a091792 commit daf8a23

File tree

4 files changed

+125
-16
lines changed

4 files changed

+125
-16
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454

5555
- name: Display workflow state
5656
run: |
57+
echo "GITHUB_SHA: $GITHUB_SHA"
5758
echo "Solution: $STRAVAIG_SOLUTION"
5859
echo "Project: $STRAVAIG_PROJECT"
5960
echo "Tests: $STRAVAIG_TESTS"
@@ -67,7 +68,7 @@ jobs:
6768
- uses: actions/setup-dotnet@v1
6869
name: Setup .NET Core
6970
with:
70-
dotnet-version: 3.1.404
71+
dotnet-version: 3.1.x # Always the latest patch version.
7172

7273
- name: Build Solution
7374
run: dotnet build $STRAVAIG_SOLUTION --configuration Release
@@ -85,7 +86,13 @@ jobs:
8586

8687
- name: Push package to NuGet
8788
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }}
88-
run: dotnet nuget push ./out/*.nupkg --api-key ${{ secrets.STRAVAIG_NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
89+
shell: pwsh
90+
run: |
91+
Get-ChildItem ./out/*.nupkg | ForEach-Object {
92+
$name = $_.FullName;
93+
Write-Output "Pushing $name";
94+
dotnet nuget push "$name" --api-key ${{ secrets.STRAVAIG_NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
95+
}
8996
9097
- name: List Contributors
9198
shell: pwsh
@@ -115,19 +122,22 @@ jobs:
115122
contributors.md
116123
release-notes/full-release-notes.md
117124
release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md
118-
119-
- name: Mark Release
125+
126+
- name: Create Release
120127
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }}
121-
uses: ncipollo/release-action@v1
122-
with:
123-
artifacts: "./out/*.nupkg,./out/*.snupkg,LICENSE,contributors.md,readme.md,./release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md"
124-
token: ${{ secrets.GITHUB_TOKEN }}
125-
bodyFile: "release-body.md"
126-
prerelease: ${{ env.STRAVAIG_IS_PREVIEW }}
127-
commit: ${{ env.GITHUB_SHA }}
128-
tag: v${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}
129-
draft: false
130-
128+
shell: pwsh
129+
env:
130+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131+
run: |
132+
$assets = @();
133+
$assets += "./out/*.nupkg"
134+
$assets += "./out/*.snupkg"
135+
$assets += "LICENSE"
136+
$assets += "contributors.md"
137+
$assets += "README.md"
138+
$assets += "./release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md"
139+
./Create-Release.ps1 -NotesFile "./release-body.md" -Assets $assets
140+
131141
- name: Bump version
132142
#IF Publishing & Stable release
133143
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }}

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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ $content = @(
44
"## Version X",
55
"",
66
"Date: ???",
7-
""
8-
"### Bugs"
7+
"",
8+
"### Bugs",
99
"",
1010
"### Features",
1111
"",
1212
"### Miscellaneous",
13+
"",
14+
"### Dependabot",
15+
"",
16+
"",
1317
""
1418
)
1519

release-notes/wip-release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Date: ???
2222
* #44: Updated the documentation.
2323
* #47: Add a Pull Request Template.
2424
* #60: Tidy Dependabot configuration & make easily available as solution item.
25+
* #71: Update the build process from the template.
2526

2627
### Dependabot
2728

0 commit comments

Comments
 (0)