Skip to content

Commit a57f88f

Browse files
Merge pull request #166 from StartAutomating/PSDevOps-Updates
PSDevOps updates
2 parents 27bc1cd + 7b0f918 commit a57f88f

File tree

150 files changed

+16999
-6227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+16999
-6227
lines changed

.github/workflows/OnIssue.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
name: OnIssueChanged
3+
on:
4+
issues:
5+
workflow_dispatch:
6+
jobs:
7+
RunGitPub:
8+
runs-on: ubuntu-latest
9+
if: ${{ success() }}
10+
steps:
11+
- name: Check out repository
12+
uses: actions/checkout@v2
13+
- name: Use GitPub Action
14+
uses: StartAutomating/GitPub@main
15+
id: GitPub
16+
with:
17+
TargetBranch: edits-$([DateTime]::Now.ToString("r").Replace(":","-").Replace(" ", ""))
18+
CommitMessage: Posting with GitPub [skip ci]
19+
PublishParameters: |
20+
{
21+
"Get-GitPubIssue": {
22+
"Repository": '${{github.repository}}'
23+
},
24+
"Get-GitPubRelease": {
25+
"Repository": '${{github.repository}}'
26+
},
27+
"Publish-GitPubJekyll": {
28+
"OutputPath": "docs/_posts"
29+
}
30+
}
31+

.github/workflows/TestAndPublish.yml

Lines changed: 120 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ jobs:
306306
$Parameters.UserName = ${env:UserName}
307307
$Parameters.TagVersionFormat = ${env:TagVersionFormat}
308308
$Parameters.ReleaseNameFormat = ${env:ReleaseNameFormat}
309+
$Parameters.ReleaseAsset = ${env:ReleaseAsset}
310+
$Parameters.ReleaseAsset = $parameters.ReleaseAsset -split ';' -replace '^[''"]' -replace '[''"]$'
309311
foreach ($k in @($parameters.Keys)) {
310312
if ([String]::IsNullOrEmpty($parameters[$k])) {
311313
$parameters.Remove($k)
@@ -331,7 +333,11 @@ jobs:
331333
332334
# The release name format (default value: '$($imported.Name) $($imported.Version)')
333335
[string]
334-
$ReleaseNameFormat = '$($imported.Name) $($imported.Version)'
336+
$ReleaseNameFormat = '$($imported.Name) $($imported.Version)',
337+
338+
# Any assets to attach to the release. Can be a wildcard or file name.
339+
[string[]]
340+
$ReleaseAsset
335341
)
336342
337343
@@ -377,39 +383,89 @@ jobs:
377383
378384
if ($releaseExists) {
379385
"::warning::Release '$($releaseExists.Name )' Already Exists" | Out-Host
380-
return
386+
$releasedIt = $releaseExists
387+
} else {
388+
$releasedIt = Invoke-RestMethod -Uri $releasesURL -Method Post -Body (
389+
[Ordered]@{
390+
owner = '${{github.owner}}'
391+
repo = '${{github.repository}}'
392+
tag_name = $targetVersion
393+
name = $ExecutionContext.InvokeCommand.ExpandString($ReleaseNameFormat)
394+
body =
395+
if ($env:RELEASENOTES) {
396+
$env:RELEASENOTES
397+
} elseif ($imported.PrivateData.PSData.ReleaseNotes) {
398+
$imported.PrivateData.PSData.ReleaseNotes
399+
} else {
400+
"$($imported.Name) $targetVersion"
401+
}
402+
draft = if ($env:RELEASEISDRAFT) { [bool]::Parse($env:RELEASEISDRAFT) } else { $false }
403+
prerelease = if ($env:PRERELEASE) { [bool]::Parse($env:PRERELEASE) } else { $false }
404+
} | ConvertTo-Json
405+
) -Headers @{
406+
"Accept" = "application/vnd.github.v3+json"
407+
"Content-type" = "application/json"
408+
"Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}'
409+
}
381410
}
382411
383412
384-
Invoke-RestMethod -Uri $releasesURL -Method Post -Body (
385-
[Ordered]@{
386-
owner = '${{github.owner}}'
387-
repo = '${{github.repository}}'
388-
tag_name = $targetVersion
389-
name = $ExecutionContext.InvokeCommand.ExpandString($ReleaseNameFormat)
390-
body =
391-
if ($env:RELEASENOTES) {
392-
$env:RELEASENOTES
393-
} elseif ($imported.PrivateData.PSData.ReleaseNotes) {
394-
$imported.PrivateData.PSData.ReleaseNotes
395-
} else {
396-
"$($imported.Name) $targetVersion"
413+
414+
415+
416+
if (-not $releasedIt) {
417+
throw "Release failed"
418+
} else {
419+
$releasedIt | Out-Host
420+
}
421+
422+
$releaseUploadUrl = $releasedIt.upload_url -replace '\{.+$'
423+
424+
if ($ReleaseAsset) {
425+
$fileList = Get-ChildItem -Recurse
426+
$filesToRelease =
427+
@(:nextFile foreach ($file in $fileList) {
428+
foreach ($relAsset in $ReleaseAsset) {
429+
if ($relAsset -match '[\*\?]') {
430+
if ($file.Name -like $relAsset) {
431+
$file; continue nextFile
432+
}
433+
} elseif ($file.Name -eq $relAsset -or $file.FullName -eq $relAsset) {
434+
$file; continue nextFile
435+
}
397436
}
398-
draft = if ($env:RELEASEISDRAFT) { [bool]::Parse($env:RELEASEISDRAFT) } else { $false }
399-
prerelease = if ($env:PRERELEASE) { [bool]::Parse($env:PRERELEASE) } else { $false }
400-
} | ConvertTo-Json
401-
) -Headers @{
402-
"Accept" = "application/vnd.github.v3+json"
403-
"Content-type" = "application/json"
404-
"Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}'
437+
})
438+
439+
$releasedFiles = @{}
440+
foreach ($file in $filesToRelease) {
441+
if ($releasedFiles[$file.Name]) {
442+
Write-Warning "Already attached file $($file.Name)"
443+
continue
444+
} else {
445+
$fileBytes = [IO.File]::ReadAllBytes($file.FullName)
446+
$releasedFiles[$file.Name] =
447+
Invoke-RestMethod -Uri "${releaseUploadUrl}?name=$($file.Name)" -Headers @{
448+
"Accept" = "application/vnd.github+json"
449+
"Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}'
450+
} -Body $fileBytes -ContentType Application/octet-stream
451+
$releasedFiles[$file.Name]
452+
}
453+
}
454+
455+
"Attached $($releasedFiles.Count) file(s) to release" | Out-Host
405456
}
457+
458+
459+
406460
} @Parameters
407461
- name: PublishPowerShellGallery
408462
id: PublishPowerShellGallery
409463
shell: pwsh
410464
run: |
411465
$Parameters = @{}
412466
$Parameters.ModulePath = ${env:ModulePath}
467+
$Parameters.Exclude = ${env:Exclude}
468+
$Parameters.Exclude = $parameters.Exclude -split ';' -replace '^[''"]' -replace '[''"]$'
413469
foreach ($k in @($parameters.Keys)) {
414470
if ([String]::IsNullOrEmpty($parameters[$k])) {
415471
$parameters.Remove($k)
@@ -418,19 +474,33 @@ jobs:
418474
Write-Host "::debug:: PublishPowerShellGallery $(@(foreach ($p in $Parameters.GetEnumerator()) {'-' + $p.Key + ' ' + $p.Value}) -join ' ')"
419475
& {param(
420476
[string]
421-
$ModulePath
477+
$ModulePath,
478+
479+
[string[]]
480+
$Exclude = @('*.png', '*.mp4', '*.jpg','*.jpeg', '*.gif', 'docs[/\]*')
422481
)
482+
423483
$gitHubEvent = if ($env:GITHUB_EVENT_PATH) {
424484
[IO.File]::ReadAllText($env:GITHUB_EVENT_PATH) | ConvertFrom-Json
425485
} else { $null }
426486
487+
if (-not $Exclude) {
488+
$Exclude = @('*.png', '*.mp4', '*.jpg','*.jpeg', '*.gif','docs[/\]*')
489+
}
490+
427491
428492
@"
429493
::group::GitHubEvent
430494
$($gitHubEvent | ConvertTo-Json -Depth 100)
431495
::endgroup::
432496
"@ | Out-Host
433497
498+
@"
499+
::group::PSBoundParameters
500+
$($PSBoundParameters | ConvertTo-Json -Depth 100)
501+
::endgroup::
502+
"@ | Out-Host
503+
434504
if (-not ($gitHubEvent.head_commit.message -match "Merge Pull Request #(?<PRNumber>\d+)") -and
435505
(-not $gitHubEvent.psobject.properties['inputs'])) {
436506
"::warning::Pull Request has not merged, skipping Gallery Publish" | Out-Host
@@ -448,9 +518,9 @@ jobs:
448518
449519
if (-not $imported) { return }
450520
451-
$foundModule = try { Find-Module -Name $imported.Name -ErrorAction SilentlyContinue } catch {}
521+
$foundModule = try { Find-Module -Name $imported.Name -ErrorAction SilentlyContinue} catch {}
452522
453-
if ($foundModule -and $foundModule.Version -ge $imported.Version) {
523+
if ($foundModule -and (([Version]$foundModule.Version) -ge ([Version]$imported.Version))) {
454524
"::warning::Gallery Version of $moduleName is more recent ($($foundModule.Version) >= $($imported.Version))" | Out-Host
455525
} else {
456526
@@ -473,9 +543,24 @@ jobs:
473543
if (Test-Path $moduleGitPath) {
474544
Remove-Item -Recurse -Force $moduleGitPath
475545
}
546+
547+
if ($Exclude) {
548+
"::notice::Attempting to Exlcude $exclude" | Out-Host
549+
Get-ChildItem $moduleTempPath -Recurse |
550+
Where-Object {
551+
foreach ($ex in $exclude) {
552+
if ($_.FullName -like $ex) {
553+
"::notice::Excluding $($_.FullName)" | Out-Host
554+
return $true
555+
}
556+
}
557+
} |
558+
Remove-Item
559+
}
560+
476561
Write-Host "Module Files:"
477562
Get-ChildItem $moduleTempPath -Recurse
478-
Write-Host "Publishing $moduleName [$($imported.Version)] to Gallery"
563+
Write-Host "Publishing $moduleName [$($imported.Version)] to Gallery"
479564
Publish-Module -Path $moduleTempPath -NuGetApiKey $gk
480565
if ($?) {
481566
Write-Host "Published to Gallery"
@@ -485,25 +570,21 @@ jobs:
485570
}
486571
}
487572
} @Parameters
488-
HelpOut:
489-
runs-on: ubuntu-latest
490-
if: ${{ success() }}
491-
steps:
492-
- name: Check out repository
493-
uses: actions/checkout@v2
494-
- name: UseHelpOut
495-
uses: StartAutomating/HelpOut@master
496-
RunEZOut:
573+
BuildPSDevOps:
497574
runs-on: ubuntu-latest
498575
if: ${{ success() }}
499576
steps:
500577
- name: Check out repository
501578
uses: actions/checkout@v2
579+
- name: Use PSSVG Action
580+
uses: StartAutomating/PSSVG@main
581+
id: PSSVG
582+
- name: BuildPipeScript
583+
uses: StartAutomating/PipeScript@main
502584
- name: UseEZOut
503585
uses: StartAutomating/EZOut@master
504-
- name: Push Changes
505-
shell: pwsh
506-
run: git push; exit 0
586+
- name: UseHelpOut
587+
uses: StartAutomating/HelpOut@master
507588
env:
508-
SYSTEM_ACCESSTOKEN: ${{ secrets.AZUREDEVOPSPAT }}
509589
NoCoverage: true
590+
SYSTEM_ACCESSTOKEN: ${{ secrets.AZUREDEVOPSPAT }}

Assets/PSDevOps.svg

Lines changed: 14 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)