Skip to content

Commit ceb8915

Browse files
committed
Update main.yml
Updated to remove use of the set-output command
1 parent 37f0567 commit ceb8915

File tree

2 files changed

+36
-84
lines changed

2 files changed

+36
-84
lines changed

.github/workflows/main.yml

Lines changed: 34 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -16,73 +16,25 @@ jobs:
1616
SOLUTION_PATH: MimeKit.sln
1717
BUILD_PLATFORM: Any CPU
1818
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+
2023
steps:
2124
- name: Setup/Install the .NET 8 SDK
2225
id: install-netsdk
2326
uses: actions/setup-dotnet@v4
2427
with:
2528
dotnet-version: 8.0.x
2629

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'
7931
name: Setup MSBuild
8032
id: setup_msbuild
8133
uses: microsoft/[email protected]
8234

8335
- name: Checkout repository
8436
id: checkout_repo
85-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
8638
with:
8739
token: ${{ secrets.GITHUB_TOKEN }}
8840
submodules: recursive
@@ -94,20 +46,28 @@ jobs:
9446
run: |
9547
$xml = [xml](gc MimeKit/MimeKit.csproj)
9648
$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}"
9953
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' }}
10158
name: Get latest tag
10259
id: get_latest_tag
10360
shell: pwsh
10461
run: |
10562
$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)")
10767
env:
10868
GIT_URL: ${{ github.repository }}
10969

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 }}
11171
name: Add new tag to repo
11272
id: add_new_tag_to_repo
11373
continue-on-error: true
@@ -137,71 +97,63 @@ jobs:
13797
continue-on-error: true
13898
shell: pwsh
13999
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
143101
144102
- name: Run unit tests
145103
id: run_unit_tests
146104
continue-on-error: true
147105
shell: pwsh
148106
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"
153108
154109
- name: Upload unit test results
155110
id: upload_test_results
156111
continue-on-error: true
157112
uses: actions/upload-artifact@v4
158113
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
160115
path: TestResult.xml
161116

162-
- if: steps.configure.outputs.generate_code_coverage == 'yes'
117+
- if: ${{ env.GENERATE_CODE_COVERAGE == 'yes' }}
163118
name: Upload code coverage data to coveralls.io
164119
id: upload_to_coveralls
165-
shell: pwsh
166120
run: |
167-
& ./scripts/coveralls.ps1
121+
pwsh ./scripts/coveralls.ps1
168122
env:
169123
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
170124
GIT_COMMIT_SHA: ${{ github.sha }}
171125
GIT_REF: ${{ github.ref }}
172126
GIT_ACTOR: ${{ github.event.head_commit.author.username }}
173127
GIT_ACTOR_EMAIL: ${{ github.event.head_commit.author.email }}
174128
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 }}
176130

177-
- if: steps.configure.outputs.is_github_release == 'true'
131+
- if: ${{ env.PUBLISH == 'true' }}
178132
name: Create NuGet package
179133
id: create_nuget_package
180134
shell: pwsh
181135
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"
184137
env:
185138
LATEST_VERSION: ${{ steps.semantic_version.outputs.version_num }}
139+
BUILD_NUMBER: ${{ github.run_number }}
186140

187-
- if: steps.configure.outputs.is_github_release == 'true'
141+
- if: ${{ env.PUBLISH == 'true' }}
188142
name: Push NuGet package to MyGet
189143
id: push_nuget_package
190144
shell: pwsh
191145
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
195147
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
197149
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
198150

199-
- if: steps.configure.outputs.is_github_release == 'true'
151+
- if: ${{ env.PUBLISH == 'true' }}
200152
name: Upload NuGet package as artifact
201153
id: upload_nuget_package
202154
uses: actions/upload-artifact@v4
203155
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
206158

207159
# Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)

scripts/test.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ param (
44
[string]
55
$Configuration = "Debug",
66
[string]
7-
$GenerateCodeCoverage = "no"
7+
$GenerateCodeCoverage = "false"
88
)
99

1010
Write-Output "Configuration: $Configuration"
@@ -26,7 +26,7 @@ $targetFramework = $project.SelectSingleNode("/Project/PropertyGroup/TargetFrame
2626
$OutputDir = Join-Path "UnitTests" "bin" $Configuration $targetFramework.InnerText
2727
$UnitTestsAssembly = Join-Path $OutputDir "UnitTests.dll"
2828

29-
if ($GenerateCodeCoverage -eq 'yes') {
29+
if ($GenerateCodeCoverage -eq 'true') {
3030
Write-Output "Instrumenting code..."
3131

3232
& dotnet AltCover -i="$OutputDir" --inplace -s="System.*" -s="Microsoft.*" -s="BouncyCastle.*" -s="NUnit*" -s="AltCover.*" -s="testhost" -s="UnitTests"

0 commit comments

Comments
 (0)