Skip to content

Commit

Permalink
Handle full module lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
natescherer committed Aug 1, 2023
1 parent c850257 commit a1ca814
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
19 changes: 16 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ runs:
if ($env:INPUT_TARGET -eq "packages") {
. "$env:GITHUB_ACTION_PATH\src\steps\3_publish_to_packages.ps1"
} else {
Write-Host "Skipping as this target was not selected..."
Write-Host "Skipping as GitHubPackages target was not selected."
}
env:
INPUT_TOKEN: ${{ inputs.token }}
Expand All @@ -59,7 +59,7 @@ runs:
if ($env:INPUT_TARGET -eq "nuget") {
. "$env:GITHUB_ACTION_PATH\src\steps\4_publish_to_nuget.ps1"
} else {
Write-Host "Skipping as this target was not selected..."
Write-Host "Skipping as NuGet target was not selected."
}
env:
INPUT_TOKEN: ${{ inputs.token }}
Expand All @@ -72,7 +72,20 @@ runs:
if ($env:INPUT_TARGET -eq "gallery") {
. "$env:GITHUB_ACTION_PATH\src\steps\5_publish_to_gallery.ps1"
} else {
Write-Host "Skipping as this target was not selected..."
Write-Host "Skipping as Gallery target was not selected."
}
env:
INPUT_TOKEN: ${{ inputs.token }}
INPUT_TARGET: ${{ inputs.target }}
INPUT_PATH: ${{ inputs.path }}
INPUT_NUGETURL: ${{ inputs.nugetUrl }}
shell: pwsh
- name: Cleanup
run: |
if ($env:UNINSTALL_STRING) {
. "$env:GITHUB_ACTION_PATH\src\steps\6_cleanup.ps1"
} else {
Write-Host "Skipping as there is nothing to clean up."
}
env:
INPUT_TOKEN: ${{ inputs.token }}
Expand Down
5 changes: 5 additions & 0 deletions src/steps/3_publish_to_packages.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
if ($env:IMPORT_STRING) {
Write-Host "Resource has dependencies, now importing them into the current session..."
Invoke-Expression -Command $env:IMPORT_STRING
}

Write-Host "Registering GitHub Packages repository..."
Register-PSResourceRepository -Name "GitHubPackages" -Uri "https://nuget.pkg.github.com/$env:GITHUB_REPOSITORY_OWNER/index.json"

Expand Down
5 changes: 5 additions & 0 deletions src/steps/4_publish_to_nuget.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
if ($env:IMPORT_STRING) {
Write-Host "Resource has dependencies, now importing them into the current session..."
Invoke-Expression -Command $env:IMPORT_STRING
}

Write-Host "Registering NuGet repository..."
Register-PSResourceRepository -Name "NuGet" -Uri $env:INPUT_NUGETURL -Trusted

Expand Down
5 changes: 5 additions & 0 deletions src/steps/5_publish_to_gallery.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
if ($env:IMPORT_STRING) {
Write-Host "Resource has dependencies, now importing them into the current session..."
Invoke-Expression -Command $env:IMPORT_STRING
}

Write-Host "Publishing to PowerShell Gallery..."
Publish-PSResource -Path $env:RESOLVED_PATH -Repository "PSGallery" -ApiKey $env:INPUT_TOKEN

Expand Down
5 changes: 5 additions & 0 deletions src/steps/6_cleanup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Write-Host "Now uninstalling temporarily installed packages..."

Invoke-Expression -Command $env:UNINSTALL_STRING

Write-Host "Done!"

0 comments on commit a1ca814

Please sign in to comment.