@@ -379,32 +379,34 @@ jobs:
379379
380380 if ($releaseExists) {
381381 "::warning::Release '$($releaseExists.Name )' Already Exists" | Out-Host
382- return
382+ $releasedIt = $releaseExists
383+ } else {
384+ $releasedIt = 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"
397+ }
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 }}'
405+ }
383406 }
384407
385408
386- $releasedIt = Invoke-RestMethod -Uri $releasesURL -Method Post -Body (
387- [Ordered]@{
388- owner = '${{github.owner}}'
389- repo = '${{github.repository}}'
390- tag_name = $targetVersion
391- name = $ExecutionContext.InvokeCommand.ExpandString($ReleaseNameFormat)
392- body =
393- if ($env:RELEASENOTES) {
394- $env:RELEASENOTES
395- } elseif ($imported.PrivateData.PSData.ReleaseNotes) {
396- $imported.PrivateData.PSData.ReleaseNotes
397- } else {
398- "$($imported.Name) $targetVersion"
399- }
400- draft = if ($env:RELEASEISDRAFT) { [bool]::Parse($env:RELEASEISDRAFT) } else { $false }
401- prerelease = if ($env:PRERELEASE) { [bool]::Parse($env:PRERELEASE) } else { $false }
402- } | ConvertTo-Json
403- ) -Headers @{
404- "Accept" = "application/vnd.github.v3+json"
405- "Content-type" = "application/json"
406- "Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}'
407- }
409+
408410
409411
410412 if (-not $releasedIt) {
@@ -439,10 +441,9 @@ jobs:
439441 $fileBytes = [IO.File]::ReadAllBytes($file.FullName)
440442 $releasedFiles[$file.Name] =
441443 Invoke-RestMethod -Uri "${releaseUploadUrl}?name=$($file.Name)" -Headers @{
442- "Accept" = "application/vnd.github+json"
443- "ContentType" = "application/octet-stream"
444+ "Accept" = "application/vnd.github+json"
444445 "Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}'
445- } -Body $fileBytes
446+ } -Body $fileBytes -ContentType Application/octet-stream
446447 $releasedFiles[$file.Name]
447448 }
448449 }
@@ -583,6 +584,44 @@ jobs:
583584 uses : StartAutomating/EZOut@master
584585 - name : UseHelpOut
585586 uses : StartAutomating/HelpOut@master
587+ - name : Log in to ghcr.io
588+ uses : docker/login-action@master
589+ with :
590+ registry : ${{ env.REGISTRY }}
591+ username : ${{ github.actor }}
592+ password : ${{ secrets.GITHUB_TOKEN }}
593+ - name : Extract Docker Metadata (for branch)
594+ if : ${{github.ref_name != 'main' && github.ref_name != 'master' && github.ref_name != 'latest'}}
595+ id : meta
596+ uses : docker/metadata-action@master
597+ with :
598+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
599+ - name : Extract Docker Metadata (for main)
600+ if : ${{github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'latest'}}
601+ id : metaMain
602+ uses : docker/metadata-action@master
603+ with :
604+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
605+ flavor : latest=true
606+ - name : Build and push Docker image (from main)
607+ if : ${{github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'latest'}}
608+ uses : docker/build-push-action@master
609+ with :
610+ context : .
611+ push : true
612+ tags : ${{ steps.metaMain.outputs.tags }}
613+ labels : ${{ steps.metaMain.outputs.labels }}
614+ - name : Build and push Docker image (from branch)
615+ if : ${{github.ref_name != 'main' && github.ref_name != 'master' && github.ref_name != 'latest'}}
616+ uses : docker/build-push-action@master
617+ with :
618+ context : .
619+ push : true
620+ tags : ${{ steps.meta.outputs.tags }}
621+ labels : ${{ steps.meta.outputs.labels }}
586622on :
587623 push :
588624 workflow_dispatch :
625+ env :
626+ REGISTRY : ghcr.io
627+ IMAGE_NAME : ${{ github.repository }}
0 commit comments