Skip to content

Commit

Permalink
Merge pull request #26 from leojonathanoh/refactor/ci-bump-psmodulepu…
Browse files Browse the repository at this point in the history
…blisher-to-v0.7.0-cleanup-ci-jobs-and-add-powershell-7.3-test-job

Refactor (ci): Bump PSModulePublisher to v0.7.0, cleanup CI jobs, and add powershell 7.3 test job
  • Loading branch information
leojonathanoh authored Nov 16, 2023
2 parents 40cc2c3 + f254068 commit 6866d41
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 143 deletions.
212 changes: 86 additions & 126 deletions .github/workflows/ci-master-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,24 @@ jobs:
test-powershell-5-1-windows-2019:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Display system info (windows)
run: |
Set-StrictMode -Version Latest; $ErrorActionPreference = 'Stop'
hostname
whoami
systeminfo
Get-PSDrive
Get-Location
# pwsh version
$PSVersionTable
# Windows Powershell version?
powershell -Command '$PSVersionTable'
- uses: actions/checkout@v3
- name: Powershell version
run: |
powershell -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Test
run: |
powershell -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'
# macos-10-15:
# runs-on: macos-10.15
# steps:
# - uses: actions/checkout@v2
# - name: Display system info (macos)
# run: |
# set -e
# hostname
# whoami
# df -h
# pwd
# # docker info
# # docker version

##########
# Docker #
##########
# Get powershell tags: https://mcr.microsoft.com/v2/powershell/tags/list
test-powershell-6-0:
runs-on: ubuntu-latest
container:
# image: theohbrothers/docker-powershell:6.0.2-ubuntu-16.04-git
image: mcr.microsoft.com/powershell:6.0.2-ubuntu-16.04
image: mcr.microsoft.com/powershell:6.0.4-ubuntu-16.04
steps:
- uses: actions/checkout@v2
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
lscpu
free
df -h
pwd
- uses: actions/checkout@v3
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
Expand All @@ -78,21 +42,9 @@ jobs:
test-powershell-6-1:
runs-on: ubuntu-latest
container:
# image: theohbrothers/docker-powershell:6.1.3-alpine-3.8-git
# image: mcr.microsoft.com/powershell:6.1.3-alpine-3.8
image: mcr.microsoft.com/powershell:6.1.3-ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
# lscpu
free
df -h
pwd
- uses: actions/checkout@v3
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
Expand All @@ -103,21 +55,9 @@ jobs:
test-powershell-6-2:
runs-on: ubuntu-latest
container:
# image: theohbrothers/docker-powershell:6.2.4-alpine-3.8-git
# image: mcr.microsoft.com/powershell:6.2.4-alpine-3.8
image: mcr.microsoft.com/powershell:6.2.4-ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
# lscpu
free
df -h
pwd
- uses: actions/checkout@v3
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
Expand All @@ -128,21 +68,9 @@ jobs:
test-powershell-7-0:
runs-on: ubuntu-latest
container:
# image: theohbrothers/docker-powershell:7.0.3-alpine-3.9-20200928
# image: mcr.microsoft.com/powershell:7.0.3-alpine-3.9
image: mcr.microsoft.com/powershell:7.0.3-ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
# lscpu
free
df -h
pwd
- uses: actions/checkout@v3
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
Expand All @@ -153,21 +81,9 @@ jobs:
test-powershell-7-1:
runs-on: ubuntu-latest
container:
# image: theohbrothers/docker-powershell:7.1.3-alpine-3.11-20210316-git
# image: mcr.microsoft.com/powershell:7.1.3-alpine-3.11-20210316
image: mcr.microsoft.com/powershell:7.1.3-ubuntu-18.04
image: mcr.microsoft.com/powershell:7.1.5-ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
# lscpu
free
df -h
pwd
- uses: actions/checkout@v3
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
Expand All @@ -178,21 +94,22 @@ jobs:
test-powershell-7-2:
runs-on: ubuntu-latest
container:
# image: theohbrothers/docker-powershell:7.2.0-preview.4-alpine-3.11-20210316-git
# image: mcr.microsoft.com/powershell:7.2.0-preview.4-alpine-3.11-20210316
image: mcr.microsoft.com/powershell:7.2.0-preview.4-ubuntu-18.04
image: mcr.microsoft.com/powershell:7.2-ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Test
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'
test-powershell-7-3:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/powershell:7.3-ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
# lscpu
free
df -h
pwd
- uses: actions/checkout@v3
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
Expand All @@ -201,54 +118,97 @@ jobs:
pwsh -NoLogo -NonInteractive -NoProfile -Command './test/test.ps1'
update-draft-release:
needs: [test-powershell-5-1-windows-2019, test-powershell-6-0, test-powershell-6-1, test-powershell-6-1, test-powershell-7-0, test-powershell-7-1, test-powershell-7-2]
needs:
- test-powershell-5-1-windows-2019
- test-powershell-6-0
- test-powershell-6-1
- test-powershell-6-2
- test-powershell-7-0
- test-powershell-7-1
- test-powershell-7-2
- test-powershell-7-3
- test-publish-to-psgallery
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

test-publish-to-psgallery:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Publish (dry run)
shell: pwsh
env:
MODULE_VERSION: '999.0.0'
NUGET_API_KEY: 'xxx'
run: |
$ErrorActionPreference = 'Stop'
# Generate the new module manifest
$moduleManifest = ./build/PSModulePublisher/src/PSModulePublisher/Public/Invoke-Build.ps1
# Publish the module
./build/PSModulePublisher/src/PSModulePublisher/Public/Invoke-Publish.ps1 -ModuleManifestPath $moduleManifest -Repository PSGallery -DryRun
publish-to-psgallery:
needs: [test-powershell-5-1-windows-2019, test-powershell-6-0, test-powershell-6-1, test-powershell-6-1, test-powershell-7-0, test-powershell-7-1, test-powershell-7-2]
needs:
- test-powershell-5-1-windows-2019
- test-powershell-6-0
- test-powershell-6-1
- test-powershell-6-2
- test-powershell-7-0
- test-powershell-7-1
- test-powershell-7-2
- test-powershell-7-3
- test-publish-to-psgallery
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: Powershell version
run: |
pwsh -NoLogo -NonInteractive -NoProfile -Command '$PSVersionTable'
- name: Publish
shell: pwsh
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
set -e
# Get 'ref-name' from 'refs/heads/ref-name'
REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev )
$ErrorActionPreference = 'Stop'
# Strip of 'v' prefix from tag
MODULE_VERSION=$( echo "${REF}" | sed 's/^v*//' )
$env:MODULE_VERSION = $env:GITHUB_REF_NAME -replace '^v', ''
# Generate the new module manifest
MODULE_NAME=$(basename $(pwd))
MODULE_VERSION=${MODULE_VERSION} pwsh -Command "build/PSModulePublisher/src/module/Generate-ModuleManifest.ps1 -DefinitionFile build/definitions/modulemanifest/definition.ps1 -Path src/$MODULE_NAME/$MODULE_NAME.psd1"
$moduleManifest = ./build/PSModulePublisher/src/PSModulePublisher/Public/Invoke-Build.ps1
# Publish the module
NUGET_API_KEY=${NUGET_API_KEY} MODULE_VERSION=${MODULE_VERSION} pwsh -Command "build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery"
./build/PSModulePublisher/src/PSModulePublisher/Public/Invoke-Publish.ps1 -ModuleManifestPath $moduleManifest -Repository PSGallery
publish-draft-release:
needs: [test-powershell-5-1-windows-2019, test-powershell-6-0, test-powershell-6-1, test-powershell-6-1, test-powershell-7-0, test-powershell-7-1, test-powershell-7-2, publish-to-psgallery]
needs: [publish-to-psgallery]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- id: release-drafter
uses: release-drafter/release-drafter@v5
with:
# config-name: release-drafter.yaml
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: true
name: ${{ github.ref_name }} # E.g. 'master' or 'v1.2.3'
tag: ${{ github.ref_name }} # E.g. 'master' or 'v1.2.3'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 11 additions & 11 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"id": "NUGET_API_KEY",
"description": "NUGET_API_KEY?",
"type": "promptString",
"default": "",
"default": "xxx",
},
{
"id": "MODULE_VERSION",
"description": "MODULE_VERSION?",
"type": "promptString",
"default": "",
"default": "0.0.0",
},
],
"tasks": [
Expand All @@ -32,25 +32,25 @@
{
"label": "Build: Generate module manifest",
"type": "shell",
"command": "MODULE_NAME=$(basename $(pwd)); MODULE_VERSION=${input:MODULE_VERSION} pwsh -Command \"build/PSModulePublisher/src/module/Generate-ModuleManifest.ps1 -DefinitionFile build/definitions/modulemanifest/definition.ps1 -Path src/$MODULE_NAME/$MODULE_NAME.psd1\"",
"group": "build"
},
{
"label": "Build: Test module manifest",
"type": "shell",
"command": "MODULE_NAME=$(basename $(pwd)); MODULE_VERSION=${input:MODULE_VERSION} pwsh -Command \"build/PSModulePublisher/src/module/Test-ModuleManifest.ps1 -Path src/$MODULE_NAME/$MODULE_NAME.psd1\"",
"command": "MODULE_VERSION=${input:MODULE_VERSION} pwsh build/PSModulePublisher/src/PSModulePublisher/Public/Invoke-Build.ps1",
"group": "build"
},
{
"label": "Publish module (dry run)",
"dependsOn":[
"Build: Generate module manifest"
],
"type": "shell",
"command": "MODULE_NAME=$(basename $(pwd)); NUGET_API_KEY=${input:NUGET_API_KEY} MODULE_VERSION=${input:MODULE_VERSION} pwsh -Command \"build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery -DryRun\"",
"command": "MODULE_NAME=$(basename $(pwd)); NUGET_API_KEY=${input:NUGET_API_KEY} MODULE_VERSION=${input:MODULE_VERSION} pwsh build/PSModulePublisher/src/PSModulePublisher/Public/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery -DryRun",
"group": "build"
},
{
"label": "Publish module",
"dependsOn":[
"Build: Generate module manifest"
],
"type": "shell",
"command": "MODULE_NAME=$(basename $(pwd)); NUGET_API_KEY=${input:NUGET_API_KEY} MODULE_VERSION=${input:MODULE_VERSION} pwsh -Command \"build/PSModulePublisher/src/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery\"",
"command": "MODULE_NAME=$(basename $(pwd)); NUGET_API_KEY=${input:NUGET_API_KEY} MODULE_VERSION=${input:MODULE_VERSION} pwsh build/PSModulePublisher/src/PSModulePublisher/Public/Invoke-Publish.ps1 -ModuleManifestPath src/$MODULE_NAME/$MODULE_NAME.psd1 -Repository PSGallery",
"group": "build"
},

Expand Down
2 changes: 1 addition & 1 deletion build/PSModulePublisher
Submodule PSModulePublisher updated 66 files
+52 −0 .github/release-drafter.yml
+207 −0 .github/workflows/ci-master-pr.yml
+57 −0 .vscode/tasks.json
+31 −37 README.md
+0 −0 docs/samples/build/definitions/modulemanifest.ps1
+21 −8 docs/samples/ci/azure-pipelines/azure-pipelines.linux.container.yml
+2 −2 docs/samples/ci/azure-pipelines/azure-pipelines.linux.sample.yml
+8 −9 docs/samples/ci/azure-pipelines/azure-pipelines.linux.windows.sample.yml
+2 −2 docs/samples/ci/azure-pipelines/azure-pipelines.macos.sample.yml
+1 −1 docs/samples/ci/azure-pipelines/azure-pipelines.windows.powershell.5.1.sample.yml
+2 −2 docs/samples/ci/azure-pipelines/azure-pipelines.windows.pwsh.sample.yml
+0 −0 docs/samples/test/scripts/dep/Install-TestDependencies.ps1
+1 −0 docs/samples/test/scripts/integration/Run-IntegrationTests.ps1
+1 −0 docs/samples/test/test.ps1
+0 −24 src/Invoke-Build.ps1
+0 −26 src/Invoke-Publish.ps1
+24 −0 src/PSModulePublisher/Invoke-PSModulePublisher.Tests.ps1
+4 −3 src/PSModulePublisher/Invoke-PSModulePublisher.ps1
+0 −0 src/PSModulePublisher/Private/Generate-ModuleManifest.ps1
+31 −0 src/PSModulePublisher/Private/Get-ProjectVariables.ps1
+0 −0 src/PSModulePublisher/Private/Install-BuildDependencies.ps1
+1 −0 src/PSModulePublisher/Private/Publish-Module.ps1
+0 −0 src/PSModulePublisher/Private/Test-Module.ps1
+0 −0 src/PSModulePublisher/Private/Test-ModuleManifest.ps1
+42 −0 src/PSModulePublisher/Public/Invoke-Build.ps1
+36 −0 src/PSModulePublisher/Public/Invoke-Publish.ps1
+3 −3 src/PSModulePublisher/Public/Invoke-Test.ps1
+0 −23 src/module/common/Get-ProjectVariables.ps1
+3 −0 templates/azure-pipelines/entrypoint/linux/build-publish.yml
+3 −0 templates/azure-pipelines/entrypoint/linux/build-test.yml
+5 −0 templates/azure-pipelines/entrypoint/linux/build.yml
+2 −5 templates/azure-pipelines/entrypoint/linux/continuous-build.yml
+2 −0 templates/azure-pipelines/entrypoint/linux/test.yml
+3 −0 templates/azure-pipelines/entrypoint/macos/build-publish.yml
+3 −0 templates/azure-pipelines/entrypoint/macos/build-test.yml
+5 −0 templates/azure-pipelines/entrypoint/macos/build.yml
+2 −5 templates/azure-pipelines/entrypoint/macos/continuous-build.yml
+2 −0 templates/azure-pipelines/entrypoint/macos/test.yml
+3 −0 templates/azure-pipelines/entrypoint/windows/build-publish.yml
+3 −0 templates/azure-pipelines/entrypoint/windows/build-test.yml
+5 −0 templates/azure-pipelines/entrypoint/windows/build.yml
+2 −5 templates/azure-pipelines/entrypoint/windows/continuous-build.yml
+3 −0 templates/azure-pipelines/entrypoint/windows/powershell/build-publish.yml
+3 −0 templates/azure-pipelines/entrypoint/windows/powershell/build-test.yml
+5 −0 templates/azure-pipelines/entrypoint/windows/powershell/build.yml
+2 −5 templates/azure-pipelines/entrypoint/windows/powershell/continuous-build.yml
+2 −0 templates/azure-pipelines/entrypoint/windows/powershell/test.yml
+2 −0 templates/azure-pipelines/entrypoint/windows/pwsh/build-publish.yml
+2 −0 templates/azure-pipelines/entrypoint/windows/pwsh/build-test.yml
+2 −0 templates/azure-pipelines/entrypoint/windows/pwsh/build.yml
+2 −0 templates/azure-pipelines/entrypoint/windows/pwsh/test.yml
+2 −0 templates/azure-pipelines/entrypoint/windows/test.yml
+1 −0 templates/azure-pipelines/steps/powershell/install-publish-dependencies.yml
+2 −1 templates/azure-pipelines/steps/powershell/run-build.yml
+2 −1 templates/azure-pipelines/steps/powershell/run-publish.yml
+2 −1 templates/azure-pipelines/steps/powershell/run-test.yml
+2 −1 templates/azure-pipelines/steps/pwsh/run-build.yml
+2 −1 templates/azure-pipelines/steps/pwsh/run-publish.yml
+2 −1 templates/azure-pipelines/steps/pwsh/run-test.yml
+62 −0 test/Mock-Module/build/definitions/modulemanifest.ps1
+132 −0 test/Mock-Module/src/Mock-Module/Mock-Module.psd1
+16 −0 test/Mock-Module/src/Mock-Module/Mock-Module.psm1
+57 −0 test/test.ps1
+1 −1 tools/system/linux/get-systeminfo.sh
+1 −1 tools/system/macos/get-systeminfo.sh
+0 −3 tools/system/windows/Get-SystemInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# FormatsToProcess = @()
# NestedModules = @()
FunctionsToExport = @(
Get-ChildItem $PSScriptRoot/../../../src/PSSourceQuery/public -Exclude *.Tests.ps1 | % { $_.BaseName }
Get-ChildItem $PSScriptRoot/../../src/PSSourceQuery/public -Exclude *.Tests.ps1 | % { $_.BaseName }
)
CmdletsToExport = @()
VariablesToExport = @()
Expand Down
Loading

0 comments on commit 6866d41

Please sign in to comment.