From 03bbcfce082242c36bd27864d906c6c1c244bc65 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 18:23:13 -0700 Subject: [PATCH 01/10] First pass at automatic deployment --- .github/workflows/ci.github-action.yml | 27 +++++++++++++++++++++----- ReadMe.md | 2 +- ValidateJson.build.ps1 | 6 +++++- tools/nuspec.template | 2 +- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.github-action.yml b/.github/workflows/ci.github-action.yml index 3907b0b..24318aa 100644 --- a/.github/workflows/ci.github-action.yml +++ b/.github/workflows/ci.github-action.yml @@ -118,12 +118,29 @@ jobs: Write-Output "tag=latest" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append Write-Output "release_name=v$env:VERSION" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - - name: Create Release - uses: "marvinpinto/action-automatic-releases@latest" + - name: Get Merged Pull Request + id: merged_pr + uses: actions-ecosystem/action-get-merged-pull-request@v1.0.1 + if: ${{ github.ref == 'refs/heads/main' }} with: - title: ${{ join(steps.*.outputs.release_name) }} - automatic_release_tag: ${{ join(steps.*.outputs.tag) }} + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Github Release + uses: softprops/action-gh-release@v1 + with: + name: ${{ join(steps.*.outputs.release_name) }} + tag_name: ${{ join(steps.*.outputs.tag) }} prerelease: ${{ github.ref != 'refs/heads/main' }} - repo_token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} + append_body: true + body: ${{ steps.merged_pr.body }} files: | ValidateJson-${{ steps.version.outputs.version_number }}.zip + + - name: Publish to Powershell Gallery + # if: ${{ github.ref == 'refs/heads/main' }} + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + RELEASE_NOTES: ${{ steps.merged_pr.body || 'GITHUB TEST DEPLOY' }} + run: | + Invoke-Build publish diff --git a/ReadMe.md b/ReadMe.md index f48574a..a39964c 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -15,7 +15,7 @@ The project relies on the [NJsonSchema](https://github.com/RicoSuter/NJsonSchem - ~~Manual Publish to PSGallery~~ - ~~GitHub Actions CI~~ - ~~CI required on PRs~~ -- GitHub Actions CD w/psgallery publish ~~and GitHub Artifacts~~ +- INPROGRESS GitHub Actions CD w/psgallery publish ~~and GitHub Artifacts~~ - ~~Pester Unit Testing~~ - ~~Help docs with [platyPS](https://github.com/PowerShell/platyPS)~~ - Add Code coverage report diff --git a/ValidateJson.build.ps1 b/ValidateJson.build.ps1 index 6b22ef7..6e63dec 100644 --- a/ValidateJson.build.ps1 +++ b/ValidateJson.build.ps1 @@ -151,7 +151,11 @@ task package rebuild, generate_package, analyze # publish package task publish install_packages, generate_package, { - Publish-Module -Path "$BuildRoot\dist\$module_name" -NuGetApiKey $env:NuGetApiKey -Force + $extraParams = @{} + if($env:RELEASE_NOTES) { + $extraParams["ReleaseNotes"] = $env:RELEASE_NOTES + } + Publish-Module -Path "$BuildRoot\dist\$module_name" -NuGetApiKey $env:NUGET_API_KEY @extraParams -Force } # default tasks diff --git a/tools/nuspec.template b/tools/nuspec.template index 796ae1d..215b936 100644 --- a/tools/nuspec.template +++ b/tools/nuspec.template @@ -3,7 +3,7 @@ - 0.3.1 + 0.3.2 mdlopresti From 53498f339b36b518eab363b80e7ce66feb22e90b Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 18:24:43 -0700 Subject: [PATCH 02/10] Adding github actions status bagdge --- ReadMe.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ReadMe.md b/ReadMe.md index a39964c..8315756 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,5 +1,7 @@ # ValidateJson +[![.github/workflows/ci.github-action.yml](https://github.com/mdlopresti/ValidateJson/actions/workflows/ci.github-action.yml/badge.svg)](https://github.com/mdlopresti/ValidateJson/actions/workflows/ci.github-action.yml) + Json validation for older PowerShell. ## Description From fbdb4f83c9940b5391cfcbc4dae2d33e1ed6fd03 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 18:25:38 -0700 Subject: [PATCH 03/10] version bump --- tools/nuspec.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/nuspec.template b/tools/nuspec.template index 215b936..7e0d3f4 100644 --- a/tools/nuspec.template +++ b/tools/nuspec.template @@ -3,7 +3,7 @@ - 0.3.2 + 0.3.3 mdlopresti From d07d911a11e4c88a6febe1fb839eebdc0b66c4f2 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 18:29:18 -0700 Subject: [PATCH 04/10] commenting out if statement so test triggers --- .github/workflows/ci.github-action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.github-action.yml b/.github/workflows/ci.github-action.yml index 24318aa..e1a97a5 100644 --- a/.github/workflows/ci.github-action.yml +++ b/.github/workflows/ci.github-action.yml @@ -78,7 +78,7 @@ jobs: permissions: contents: write runs-on: windows-latest - if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' + # if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' defaults: run: shell: ${{ env.SHELL }} @@ -141,6 +141,6 @@ jobs: # if: ${{ github.ref == 'refs/heads/main' }} env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - RELEASE_NOTES: ${{ steps.merged_pr.body || 'GITHUB TEST DEPLOY' }} + RELEASE_NOTES: ${{ steps.merged_pr.body || github.event.pull_request.description || 'GITHUB TEST DEPLOY' }} run: | Invoke-Build publish From 2034f22b07a4e4c643969ecfce26c29ee803f653 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 19:08:01 -0700 Subject: [PATCH 05/10] Adding command to install needed module --- .github/workflows/ci.github-action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.github-action.yml b/.github/workflows/ci.github-action.yml index e1a97a5..725ddd3 100644 --- a/.github/workflows/ci.github-action.yml +++ b/.github/workflows/ci.github-action.yml @@ -143,4 +143,5 @@ jobs: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} RELEASE_NOTES: ${{ steps.merged_pr.body || github.event.pull_request.description || 'GITHUB TEST DEPLOY' }} run: | + Install-Module "InvokeBuild" -Scope CurrentUser -Force Invoke-Build publish From b9d5067a5d43f938750fbafbdd724791a9759490 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 19:31:30 -0700 Subject: [PATCH 06/10] Created seperate psgallery_release job --- .github/workflows/ci.github-action.yml | 41 ++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.github-action.yml b/.github/workflows/ci.github-action.yml index 725ddd3..5d184ce 100644 --- a/.github/workflows/ci.github-action.yml +++ b/.github/workflows/ci.github-action.yml @@ -73,12 +73,12 @@ jobs: path: dist/ValidateJson.zip retention-days: 7 - release: + gh_release: needs: package permissions: contents: write runs-on: windows-latest - # if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' defaults: run: shell: ${{ env.SHELL }} @@ -137,11 +137,40 @@ jobs: files: | ValidateJson-${{ steps.version.outputs.version_number }}.zip + psgallery_release: + needs: package + runs-on: windows-latest + # if: ${{ github.ref == 'refs/heads/main' }} + defaults: + run: + shell: ${{ env.SHELL }} + steps: + - uses: actions/checkout@v4 + + - name: Setup Environment + uses: "./.github/template/setup" + with: + shell: ${{ env.SHELL }} + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Prod Tag + id: prod_tag + if: github.ref == 'refs/heads/main' + env: + VERSION: ${{ steps.version.outputs.version_number }} + RUN_ID: ${{ github.run_id }} + run: | + Write-Output "tag=latest" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Output "release_name=v$env:VERSION" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + + - name: Get Merged Pull Request + id: merged_pr + uses: actions-ecosystem/action-get-merged-pull-request@v1.0.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Publish to Powershell Gallery - # if: ${{ github.ref == 'refs/heads/main' }} env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} RELEASE_NOTES: ${{ steps.merged_pr.body || github.event.pull_request.description || 'GITHUB TEST DEPLOY' }} - run: | - Install-Module "InvokeBuild" -Scope CurrentUser -Force - Invoke-Build publish + run: Invoke-Build publish From 6eb0764df07798c835ad2cef33217785c557624c Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 19:32:28 -0700 Subject: [PATCH 07/10] renameing github release job --- .github/workflows/ci.github-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.github-action.yml b/.github/workflows/ci.github-action.yml index 5d184ce..888d310 100644 --- a/.github/workflows/ci.github-action.yml +++ b/.github/workflows/ci.github-action.yml @@ -73,7 +73,7 @@ jobs: path: dist/ValidateJson.zip retention-days: 7 - gh_release: + github_release: needs: package permissions: contents: write From 82b4507d6b3794d30b27eba7e5911c5e3721e8bc Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 20:04:42 -0700 Subject: [PATCH 08/10] Cleanup and enable final version --- .github/workflows/ci.github-action.yml | 12 +----------- ValidateJson.build.ps1 | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.github-action.yml b/.github/workflows/ci.github-action.yml index 888d310..2b530d3 100644 --- a/.github/workflows/ci.github-action.yml +++ b/.github/workflows/ci.github-action.yml @@ -140,7 +140,7 @@ jobs: psgallery_release: needs: package runs-on: windows-latest - # if: ${{ github.ref == 'refs/heads/main' }} + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' defaults: run: shell: ${{ env.SHELL }} @@ -153,16 +153,6 @@ jobs: shell: ${{ env.SHELL }} github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Build Prod Tag - id: prod_tag - if: github.ref == 'refs/heads/main' - env: - VERSION: ${{ steps.version.outputs.version_number }} - RUN_ID: ${{ github.run_id }} - run: | - Write-Output "tag=latest" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - Write-Output "release_name=v$env:VERSION" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - - name: Get Merged Pull Request id: merged_pr uses: actions-ecosystem/action-get-merged-pull-request@v1.0.1 diff --git a/ValidateJson.build.ps1 b/ValidateJson.build.ps1 index 6e63dec..a66b516 100644 --- a/ValidateJson.build.ps1 +++ b/ValidateJson.build.ps1 @@ -147,7 +147,7 @@ task generate_package generate_manifest, { Compress-Archive -Path "$BuildRoot\dist\$module_name\*" -DestinationPath "$BuildRoot\dist\$module_name.zip" } } -task package rebuild, generate_package, analyze +task package rebuild, generate_package # publish package task publish install_packages, generate_package, { From 81aa48128197effa0fbf08ba8428e72213e23bb3 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 20:05:15 -0700 Subject: [PATCH 09/10] Bump to Verison 1.0.0 --- tools/nuspec.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/nuspec.template b/tools/nuspec.template index 7e0d3f4..cf7771c 100644 --- a/tools/nuspec.template +++ b/tools/nuspec.template @@ -3,7 +3,7 @@ - 0.3.3 + 1.0.0 mdlopresti From 5f668e2d61eb99855713d7244da3373953349e65 Mon Sep 17 00:00:00 2001 From: Michael LoPresti Date: Sun, 15 Oct 2023 20:06:22 -0700 Subject: [PATCH 10/10] Updated Readme --- ReadMe.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReadMe.md b/ReadMe.md index 8315756..4981e87 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -17,7 +17,8 @@ The project relies on the [NJsonSchema](https://github.com/RicoSuter/NJsonSchem - ~~Manual Publish to PSGallery~~ - ~~GitHub Actions CI~~ - ~~CI required on PRs~~ -- INPROGRESS GitHub Actions CD w/psgallery publish ~~and GitHub Artifacts~~ +- ~~GitHub Actions CD w/psgallery publish and GitHub Artifacts~~ - ~~Pester Unit Testing~~ - ~~Help docs with [platyPS](https://github.com/PowerShell/platyPS)~~ +- Add documentation update to CI process - Add Code coverage report