Skip to content

Commit 36c2858

Browse files
committed
Update build script, and fix build warning
1 parent e3737fd commit 36c2858

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ on:
44
push:
55
branches:
66
- master
7+
tags:
8+
- 'v*'
79
pull_request:
8-
release:
9-
types:
10-
- published
1110

1211
env:
1312
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
@@ -33,21 +32,26 @@ jobs:
3332
- name: Test
3433
run: dotnet test -c Release --no-build
3534
- name: Pack
36-
if: matrix.os == 'windows-latest' && github.event_name == 'release'
35+
if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/v')
36+
shell: pwsh
3737
run: |
38-
arrTag=(${GITHUB_REF//\// })
39-
VERSION="${arrTag[2]}"
40-
VERSION="${VERSION//v}"
41-
echo Version: $VERSION
42-
dotnet pack -c Release -p:Version=$Version -p:PackageVersion=$VERSION -p:AssemblyVersion=$Version -p:FileVersion=$Version -p:InformationalVersion=$Version -o nupkg src/CsvTextFieldParser/CsvTextFieldParser.csproj
38+
$GITHUB_REF = $env:GITHUB_REF
39+
if (!($GITHUB_REF -match 'refs/tags/v(\d+\.\d+\.\d+)')) {
40+
Write-Error "Failed to parse version from GITHUB_REF: $GITHUB_REF"
41+
exit 1
42+
}
43+
$Version = $matches[1]
44+
Write-Host "Version: $Version"
45+
& dotnet pack -c Release -p:Version=$Version -p:PackageVersion=$VERSION -p:AssemblyVersion=$Version -p:FileVersion=$Version -p:InformationalVersion=$Version -o nupkg src/CsvTextFieldParser/CsvTextFieldParser.csproj
46+
exit $LastExitCode
4347
- name: Upload Artifact Nupkg
44-
if: matrix.os == 'windows-latest' && github.event_name == 'release'
48+
if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/v')
4549
uses: actions/upload-artifact@v2
4650
with:
4751
name: nupkg
4852
path: ./CsvTextFieldParser/bin/Release/*.nupkg
4953
- name: Upload Artifact Bin
50-
if: matrix.os == 'windows-latest' && github.event_name == 'release'
54+
if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/v')
5155
uses: actions/upload-artifact@v2
5256
with:
5357
name: bin

CsvTextFieldParser.Tests/VbCsvTextFieldParserTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void SetDelimiters_Empty()
5252
{
5353
parser.Delimiters = new string[0];
5454
var actual = parser.Delimiters;
55-
Assert.Equal(0, actual.Length);
55+
Assert.Empty(actual);
5656
}
5757
}
5858

CsvTextFieldParser/CsvTextFieldParser.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<PackageLicenseExpression>MIT OR Unlicense</PackageLicenseExpression>
1010
<PackageTags>csv parser CsvParser CsvTextFieldParser TextFieldParser</PackageTags>
1111
<Company />
12-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1312
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1413
<CodeAnalysisRuleSet>CodeAnalysis.ruleset</CodeAnalysisRuleSet>
1514
<Version>0.0.0</Version>

0 commit comments

Comments
 (0)