{"id":13596548,"url":"https://github.com/RamblingCookieMonster/BuildHelpers","last_synced_at":"2025-04-09T16:32:57.225Z","repository":{"id":41478913,"uuid":"59748913","full_name":"RamblingCookieMonster/BuildHelpers","owner":"RamblingCookieMonster","description":"Helper functions for PowerShell CI/CD scenarios","archived":false,"fork":false,"pushed_at":"2023-08-11T15:04:37.000Z","size":353,"stargazers_count":217,"open_issues_count":44,"forks_count":47,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-07T10:26:42.227Z","etag":null,"topics":["appveyor","build","build-automation","build-pipelines","ci-cd","continuous-deployment","continuous-integration","powershell","powershell-modules"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RamblingCookieMonster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["ramblingcookiemonster"]}},"created_at":"2016-05-26T12:36:00.000Z","updated_at":"2025-02-03T21:21:44.000Z","dependencies_parsed_at":"2024-04-19T02:00:37.183Z","dependency_job_id":null,"html_url":"https://github.com/RamblingCookieMonster/BuildHelpers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RamblingCookieMonster%2FBuildHelpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RamblingCookieMonster%2FBuildHelpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RamblingCookieMonster%2FBuildHelpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RamblingCookieMonster%2FBuildHelpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RamblingCookieMonster","download_url":"https://codeload.github.com/RamblingCookieMonster/BuildHelpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248067971,"owners_count":21042393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appveyor","build","build-automation","build-pipelines","ci-cd","continuous-deployment","continuous-integration","powershell","powershell-modules"],"created_at":"2024-08-01T16:02:34.005Z","updated_at":"2025-04-09T16:32:57.184Z","avatar_url":"https://github.com/RamblingCookieMonster.png","language":"PowerShell","readme":"[![Build status](https://ci.appveyor.com/api/projects/status/joxudd6qrahtr802?svg=true)](https://ci.appveyor.com/project/RamblingCookieMonster/buildhelpers)\n\nBuildHelpers\n==============\n\nThis is a quick and dirty PowerShell module with a variety of helper functions for PowerShell CI/CD scenarios.\n\nMany of our build scripts explicitly reference build-system-specific features.  We might rely on `$ENV:APPVEYOR_REPO_BRANCH` to know which branch we're in, for example.\n\nThis certainly works, but we can enable more portable build scripts by bundling up helper functions, normalizing build variables, and avoiding build-system-specific features.\n\nPull requests and other contributions welcome!\n\n## Instructions\n\n```powershell\n# One time setup\n    # Download the repository\n    # Unblock the zip\n    # Extract the BuildHelpers folder to a module path (e.g. $env:USERPROFILE\\Documents\\WindowsPowerShell\\Modules\\)\n\n    #Simple alternative, if you have PowerShell 5, or the PowerShellGet module:\n        Install-Module BuildHelpers\n\n# Import the module.\n    Import-Module BuildHelpers\n\n# Get commands in the module\n    Get-Command -Module BuildHelpers\n\n# Get help\n    Get-Help Get-BuildVariable -Full\n    Get-Help about_BuildHelpers\n```\n\n## Examples\n\n### Get Normalized Build Variables\n\n```powershell\nGet-BuildVariable\n\n# We assume you're in the project root. If not, specify a path:\nGet-BuildVariable -Path C:\\MyProjectRoot\n```\n\n### Get Project Name\n\nWe occasionally need to reference the project or module name:\n\n```powershell\nGet-ProjectName\n```\n\nThis checks the following expected file system organizations, in order:\n\n(1) *File structure*:\n\n* ProjectX (Repo root)\n  * ProjectX (Project here)\n\n*Output*: ProjectX\n\n(2) *File structure*:\n\n* ProjectX (Repo root)\n  * DifferentName (Project here. tsk tsk)\n    * DifferentName.psd1\n\n*Output*: DifferentName\n\n(3) *File structure*:\n\n* ProjectX (Repo root)\n  * ProjectX.psd1 (Please don't use this organization...)\n\n*Output*: ProjectX\n\n(5) *File structure*:\n\n* ProjectWhatever (Repo root)\n  * src (or source)\n    * ProjectX.psd1\n\n*Output*: ProjectX\n\n(6) *File structure*:\n\n* ProjectX\n  * NoHelpfulIndicatorsOfProjectName.md\n\n*Output*: ProjectX\n\n### Create Normalized Environment Variables\n\nThis runs a few commands from BuildHelpers module, and populates ENV:BH... variables\n\n```powershell\n# Read the current environment, populate env vars\nSet-BuildEnvironment\n\n# Read back the env vars\nGet-Item ENV:BH*\n```\n\nHere's an example, having run Set-BuildEnvironment in an AppVeyor project:\n\n[![AppVeyor Example](/Media/AppVeyor.png)](https://ci.appveyor.com/project/RamblingCookieMonster/psdepend/build/1.0.91)\n\n### Update your FunctionsToExport\n\nDuring the module authoring process, updating FunctionsToExport can be tedious, so many folks leave this set to '*', missing out on module auto-loading and other benefits.\n\nTo get the best of both worlds, use FunctionsToExport='*', and use Set-ModuleFunction in your build before deployment:\n\n```powershell\n# Set your build environment (we use this to get psd1 path)\nSet-BuildEnvironment\n\n# Check current FunctionsToExport:\nSelect-String -Path .\\PSSlack\\PSSlack.psd1 -Pattern FunctionsToExport\n\n    # PSSlack\\PSSlack.psd1:61:FunctionsToExport = '*'\n\n# Update the psd1 with Set-ModuleFunction:\nSet-ModuleFunction\n\n# Check FunctionsToExport again:\nSelect-String -Path .\\PSSlack\\PSSlack.psd1 -Pattern FunctionsToExport\n\n    # PSSlack\\PSSlack.psd1:61:FunctionsToExport = @('Find-SlackMessage','Get-PSSlackConfig','Get-SlackChannel','Get-SlackHistory','Get-SlackUser','New-SlackField','New-SlackMessage','New-SlackMessageAttachment','Send-SlackApi','Send-SlackFile','Send-SlackMessage','Set-PSSlackConfig')\n```\n\n### Update your ModuleVersion\n\nTypical examples take an existing PSD1 file and bump the module version from that.  Not so helpful if you don't commit that version to Git: The next time you bump the version, you're bumping the original version.\n\n```powershell\n# Get the latest version for a project\n$Version = Get-NextNugetPackageVersion -Name $env:BHProjectName\n\n# Update the module metadata with the new version - thanks to Joel Bennett for this function!\nUpdate-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -Value $Version\n```\n\n## Notes\n\nThanks to Joel Bennett for the ConvertTo-Metadata function that we use in Set-ModuleFunction!\n","funding_links":["https://github.com/sponsors/ramblingcookiemonster"],"categories":["PowerShell","🛠️ Build Tools","Build Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRamblingCookieMonster%2FBuildHelpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRamblingCookieMonster%2FBuildHelpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRamblingCookieMonster%2FBuildHelpers/lists"}