-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (114 loc) · 3.77 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
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: Create Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
title: ${{ join(steps.*.outputs.release_name) }}
automatic_release_tag: ${{ join(steps.*.outputs.tag) }}
prerelease: ${{ github.ref != 'refs/heads/main' }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
files: |
ValidateJson-${{ steps.version.outputs.version_number }}.zip