From 53caad5c7851ce113d5e6771bad003ed5599463a Mon Sep 17 00:00:00 2001
From: 22222 <22222@users.noreply.github.com>
Date: Fri, 17 Dec 2021 13:47:28 -0600
Subject: [PATCH] Update build script, and fix build warning
---
.github/workflows/build.yml | 26 +++++++++++--------
.../VbCsvTextFieldParserTest.cs | 2 +-
CsvTextFieldParser/CsvTextFieldParser.csproj | 1 -
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 743c451..95b4cee 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -4,10 +4,9 @@ on:
push:
branches:
- master
+ tags:
+ - 'v*'
pull_request:
- release:
- types:
- - published
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
@@ -33,21 +32,26 @@ jobs:
- name: Test
run: dotnet test -c Release --no-build
- name: Pack
- if: matrix.os == 'windows-latest' && github.event_name == 'release'
+ if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/v')
+ shell: pwsh
run: |
- arrTag=(${GITHUB_REF//\// })
- VERSION="${arrTag[2]}"
- VERSION="${VERSION//v}"
- echo Version: $VERSION
- 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
+ $GITHUB_REF = $env:GITHUB_REF
+ if (!($GITHUB_REF -match 'refs/tags/v(\d+\.\d+\.\d+)')) {
+ Write-Error "Failed to parse version from GITHUB_REF: $GITHUB_REF"
+ exit 1
+ }
+ $Version = $matches[1]
+ Write-Host "Version: $Version"
+ & dotnet pack -c Release -p:Version=$Version -p:PackageVersion=$VERSION -p:AssemblyVersion=$Version -p:FileVersion=$Version -p:InformationalVersion=$Version CsvTextFieldParser/CsvTextFieldParser.csproj
+ exit $LastExitCode
- name: Upload Artifact Nupkg
- if: matrix.os == 'windows-latest' && github.event_name == 'release'
+ if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v2
with:
name: nupkg
path: ./CsvTextFieldParser/bin/Release/*.nupkg
- name: Upload Artifact Bin
- if: matrix.os == 'windows-latest' && github.event_name == 'release'
+ if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v2
with:
name: bin
diff --git a/CsvTextFieldParser.Tests/VbCsvTextFieldParserTest.cs b/CsvTextFieldParser.Tests/VbCsvTextFieldParserTest.cs
index 079ff2e..ffecbe6 100644
--- a/CsvTextFieldParser.Tests/VbCsvTextFieldParserTest.cs
+++ b/CsvTextFieldParser.Tests/VbCsvTextFieldParserTest.cs
@@ -52,7 +52,7 @@ public void SetDelimiters_Empty()
{
parser.Delimiters = new string[0];
var actual = parser.Delimiters;
- Assert.Equal(0, actual.Length);
+ Assert.Empty(actual);
}
}
diff --git a/CsvTextFieldParser/CsvTextFieldParser.csproj b/CsvTextFieldParser/CsvTextFieldParser.csproj
index 8fe5b0a..2a9a79e 100644
--- a/CsvTextFieldParser/CsvTextFieldParser.csproj
+++ b/CsvTextFieldParser/CsvTextFieldParser.csproj
@@ -9,7 +9,6 @@
MIT OR Unlicense
csv parser CsvParser CsvTextFieldParser TextFieldParser
- true
true
CodeAnalysis.ruleset
0.0.0