Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use placeholder for version in script source #154

Merged

Conversation

SamErde
Copy link
Collaborator

@SamErde SamErde commented Aug 15, 2024

The latest release of PSPublishModule adds supports for code placeholders that get replaced during the build process. Placeholders and their replacements can be defined in .\Build\Build-Module.ps1 and there are also a number of predefined placeholders.

This PR takes advantage of the predefined placeholder which gets automatically replaced with the ModuleVersion value from the manifest.

I also added a $CalVer parameter to Build-Module.ps1 so a version can be manually specified (uses .\Build\Build-Module.ps1 -CalVer '2024.8.15'). If this parameter is not used, the build will automatically be versioned by (Get-Date -format yyyy.M).

@SamErde SamErde self-assigned this Aug 15, 2024
@SamErde SamErde added the enhancement New feature or request label Aug 15, 2024
@SamErde
Copy link
Collaborator Author

SamErde commented Aug 15, 2024

Thanks for building this idea so quickly, @PrzemyslawKlys!

@TrimarcJake
Copy link
Owner

This is awesome.

It seems to be updating the version number in all the correct locations except Private/Invoke-Locksmith.ps1. I'm not sure if that's a you thing or a PSPublishModule thing. We'll look into it tomorrow.

@SamErde
Copy link
Collaborator Author

SamErde commented Aug 16, 2024

There isn't an Invoke-Locksmith.ps1 in Private.

New-Dictionary.ps1 is versioned separately from the module version. Maybe that's what you saw?

@TrimarcJake
Copy link
Owner

I meant Public, but I see why it needs to remained as a placeholder. This is a me problem. :D

My typical testing process is to do:

> .\Build\Build-Module.ps1
> Import-Module .\Locksmith.psd1 -Force
> Invoke-Locksmith

<cool shtuff...>

but this loads Public\Invoke-Locksmith.ps1

Instead, I should be doing is:

> .\Build\Build-Module.ps1
> Import-Module .\Artefacts\Unpacked\Locksmith\Locksmith.psd1 -Force
> Invoke-Locksmith

<cool shtuff...>

I have updated my testing procedures!

@PrzemyslawKlys
Copy link
Contributor

I would say you need to run it as you were and just "ignore" placeholders knowing they will be fixed, unless you specifically test for the placeholder replacement. Building artefacts just for running your code adds seconds/minutes to your testing.

Copy link
Owner

@TrimarcJake TrimarcJake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested! Works as expected!

@TrimarcJake TrimarcJake merged commit 9a5c3d6 into TrimarcJake:testing Aug 16, 2024
3 checks passed
@TrimarcJake
Copy link
Owner

@PrzemyslawKlys that's fair, but I still build every time anyway as a check against me making stupid mistakes. It takes about 6 seconds to build, and I give myself a little sip of coffee when I test. 😄

@SamErde SamErde deleted the enhancement-version-placeholder branch August 16, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants