theohbrothers / PSModulePublisher

A project containing the necessary tools to ease publishing of PowerShell modules.
Apache License 2.0
1 stars 1 forks source link

`Invoke-PSModulePublisher.ps1` does not take params #24

Closed leojonathanoh closed 5 months ago

leojonathanoh commented 1 year ago

Current

Invoke-PSModulePublisher.ps1 does not take params

Discussion

If Invoke-PSModulePublisher.ps1 is to be used in the CI (as stated in the readme), it must be able to take params -Repository and DryRun.

Right now, the script is a standalone script that is to be used interactively.

joeltimothyoh commented 1 year ago

Invoke-PSModulePublisher.ps1 was designed for use in dev environments: https://github.com/theohbrothers/PSModulePublisher/blob/aa99891eac2de091060b8435fd23762163bb75e3/src/Invoke-PSModulePublisher.ps1#L2 It's meant to be executed without params with the fail-safe defaults.

CI environments on the other hand use the public scripts. The directory structure is a little more understandable with the recent changes.

leojonathanoh commented 1 year ago

as described in https://github.com/theohbrothers/PSModulePublisher/issues/25#issuecomment-1484485869 that there is a need for the user to be able to use Invoke-Test, Invoke-Build, and Invoke-Publish independently, instead of Invoke-PSModulePublisher which performs all three of them at once. Also discussed there is that it seems like the module is making correct progress with #26, #27, #28 which are making all three public functions.

joeltimothyoh commented 1 year ago

The project actually isn't a PS module because it contains scripts and CI templates for use with it as well. It's possible to convert the scripts to functions. Will have to see if it's possible to do so without introducing too many breaking changes.

leojonathanoh commented 1 year ago

It is possible. I've checked that all the Invoke-Build, Invoke-Test, Invoke-Publish cmdlets are not used by the default PS cmdlets.

leojonathanoh commented 1 year ago

the only difficulty i foresee are that the dot-sourcing in Invoke-Build.ps1 to Get-ProjectVariables.ps1 uses relative paths to PSModulePublisher. If this becomes a PS module Import-Module; Invoke-Build for instance, the Invoke-* cmdlets must now be executed in the PS module's project dir to be able too resolve variables correctly (via private function Get-ProjectVariables), in contrast to now where the Invoke-* script may be called from anywhere.

joeltimothyoh commented 1 year ago

i think making turning it into a module makes the project hard to understand, develop, and use in CI environments. it's more a compilation of scripts which now follow a modular format. the present design allows Invoke-PSModulePublisher.ps1 to be used which frees developer burden of needing to import the module etc.

leojonathanoh commented 1 year ago

true. basically a tools git submodule with a bunch of helpers. shouldn't need a PSGallery to Install Module; Import Module in CI environments.

leojonathanoh commented 1 year ago

btw, pwsh has become mainstream in at least Github CI, with first class citizen availability: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-powershell

so it's pretty easy to any of these in CI.

PSGallery PS module

Install-Module PSModulePublisher  ...
Import-Module PSModulePublisher -Force # May not be necessary, since Cmdlet might be loaded dynamically
Invoke-Build

Git submodule as PS module

# Must have git clone --recursive to clone submodules
Import-Module ./path/to/src/PSModulePublisher
Invoke-Build 

GIt submodule as PS script

# Must git clone --recursive to clone submodules
./path/to/src/Invoke-Build.ps1

just some little ideas.

joeltimothyoh commented 1 year ago

How about the installation of publish dependencies, Pester, testing, and publishing of PS modules via actions as documented in the link. I'd assume it'd be pretty seamless. Code would be coupled and dependent on GHA though.

leojonathanoh commented 1 year ago

Reviewing things again, the approach https://github.com/theohbrothers/Generate-DockerImageVariants/pull/78 is the most elegant imo. The CI jobs do not execute the monolithic Invoke-PSModulePublisher.ps1 but only the scripts needed.

If Invoke-PSModulePublisher.ps1 would ever be used, it must support non-interactivity as suggested in OP.

joeltimothyoh commented 1 year ago

If Invoke-PSModulePublisher.ps1 would ever be used, it must support non-interactivity as suggested in OP.

Will see if that can be supported.

joeltimothyoh commented 5 months ago

Resolved in #46.

Closing.