44 push :
55 branches :
66 - master
7+ tags :
8+ - ' v*'
79 pull_request :
8- release :
9- types :
10- - published
1110
1211env :
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
0 commit comments