@@ -11,12 +11,16 @@ jobs:
1111 strategy :
1212 matrix :
1313 dotnet : [ '3.1.x' ]
14- name : Dotnet ${{ matrix.dotnet }}
14+ name : .NET Core ${{ matrix.dotnet }}
1515
1616 runs-on : ubuntu-latest
17+ outputs :
18+ version : ${{ steps.get_version.outputs.version }}
1719
1820 steps :
1921 - uses : actions/checkout@v2
22+
23+ # https://github.com/actions/setup-dotnet/
2024 - name : Setup .NET Core
2125 uses : actions/setup-dotnet@v1
2226 with :
3034
3135 - name : Create the package
3236 run : dotnet pack --configuration Release System.Text.Json.Extensions
37+ - name : Get Version
38+ id : get_version
39+ shell : pwsh
40+ run : |
41+ Write-Host "::set-output name=packageAndVersion::$(Split-Path -Path $(Resolve-Path "System.Text.Json.Extensions/bin/Release/*.nupkg") -LeafBase)"
42+ Write-Host "::set-output name=version::$((Split-Path -Path $(Resolve-Path "System.Text.Json.Extensions/bin/Release/*.nupkg") -LeafBase) -replace '^.*?(\d.*)$','$1')"
3343 - uses : actions/upload-artifact@v2
3444 with :
3545 name : Dotnet ${{ matrix.dotnet }}
6171 - name : Publish the package to GPR
6272 if : success() && github.event_name == 'push' && matrix.dotnet == '3.1.x'
6373 run : dotnet nuget push System.Text.Json.Extensions/bin/Release/*.nupkg
74+
75+ - name : Create Release
76+ id : create_release
77+ if : success() && github.event_name == 'push' && matrix.dotnet == '3.1.x'
78+ uses : actions/create-release@v1
79+ env :
80+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
81+ with :
82+ tag_name : v${{ steps.get_version.version }}
83+ release_name : Release ${{ steps.get_version.version }}
84+ draft : true
85+ prerelease : false
86+ - name : Upload Release Asset
87+ if : success() && github.event_name == 'push' && matrix.dotnet == '3.1.x'
88+ uses : actions/upload-release-asset@v1
89+ env :
90+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
91+ with :
92+ upload_url : ${{ steps.create_release.outputs.upload_url }}
93+ asset_path : System.Text.Json.Extensions/bin/Release/${{ steps.get_version.packageAndVersion }}.nupkg
94+ asset_name : ${{ steps.get_version.packageAndVersion }}.nupkg
95+ asset_content_type : application/zip
0 commit comments