-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (129 loc) · 4.33 KB
/
ci.github-action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
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
- 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