@@ -16,73 +16,25 @@ jobs:
16
16
SOLUTION_PATH : MimeKit.sln
17
17
BUILD_PLATFORM : Any CPU
18
18
BUILD_CONFIGURATION : ${{ matrix.build-configuration }}
19
- GITHUB_RUN_NUMBER : ${{ github.run_number }}
19
+ GENERATE_CODE_COVERAGE : ${{ matrix.os == 'windows-latest' && matrix.build-configuration == 'Debug' }}
20
+ MONO_RUNTIME : ${{ matrix.os != 'windows-latest' }}
21
+ PUBLISH : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.os == 'windows-latest' && matrix.build-configuration == 'Release' }}
22
+
20
23
steps :
21
24
- name : Setup/Install the .NET 8 SDK
22
25
id : install-netsdk
23
26
uses : actions/setup-dotnet@v4
24
27
with :
25
28
dotnet-version : 8.0.x
26
29
27
- - name : Configure build options
28
- id : configure
29
- shell : pwsh
30
- run : |
31
- $IS_DEBUG = 'false'
32
- $IS_RELEASE = 'false'
33
- $IS_PUSH_TO_MASTER = 'false'
34
- $IS_NOT_PR = 'true'
35
- $IS_GITHUB_RELEASE = 'false'
36
- $IS_WINDOWS = 'false'
37
- $IS_UBUNTU = 'false'
38
- $GENERATE_CODE_COVERAGE = 'no'
39
-
40
- if ( $env:BUILD_CONFIGURATION -ceq 'Debug' ) {
41
- $IS_DEBUG = 'true'
42
- }
43
- if ( $env:BUILD_CONFIGURATION -ceq 'Release' ) {
44
- $IS_RELEASE = 'true'
45
- }
46
- if ( ($env:GITHUB_EVENT_NAME -ceq 'push') -and ($env:GITHUB_REF -ceq 'refs/heads/master') ) {
47
- $IS_PUSH_TO_MASTER = 'true'
48
- }
49
- if ( $env:GITHUB_EVENT_NAME -ceq 'pull_request' ) {
50
- $IS_NOT_PR = 'false'
51
- }
52
- if ( ($env:GITHUB_EVENT_NAME -ceq 'push') -and ($env:GITHUB_REF -ceq 'refs/heads/master') -and ($env:BUILD_CONFIGURATION -ceq 'Release') -and ($env:OS -ceq 'windows-latest') ) {
53
- $IS_GITHUB_RELEASE = 'true'
54
- }
55
- if ( $env:OS -ceq 'windows-latest' ) {
56
- $IS_WINDOWS = 'true'
57
- }
58
- if ( $env:OS -ceq 'ubuntu-latest' ) {
59
- $IS_UBUNTU = 'true'
60
- }
61
- if ( $IS_WINDOWS -ceq 'true' -and $IS_DEBUG -ceq 'true' ) {
62
- $GENERATE_CODE_COVERAGE = 'yes'
63
- }
64
-
65
- echo "::set-output name=is_debug::$(echo $IS_DEBUG)"
66
- echo "::set-output name=is_release::$(echo $IS_RELEASE)"
67
- echo "::set-output name=is_push_to_master::$(echo $IS_PUSH_TO_MASTER)"
68
- echo "::set-output name=is_not_pr::$(echo $IS_NOT_PR)"
69
- echo "::set-output name=is_github_release::$(echo $IS_GITHUB_RELEASE)"
70
- echo "::set-output name=is_windows::$(echo $IS_WINDOWS)"
71
- echo "::set-output name=is_ubuntu::$(echo $IS_UBUNTU)"
72
- echo "::set-output name=generate_code_coverage::$(echo $GENERATE_CODE_COVERAGE)"
73
- env :
74
- GITHUB_EVENT_NAME : ${{ github.event_name }}
75
- GITHUB_REF : ${{ github.ref }}
76
- OS : ${{ matrix.os }}
77
-
78
- - if : steps.configure.outputs.is_windows == 'true'
30
+ - if : runner.os == 'Windows'
79
31
name : Setup MSBuild
80
32
id : setup_msbuild
81
33
82
34
83
35
- name : Checkout repository
84
36
id : checkout_repo
85
- uses : actions/checkout@v3
37
+ uses : actions/checkout@v4
86
38
with :
87
39
token : ${{ secrets.GITHUB_TOKEN }}
88
40
submodules : recursive
@@ -94,20 +46,28 @@ jobs:
94
46
run : |
95
47
$xml = [xml](gc MimeKit/MimeKit.csproj)
96
48
$SEMANTIC_VERSION_NUMBER = $xml.Project.PropertyGroup.VersionPrefix
97
- echo "::set-output name=version_num::$(echo $SEMANTIC_VERSION_NUMBER[0].Trim())"
98
- echo "::set-output name=version_tag::$(echo v"$SEMANTIC_VERSION_NUMBER[0].Trim()")"
49
+ $VERSION_NUM = $SEMANTIC_VERSION_NUMBER[0].Trim()
50
+
51
+ Write-Host "version_num=${VERSION_NUM}"
52
+ Write-Host "version_tag=v${VERSION_NUM}"
99
53
100
- - if : steps.configure.outputs.is_github_release == 'true'
54
+ [IO.File]::AppendAllText($env:GITHUB_OUTPUT, "version_num=${VERSION_NUM}$([Environment]::NewLine)")
55
+ [IO.File]::AppendAllText($env:GITHUB_OUTPUT, "version_tag=v${VERSION_NUM}$([Environment]::NewLine)")
56
+
57
+ - if : ${{ env.PUBLISH == 'true' }}
101
58
name : Get latest tag
102
59
id : get_latest_tag
103
60
shell : pwsh
104
61
run : |
105
62
$LATEST_TAG = git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags "https://github.com/$env:GIT_URL.git" '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3
106
- echo "::set-output name=tag::$(echo $LATEST_TAG)"
63
+
64
+ Write-Host "tag=$LATEST_TAG"
65
+
66
+ [IO.File]::AppendAllText($env:GITHUB_OUTPUT, "tag=${LATEST_TAG}$([Environment]::NewLine)")
107
67
env :
108
68
GIT_URL : ${{ github.repository }}
109
69
110
- - if : steps.configure.outputs.is_github_release == 'true' && steps.semantic_version.outputs.version_tag != steps.get_latest_tag.outputs.tag
70
+ - if : ${{ env.PUBLISH == 'true' && steps.semantic_version.outputs.version_tag != steps.get_latest_tag.outputs.tag }}
111
71
name : Add new tag to repo
112
72
id : add_new_tag_to_repo
113
73
continue-on-error : true
@@ -137,71 +97,63 @@ jobs:
137
97
continue-on-error : true
138
98
shell : pwsh
139
99
run : |
140
- dotnet msbuild $env:SOLUTION_PATH -property:Platform=$env:BUILD_PLATFORM -property:Configuration=$env:BUILD_CONFIGURATION -property:MonoRuntime=$env:IS_UBUNTU
141
- env :
142
- IS_UBUNTU : ${{ steps.configure.outputs.is_ubuntu }}
100
+ dotnet msbuild $env:SOLUTION_PATH -property:Platform=$env:BUILD_PLATFORM -property:Configuration=$env:BUILD_CONFIGURATION -property:MonoRuntime=$env:MONO_RUNTIME
143
101
144
102
- name : Run unit tests
145
103
id : run_unit_tests
146
104
continue-on-error : true
147
105
shell : pwsh
148
106
run : |
149
- & ./scripts/test.ps1 -Configuration:$env:BUILD_CONFIGURATION -GenerateCodeCoverage:$env:GENERATE_CODE_COVERAGE
150
- env :
151
- BUILD_CONFIGURATION : ${{ matrix.build-configuration }}
152
- GENERATE_CODE_COVERAGE : ${{ steps.configure.outputs.generate_code_coverage }}
107
+ pwsh ./scripts/test.ps1 -Configuration "$env:BUILD_CONFIGURATION" -GenerateCodeCoverage "$env:GENERATE_CODE_COVERAGE"
153
108
154
109
- name : Upload unit test results
155
110
id : upload_test_results
156
111
continue-on-error : true
157
112
uses : actions/upload-artifact@v4
158
113
with :
159
- name : MimeKit.${{ steps.semantic_version.outputs.version_num }}.${{ env.GITHUB_RUN_NUMBER }}-${{ matrix.os }}-${{ matrix.build-configuration }}-TestResults.xml
114
+ name : MimeKit.${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }}-${{ matrix.os }}-${{ matrix.build-configuration }}-TestResults.xml
160
115
path : TestResult.xml
161
116
162
- - if : steps.configure.outputs.generate_code_coverage == 'yes'
117
+ - if : ${{ env.GENERATE_CODE_COVERAGE == 'yes' }}
163
118
name : Upload code coverage data to coveralls.io
164
119
id : upload_to_coveralls
165
- shell : pwsh
166
120
run : |
167
- & ./scripts/coveralls.ps1
121
+ pwsh ./scripts/coveralls.ps1
168
122
env :
169
123
COVERALLS_REPO_TOKEN : ${{ secrets.COVERALLS_REPO_TOKEN }}
170
124
GIT_COMMIT_SHA : ${{ github.sha }}
171
125
GIT_REF : ${{ github.ref }}
172
126
GIT_ACTOR : ${{ github.event.head_commit.author.username }}
173
127
GIT_ACTOR_EMAIL : ${{ github.event.head_commit.author.email }}
174
128
GIT_COMMIT_MESSAGE : ${{ github.event.head_commit.message }}
175
- COVERALLS_JOB_ID : ${{ steps.semantic_version.outputs.version_num }}.${{ env.GITHUB_RUN_NUMBER }}
129
+ COVERALLS_JOB_ID : ${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }}
176
130
177
- - if : steps.configure.outputs.is_github_release == 'true'
131
+ - if : ${{ env.PUBLISH == 'true' }}
178
132
name : Create NuGet package
179
133
id : create_nuget_package
180
134
shell : pwsh
181
135
run : |
182
- nuget pack nuget/MimeKit.nuspec `
183
- -Version "$env:LATEST_VERSION.$env:GITHUB_RUN_NUMBER"
136
+ nuget pack nuget/MimeKit.nuspec -Version "$env:LATEST_VERSION.$env:BUILD_NUMBER"
184
137
env :
185
138
LATEST_VERSION : ${{ steps.semantic_version.outputs.version_num }}
139
+ BUILD_NUMBER : ${{ github.run_number }}
186
140
187
- - if : steps.configure.outputs.is_github_release == 'true'
141
+ - if : ${{ env.PUBLISH == 'true' }}
188
142
name : Push NuGet package to MyGet
189
143
id : push_nuget_package
190
144
shell : pwsh
191
145
run : |
192
- nuget push $env:NUGET_PKG_PATH `
193
- -ApiKey $env:MYGET_API_KEY `
194
- -Source https://www.myget.org/F/mimekit/api/v3/index.json
146
+ nuget push $env:NUGET_PKG_PATH -ApiKey $env:MYGET_API_KEY -Source https://www.myget.org/F/mimekit/api/v3/index.json
195
147
env :
196
- NUGET_PKG_PATH : MimeKit.${{ steps.semantic_version.outputs.version_num }}.${{ env.GITHUB_RUN_NUMBER }}.nupkg
148
+ NUGET_PKG_PATH : MimeKit.${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }}.nupkg
197
149
MYGET_API_KEY : ${{ secrets.MYGET_API_KEY }}
198
150
199
- - if : steps.configure.outputs.is_github_release == 'true'
151
+ - if : ${{ env.PUBLISH == 'true' }}
200
152
name : Upload NuGet package as artifact
201
153
id : upload_nuget_package
202
154
uses : actions/upload-artifact@v4
203
155
with :
204
- name : MimeKit.${{ steps.semantic_version.outputs.version_num }}.${{ env.GITHUB_RUN_NUMBER }}.nupkg
205
- path : MimeKit.${{ steps.semantic_version.outputs.version_num }}.${{ env.GITHUB_RUN_NUMBER }}.nupkg
156
+ name : MimeKit.${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }}.nupkg
157
+ path : MimeKit.${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }}.nupkg
206
158
207
159
# Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)
0 commit comments