Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5932358

Browse files
authoredSep 29, 2021
don't fail on unavailble module nupkg (for when publishing release with assets in build.yml) (#19)
* don't fail on unavailble module nupkg (for when publishing release with assets in build.yml) * updating changelog * making sure the Get-SamplerProjectName is not called when importing task * reverting code to hide token
1 parent fa359c1 commit 5932358

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed
 

‎.build/tasks/New-Release.GitHub.build.ps1

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
param (
2-
# Base directory of all output (default to 'output')
3-
1+
param
2+
(
43
[Parameter()]
54
[System.String]
65
$BuiltModuleSubdirectory = (property BuiltModuleSubdirectory ''),
@@ -11,11 +10,11 @@ param (
1110

1211
[Parameter()]
1312
[System.String]
14-
$ProjectName = (property ProjectName $(Get-SamplerProjectName -BuildRoot $BuildRoot)),
13+
$ProjectName = (property ProjectName ''),
1514

1615
[Parameter()]
1716
[System.String]
18-
$SourcePath = (property SourcePath $(Get-SamplerSourcePath -BuildRoot $BuildRoot)),
17+
$SourcePath = (property SourcePath ''),
1918

2019
[Parameter()]
2120
$ChangelogPath = (property ChangelogPath 'CHANGELOG.md'),
@@ -29,7 +28,7 @@ param (
2928

3029
[Parameter()]
3130
[string]
32-
$ReleaseBranch = (property ReleaseBranch 'master'),
31+
$ReleaseBranch = (property ReleaseBranch 'main'),
3332

3433
[Parameter()]
3534
[string]
@@ -49,14 +48,13 @@ param (
4948
$SkipPublish = (property SkipPublish ''),
5049

5150
[Parameter()]
52-
$MainGitBranch = (property MainGitBranch 'master')
51+
$MainGitBranch = (property MainGitBranch 'main')
5352
)
5453

5554
task Publish_release_to_GitHub -if ($GitHubToken -and (Get-Module -Name PowerShellForGitHub -ListAvailable)) {
5655

5756
. Set-SamplerTaskVariable
5857

59-
6058
$ReleaseNotesPath = Get-SamplerAbsolutePath -Path $ReleaseNotesPath -RelativeTo $OutputDirectory
6159
"`tRelease Notes Path = '$ReleaseNotesPath'"
6260

@@ -65,19 +63,16 @@ task Publish_release_to_GitHub -if ($GitHubToken -and (Get-Module -Name PowerShe
6563

6664
"`tProject Path = $ProjectPath"
6765

68-
# find Module's nupkg
69-
$PackageToRelease = Get-ChildItem (Join-Path $OutputDirectory "$ProjectName.$moduleVersion.nupkg")
66+
# find Module's nupkg if it exists
67+
$packagedProjectNupkg = Join-Path -Path $OutputDirectory -ChildPath "$ProjectName.$moduleVersion.nupkg"
68+
$PackageToRelease = Get-ChildItem -Path $packagedProjectNupkg -ErrorAction Ignore
69+
# If the Project nupkg is not found, don't fail. You can still create a release and specify the
70+
# assets in the build.yml (i.e. Chocolatey packages or Azure Policy Guest Config Packages)
7071
$ReleaseTag = "v$ModuleVersion"
7172

7273
Write-Build DarkGray "About to release '$PackageToRelease' with tag and release name '$ReleaseTag'"
7374
$remoteURL = git remote get-url origin
7475

75-
if ($remoteURL -notMatch 'github')
76-
{
77-
Write-Build Yellow "Skipping Publish GitHub release to $RemoteURL"
78-
return
79-
}
80-
8176
# Retrieving ReleaseNotes or defaulting to Updated ChangeLog
8277
if (Import-Module ChangelogManagement -ErrorAction SilentlyContinue -PassThru)
8378
{

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
### Changed
2020

21+
- Fixed Erroring when "$ProjectName.$ModuleVersion.nupkg" is not available (i.e. when using asset list in `Build.yaml`).
2122
- Fixed tasks to use the new Sampler version and its public functions.
2223
- Fixed RootModule not loaded because of Module Manifest.
2324
- Making this project use the prerelease version of Sampler for testing.

0 commit comments

Comments
 (0)
Please sign in to comment.