-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (169 loc) · 6.08 KB
/
main.yml
File metadata and controls
183 lines (169 loc) · 6.08 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: CI
on:
push:
branches:
- main
- preview
- next-release
tags:
- 'v*'
paths-ignore:
- 'CHANGELOG.md'
- 'README.md'
- '.github/workflows/main.yml'
pull_request:
branches: [ "main" ]
paths-ignore:
- 'CHANGELOG.md'
workflow_dispatch:
env:
buildFolderName: output
buildArtifactName: output
testResultFolderName: testResults
jobs:
# prepare:
# runs-on: windows-latest
# outputs:
# semVer: ${{ steps.version.outputs.LegacySemVerPadded }}
# fullSemVer: ${{ steps.version.outputs.LegacySemVerPadded }}
# major: ${{ steps.version.outputs.major }}
# minor: ${{ steps.version.outputs.minor }}
# patch: ${{ steps.version.outputs.patch }}
# steps:
# # Checkout code
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# # Install GitVersion and calculate version
# - name: Setup GitVersion
# uses: gittools/actions/gitversion/setup@v3.2.1
# with:
# versionSpec: '5.12.0'
# - name: Determine Version
# id: version # step id used as a reference for output values
# uses: gittools/actions/gitversion/execute@v3.2.1
# with:
# useConfigFile: true
# configFilePath: 'GitVersion.yml'
# - name: Display GitVersion outputs
# run: |
# echo "SemVer: ${{ steps.version.outputs.LegacySemVerPadded }}"
# echo "FullSemVer: ${{ steps.version.outputs.LegacySemVerPadded }}"
# echo "Major: ${{ steps.version.outputs.major }}"
# echo "Minor: ${{ steps.version.outputs.minor }}"
# echo "Patch: ${{ steps.version.outputs.patch }}"
Build_Stage_Package_Module:
name: Package Module
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # checkout the correct branch name
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.15
with:
versionSpec: 5.x
- name: Evaluate Next Version
uses: gittools/actions/gitversion/execute@v0.9.15
with:
configFilePath: GitVersion.yml
- name: Build & Package Module
shell: pwsh
run: ./build.ps1 -ResolveDependency -tasks pack -Verbose
env:
ModuleVersion: ${{ env.gitVersion.NuGetVersionV2 }}
- name: Publish Build Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.buildArtifactName }}
path: ${{ env.buildFolderName }}/
test_powershell_core:
name: Test Windows PowerShell Core
runs-on: windows-latest
needs: Build_Stage_Package_Module
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # checkout the correct branch name
fetch-depth: 0
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.buildArtifactName }}
path: ${{ env.buildFolderName }}
- name: Run Tests
shell: pwsh
run: ./build.ps1 -tasks noop; ./build.ps1 -tasks test
- name: Publish Test Artifact
uses: actions/upload-artifact@v4
with:
path: ${{ env.buildFolderName }}/${{ env.testResultFolderName }}/
name: CodeCoverageWinPS7
if: success() || failure()
deploy:
name: Deploy Module
runs-on: windows-latest
needs: test_powershell_core
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # checkout the correct branch name
fetch-depth: 0
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.buildArtifactName }}
path: ${{ env.buildFolderName }}
- name: Publish Release
shell: pwsh
run: ./build.ps1 -tasks publish
env:
GitHubToken: ${{ secrets.GitHubToken }}
GalleryApiToken: ${{ secrets.GalleryApiToken }}
# deploy:
# runs-on: windows-latest
# # needs: [prepare, test_powershell_core, test_windows_powershell]
# needs: [prepare, test_powershell_core]
# env:
# ModuleVersion: ${{ needs.prepare.outputs.LegacySemVerPadded }}
# ModuleFullVersion: ${{ needs.prepare.outputs.LegacySemVerPadded }}
# ModuleMajor: ${{ needs.prepare.outputs.major }}
# ModuleMinor: ${{ needs.prepare.outputs.minor }}
# ModulePatch: ${{ needs.prepare.outputs.patch }}
# # if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
# if: |
# github.ref == 'refs/heads/main' ||
# github.ref == 'refs/heads/preview' ||
# github.ref == 'refs/heads/next-release' ||
# startsWith(github.ref, 'refs/tags/')
# steps:
# # Checkout code and set up .NET Core environment for deployment stage.
# - name: Checkout code and set up .NET Core environment.
# uses: actions/checkout@v2
# # # Check PSRepository for deployment stage.
# # - name: Check PSRepository
# # run: |
# # if (Get-PSResourceRepository -Name ${{ secrets.repositoryName }} -ErrorAction SilentlyContinue) {
# # Unregister-PSResourceRepository -Name ${{ secrets.repositoryName }}
# # }
# # Register-PSResourceRepository -Name ${{ secrets.repositoryName }} -Uri ${{ secrets.repositoryUri }} -Trusted
# # Get-PSResourceRepository -Name ${{ secrets.repositoryName }} -ErrorAction Stop
# # shell: pwsh
# # Build Release package using the build script.
# - name: Build Release
# run: $verbosePreference='Continue'; ./build.ps1 -tasks pack -ResolveDependency -UseModuleFast
# shell: pwsh
# # Publish Release package to the repository.
# - name: Publish Release
# run: ./build.ps1 -tasks publish -UseModuleFast
# shell: pwsh
# env:
# # ReleaseBranch: ${{ secrets.defaultBranch }}
# # MainGitBranch: ${{ secrets.defaultBranch }}
# GalleryApiToken: ${{ secrets.GalleryApiToken }}
# # PSModuleFeed: ${{ secrets.repositoryName }}