Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Publishing to Powershell Gallery #7

Merged
merged 10 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions .github/workflows/ci.github-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
path: dist/ValidateJson.zip
retention-days: 7

release:
github_release:
needs: package
permissions:
contents: write
Expand Down Expand Up @@ -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/[email protected]
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/[email protected]
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
5 changes: 4 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
8 changes: 6 additions & 2 deletions ValidateJson.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/nuspec.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>
</id>
<version>0.3.1</version>
<version>1.0.0</version>
<authors>mdlopresti</authors>
<readme/>
<projectUrl>
Expand Down
Loading