mdlopresti pull_request #73
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run-name: ${{ github.actor }} ${{ github.event_name }} | |
on: | |
push: | |
branches: | |
- feature/* | |
- main | |
paths: | |
- .github/template/** | |
- .github/workflows/ci.github-action.yml | |
- src/** | |
- tools/** | |
- ValidateJson.build.ps1 | |
pull_request: | |
branches: | |
- main | |
env: | |
SHELL: powershell | |
jobs: | |
test: | |
runs-on: windows-latest | |
permissions: | |
checks: write | |
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: Validate | |
run: Invoke-Build validate -ci $true | |
continue-on-error: true | |
- name: Report Test Results | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() | |
with: | |
name: test_results | |
path: test/result/*Test-Result.XML | |
reporter: java-junit | |
package: | |
needs: test | |
runs-on: windows-latest | |
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: Generate Package | |
run: | | |
Invoke-Build clean | |
Invoke-Build generate_package -zipPackage $true | |
- name: Save Package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: package | |
path: dist/ValidateJson.zip | |
retention-days: 7 | |
github_release: | |
needs: package | |
permissions: | |
contents: write | |
runs-on: windows-latest | |
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' | |
defaults: | |
run: | |
shell: ${{ env.SHELL }} | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: package | |
- name: Get Version | |
id: version | |
run: | | |
Expand-Archive -Path ValidateJson.zip | |
$versionNumber = (Import-PowerShellDataFile .\ValidateJson\ValidateJson.psd1)["ModuleVersion"] | |
Write-Output "version_number=$versionNumber" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
Remove-Item -Path .\ValidateJson\ -Force -Recurse | |
- name: Put Version Number in Package | |
run: Move-Item ValidateJson.zip ValidateJson-${{ steps.version.outputs.version_number }}.zip | |
- name: Build Dev Tag | |
id: dev_tag | |
if: github.ref != 'refs/heads/main' | |
env: | |
VERSION: ${{ steps.version.outputs.version_number }} | |
RUN_ID: ${{ github.run_id }} | |
run: | | |
Write-Output "tag=v$env:VERSION.$env:RUN_ID" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
Write-Output "release_name=v$env:VERSION.$env:RUN_ID" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
- 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/[email protected] | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
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' }} | |
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 |