Skip to content

Commit

Permalink
♻ Makes Module Exports Explicit (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
brucificus committed Oct 3, 2023
1 parent c4f8b14 commit 7186589
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 49 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
steps:
- run: echo "Beginning release."
- name: "Transfer 'version-json' artifact from triggering workflow"
uses: pwshrc/actions-transfer-artifact@v0.3.7
uses: pwshrc/actions-transfer-artifact@v0.3.9
with:
name: 'version-json'
- name: "Transfer 'PSGallery-package' artifact from triggering workflow"
uses: pwshrc/actions-transfer-artifact@v0.3.7
uses: pwshrc/actions-transfer-artifact@v0.3.9
with:
name: 'PSGallery-package'
- name: "Transfer 'release-notes' artifact from triggering workflow"
uses: pwshrc/actions-transfer-artifact@v0.3.7
uses: pwshrc/actions-transfer-artifact@v0.3.9
with:
name: 'release-notes'

Expand All @@ -33,10 +33,10 @@ jobs:
needs: [begin-release]
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Populate GitVersion variables
id: gitversion_vars
uses: pwshrc/actions-determine-version@v0.8.5
uses: pwshrc/actions-determine-version@v0.8.6
with:
mode: 'download'
- name: "Get artifact: PSGallery-package"
Expand All @@ -46,12 +46,12 @@ jobs:
path: ./out/
- name: Publish Prerelease to PSGallery (WhatIf)
if: steps.gitversion_vars.outputs.PreReleaseTag != ''
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9
with:
run: ./build/publish.ps1 -NUGET_KEY "abc" -Prerelease -WhatIf
- name: Publish Release to PSGallery (WhatIf)
if: steps.gitversion_vars.outputs.PreReleaseTag == ''
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9
with:
run: ./build/publish.ps1 -NUGET_KEY "abc" -WhatIf

Expand All @@ -61,10 +61,10 @@ jobs:
needs: [test-publish-psgallery-package]
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Populate GitVersion variables
id: gitversion_vars
uses: pwshrc/actions-determine-version@v0.8.5
uses: pwshrc/actions-determine-version@v0.8.6
with:
mode: 'download'
- name: "Get artifact: PSGallery-package"
Expand All @@ -74,14 +74,14 @@ jobs:
path: ./out/
- name: Publish Prerelease to PSGallery
if: steps.gitversion_vars.outputs.PreReleaseTag != ''
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
with:
run: ./build/publish.ps1 -NUGET_KEY "$env:NUGET_KEY" -Prerelease
- name: Publish Release to PSGallery
if: steps.gitversion_vars.outputs.PreReleaseTag == ''
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
with:
Expand All @@ -93,15 +93,15 @@ jobs:
needs: [publish-psgallery-package]
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Get GitVersion
id: gitversion_vars
uses: pwshrc/actions-determine-version@v0.8.5
uses: pwshrc/actions-determine-version@v0.8.6
with:
mode: 'download'
- name: Get release notes
id: get-releasenotes
uses: pwshrc/actions-create-release-notes@v0.8.6
uses: pwshrc/actions-create-release-notes@v0.8.8
with:
mode: 'download'
github_token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/review-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Review Dependabot PR
uses: pwshrc/actions-review-dependabot@v0.6.0
uses: pwshrc/actions-review-dependabot@v0.6.2
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
required-pr-user-login: 'dependabot[bot]'
Expand Down
29 changes: 16 additions & 13 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Lint with PSScriptAnalyzer
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9
with:
run: ./build/lint.ps1 -CI -NoFail:([bool]"${{ secrets.MANDATE_LINT_SUCCESS != 'true' }}")

Expand All @@ -24,7 +24,7 @@ jobs:
steps:
- name: Populate GitVersion variables
id: gitversion_vars
uses: pwshrc/actions-determine-version@v0.8.5
uses: pwshrc/actions-determine-version@v0.8.6
with:
mode: 'upload'

Expand All @@ -34,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create release notes
uses: pwshrc/actions-create-release-notes@v0.8.6
uses: pwshrc/actions-create-release-notes@v0.8.8
with:
mode: 'upload'
github_token: "${{ secrets.GITHUB_TOKEN }}"
Expand All @@ -45,30 +45,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Populate GitVersion
id: gitversion_vars
uses: pwshrc/actions-determine-version@v0.8.5
uses: pwshrc/actions-determine-version@v0.8.6
with:
mode: 'download'
- name: Populate release notes
id: get-releasenotes
uses: pwshrc/actions-create-release-notes@v0.8.6
uses: pwshrc/actions-create-release-notes@v0.8.8
with:
mode: 'download'
github_token: "${{ secrets.GITHUB_TOKEN }}"
- name: Build PSGallery package
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9
env:
PackageVersionNuGet: ${{ steps.gitversion_vars.outputs.NuGetVersionV2 }}
PackageVersionMajorMinorPatchBuild: ${{ steps.gitversion_vars.outputs.AssemblySemVer }}
PackageVersion: ${{ steps.gitversion_vars.outputs.NuGetVersionV2 }}
ModuleVersionMajor: ${{ steps.gitversion_vars.outputs.Major }}
ModuleVersionMinor: ${{ steps.gitversion_vars.outputs.Minor }}
ModuleVersionPatch: ${{ steps.gitversion_vars.outputs.Patch }}
PackageVersionPrereleaseTag: ${{ steps.gitversion_vars.outputs.PreReleaseTag }}
CommitSha: ${{ steps.gitversion_vars.outputs.Sha }}
ReleaseNotesFilepath: ${{ steps.get-releasenotes.outputs.filepath }}
with:
run: |
[string] $releaseNotes = (Get-Content -Raw -Path ./out/release-notes.md -Encoding UTF8).Trim()
./build/package.ps1 -PackageVersionNuGet $Env:PackageVersionNuGet -PackageVersionMajorMinorPatchBuild $Env:PackageVersionMajorMinorPatchBuild -PackageVersionPrereleaseTag $Env:PackageVersionPrereleaseTag -ReleaseNotes $releaseNotes -CommitSha $Env:CommitSha
[Version] $moduleVersion = [Version]::new($Env:ModuleVersionMajor, $Env:ModuleVersionMinor, $Env:ModuleVersionPatch)
./build/package.ps1 -PackageVersion $Env:PackageVersion -ModuleVersion $moduleVersion -PackageVersionPrereleaseTag $Env:PackageVersionPrereleaseTag -ReleaseNotes $releaseNotes -CommitSha $Env:CommitSha
- name: "Create artifact: PSGallery-package"
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -102,14 +105,14 @@ jobs:
needs: build-release-package
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: "Get artifact: PSGallery-package"
uses: actions/download-artifact@v3
with:
name: PSGallery-package
path: ./out/
- name: Test with Pester
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.7
uses: pwshrc/actions-invoke-lib-dependent-pwsh@v0.2.9
with:
run: ./build/test.ps1 -UsePackageExport -CI -OutputFilesPrefix "${{ matrix.os }}-" -NoFail:([bool]"${{ matrix.experimental }}")
- name: "Create artifact: tests-${{ matrix.os }}"
Expand Down
6 changes: 3 additions & 3 deletions build/funcs/New-ModuleManifestCustomized.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ function New-ModuleManifestCustomized {
[string] $PackageVersion,

[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $PackageVersionMajorMinorPatchBuild,
[ValidateNotNull()]
[Version] $ModuleVersion,

[Parameter(Mandatory = $false)]
[string] $PackageVersionPrereleaseTag,
Expand Down Expand Up @@ -159,7 +159,7 @@ function New-ModuleManifestCustomized {
-CompanyName $CompanyName `
-Description $packageSynopsis `
-Copyright $PackageCopyright `
-ModuleVersion $PackageVersion `
-ModuleVersion $ModuleVersion `
-Guid $PackageGuid `
-Tags $PackageTags `
-LicenseUri "${ProjectUrlAtVersion}/${LicenseFileName}" `
Expand Down
22 changes: 14 additions & 8 deletions build/package-dev.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,36 @@ elseif (Get-Command gitversion -ErrorAction SilentlyContinue) {
if ($gitversion_bin) {
[PSObject] $versionInfo = & $gitversion_bin | ConvertFrom-Json

[string] $PackageVersionNuGet = $versionInfo | Select-Object -ExpandProperty NuGetVersionV2
[string] $PackageVersion = $versionInfo | Select-Object -ExpandProperty NuGetVersionV2
[string] $PackageVersionPrereleaseTag = $versionInfo | Select-Object -ExpandProperty PreReleaseTag
[string] $PackageVersionMajorMinorPatchBuild = $versionInfo | Select-Object -ExpandProperty AssemblySemVer
[string] $assemblySemVer = $versionInfo | Select-Object -ExpandProperty AssemblySemVer
[string] $CommitSha = $versionInfo | Select-Object -ExpandProperty Sha
} else {
[string] $PackageVersionNuGet = "0.0.1"
[string] $PackageVersion = "0.0.1"
[string] $PackageVersionPrereleaseTag = $null
[string] $PackageVersionMajorMinorPatchBuild = "0.0.1.0"
[string] $assemblySemVer = "0.0.1"
[string] $CommitSha = (git rev-parse HEAD)
}
[string] $ReleaseNotes = "Fake Release Notes"

if (-not $PackageVersionPrereleaseTag) {
$PackageVersionNuGet += "-dev"
$PackageVersion += "-dev"
$PackageVersionPrereleaseTag = "dev"
} else {
$PackageVersionNuGet = $PackageVersionNuGet.Replace("-" + $PackageVersionPrereleaseTag, "-dev-" + $PackageVersionPrereleaseTag)
$PackageVersion = $PackageVersion.Replace("-" + $PackageVersionPrereleaseTag, "-dev-" + $PackageVersionPrereleaseTag)
$PackageVersionPrereleaseTag = "dev-" + $PackageVersionPrereleaseTag
}

if (-not $PackageVersionPrereleaseTag) {
[Version] $moduleVersion = [Version] $assemblySemVer
} else {
[Version] $moduleVersion = [Version] ($assemblySemVer -replace "-$PackageVersionPrereleaseTag", "")
}

[string] $ds = [System.IO.Path]::DirectorySeparatorChar
& "${PSScriptRoot}${ds}package.ps1" `
-PackageVersionNuGet $PackageVersionNuGet `
-PackageVersionMajorMinorPatchBuild $PackageVersionMajorMinorPatchBuild `
-PackageVersion $PackageVersion `
-ModuleVersion $moduleVersion `
-PackageVersionPrereleaseTag $PackageVersionPrereleaseTag `
-ReleaseNotes $ReleaseNotes `
-CommitSha $CommitSha
13 changes: 6 additions & 7 deletions build/package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $PackageVersionNuGet,
[string] $PackageVersion,

[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $PackageVersionMajorMinorPatchBuild,
[ValidateNotNull()]
[Version] $ModuleVersion,

[Parameter(Mandatory = $false)]
[string] $PackageVersionPrereleaseTag,
Expand Down Expand Up @@ -61,7 +61,6 @@ Set-StrictMode -Version Latest

. "${PSScriptRoot}${ds}funcs${ds}Get-PSGalleryModuleNested.ps1"
[object[]] $nestedRuntimePSGalleryModules = @(Get-PSGalleryModuleNested -RuntimeDependencies)
[string] $packageVersion = $PackageVersionNuGet

. "${PSScriptRoot}${ds}funcs${ds}New-ModuleManifestCustomized.ps1"
[System.IO.FileInfo] $moduleManifest = New-ModuleManifestCustomized `
Expand All @@ -78,8 +77,8 @@ Set-StrictMode -Version Latest
-PackageCopyright $packageCopyright `
-PackageTags $packageTagsForNuSpec `
-ReleaseNotes $ReleaseNotes `
-PackageVersion $packageVersion `
-PackageVersionMajorMinorPatchBuild $PackageVersionMajorMinorPatchBuild `
-PackageVersion $PackageVersion `
-ModuleVersion $ModuleVersion `
-PackageVersionPrereleaseTag $PackageVersionPrereleaseTag `
-PackageGuid $packageGuid `
-PSEdition_Desktop:$PSEdition_Desktop `
Expand All @@ -90,7 +89,7 @@ Set-StrictMode -Version Latest
. "${PSScriptRoot}${ds}funcs${ds}New-TemporaryProjectFile.ps1"
[System.IO.FileInfo] $projectFile = New-TemporaryProjectFile `
-PackageId $PackageId `
-PackageVersion $packageVersion `
-PackageVersion $PackageVersion `
-CompanyName $companyName `
-Authors $authors `
-GitRepositoryUrl $repositoryGitUrl `
Expand Down
2 changes: 1 addition & 1 deletion packages.PSGallery.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="poshy-env-var" version="0.5.0" />
<package id="poshy-lucidity" version="0.3.2" />
<package id="poshy-lucidity" version="0.3.15" />
<package id="Pester" version="5.5.0" developmentDependency="true" />
<package id="PowerShellGet" version="2.2.5" developmentDependency="true" />
<package id="PSScriptAnalyzer" version="1.21.0" developmentDependency="true" />
Expand Down
Loading

0 comments on commit 7186589

Please sign in to comment.