-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (142 loc) · 4.89 KB
/
Copy pathrelease-pipline.yml
File metadata and controls
169 lines (142 loc) · 4.89 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
#
# Inputs (Action Inputs) : kebab-case (all lowercase letters with hyphens)
# Outputs (Action Outputs): camelCase (lowercase first letter with uppercase subsequent words)
# Environment Variables : UPPERCASE_WITH_UNDERSCORES
# Job Names : PascalCase or Title Case
# Step IDs : snake_case or kebab-case
#
name: Build, Test & Release
# Permissions for the workflow
permissions:
contents: write
checks: write
pull-requests: write
statuses: write
# Trigger workflow on push to the main branch
on:
push:
branches:
- main
env:
#
# Build and release settings
ARTIFACT_TYPE : 'Production'
DOTNET_VERSION : '8.0.x'
BINARIES_DIRECTORY : ${{ github.workspace }}/binaries
BUILD_CONFIGURATION : 'Release'
SOLUTION_NAME : 'G4'
STAGE_DIRECTORY : ${{ github.workspace }}/artifact_staging
#
# Publish settings
NUGET_API_KEY : ${{ secrets.NUGET_PUBLIC_KEY }}
NUGET_SOURCE : ${{ vars.NUGET_PUBLIC_SOURCE }}
#
# Test settings
BROWSERSTACK_API_KEY: ${{ secrets.BROWSERSTACK_API_KEY }}
BROWSERSTACK_USER : ${{ secrets.BROWSERSTACK_USER }}
G4_API_KEY : ${{ secrets.G4_API_KEY }}
GRID_ENDPOINT : ${{ secrets.GRID_ENDPOINT }}
RUN_SETTINGS_FILE : 'Default.runsettings'
TEST_WORKERS : '5'
# Default settings for all run steps
defaults:
run:
working-directory: src
jobs:
NewVersion:
name: New Version
runs-on: ubuntu-latest
outputs:
buildVersion: ${{ steps.parse-version.outputs.version }}
validVersion: ${{ steps.validate-version.outputs.valid }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Parse Build Version for GitHub Tag
id: parse-version
shell: pwsh
run: echo "version=$(Get-Date -UFormat '%Y.%m.%d').${{ github.run_number }}" >> $env:GITHUB_OUTPUT
- name: Validate Version ${{ steps.parse-version.outputs.version }}
id: validate-version
shell: pwsh
run: |
$version = "${{ steps.parse-version.outputs.version }}"
echo "valid=$($version -match '^\d+(\.\d+){3}$')" >> $env:GITHUB_OUTPUT
NewBuild:
name: Restore & Build
runs-on: ubuntu-latest
if: ${{ needs.NewVersion.result == 'success' && needs.NewVersion.outputs.validVersion == 'True' }}
needs:
- NewVersion
env:
BUILD_VERSION: ${{ needs.NewVersion.outputs.buildVersion }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "${{ env.DOTNET_VERSION }}"
- name: Restore Dependencies
shell: pwsh
run: dotnet restore
- name: Build ${{ env.SOLUTION_NAME }} v${{ env.BUILD_VERSION }}
shell: pwsh
run: dotnet build
PublishNugetPackages:
name: Publish & Push NuGet Packages v${{ needs.NewVersion.outputs.buildVersion }}
runs-on: ubuntu-latest
if: ${{ needs.NewBuild.result == 'success' }}
needs:
- NewVersion
- NewBuild
defaults:
run:
working-directory: ${{ github.workspace }}
env:
BUILD_VERSION: ${{ needs.NewVersion.outputs.buildVersion }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: New Packages v${{ env.BUILD_VERSION }}
shell: pwsh
run: dotnet pack -o ${{ env.STAGE_DIRECTORY }} -c ${{ env.BUILD_CONFIGURATION }} /p:Version=${{ env.BUILD_VERSION }}
working-directory: src
- name: Publish Build Artifacts to NuGet Feed
shell: pwsh
run: |
dotnet nuget push "${{ env.STAGE_DIRECTORY }}/*.nupkg" --api-key ${{ env.NUGET_API_KEY }} --source ${{ env.NUGET_SOURCE }}
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages-drop-v${{ env.BUILD_VERSION }}
path: ${{ env.STAGE_DIRECTORY }}/*.nupkg
NewRelease:
name: New GitHub Release Version ${{ needs.NewVersion.outputs.buildVersion }}
runs-on: ubuntu-latest
if: ${{ needs.NewVersion.result == 'success' && needs.NewVersion.outputs.validVersion == 'True' && needs.PublishNugetPackages.result == 'success' }}
needs:
- NewVersion
- PublishNugetPackages
env:
BUILD_VERSION: ${{ needs.NewVersion.outputs.buildVersion }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
path: ${{ env.STAGE_DIRECTORY }}
- name: List Downloaded Files
run: |
ls -R ${{ env.STAGE_DIRECTORY }}
- name: Create GitHub Release & Tag v${{ env.BUILD_VERSION }}
uses: softprops/action-gh-release@v2
with:
files: |
**/*.zip
**/*.nupkg
tag_name: v${{ env.BUILD_VERSION }}
name: ${{ env.ARTIFACT_TYPE }} v${{ env.BUILD_VERSION }}
generate_release_notes: true