diff --git a/.github/workflows/ci.github-action.yml b/.github/workflows/ci.github-action.yml index 3907b0b..2b530d3 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 - release: + github_release: needs: package permissions: contents: write @@ -118,12 +118,49 @@ 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 + + psgallery_release: + needs: package + runs-on: windows-latest + if: github.event_name == 'pull_request' || 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: 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 + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + RELEASE_NOTES: ${{ steps.merged_pr.body || github.event.pull_request.description || 'GITHUB TEST DEPLOY' }} + run: Invoke-Build publish diff --git a/ReadMe.md b/ReadMe.md index f48574a..4981e87 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 @@ -15,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~~ -- 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 diff --git a/ValidateJson.build.ps1 b/ValidateJson.build.ps1 index 6b22ef7..a66b516 100644 --- a/ValidateJson.build.ps1 +++ b/ValidateJson.build.ps1 @@ -147,11 +147,15 @@ 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, { - 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..cf7771c 100644 --- a/tools/nuspec.template +++ b/tools/nuspec.template @@ -3,7 +3,7 @@ - 0.3.1 + 1.0.0 mdlopresti