diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/main.yml similarity index 62% rename from .github/workflows/dotnetcore.yml rename to .github/workflows/main.yml index dab405a371..f53a6b53f2 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/main.yml @@ -72,3 +72,41 @@ jobs: run: dotnet nuget push out/*.nupkg -s https://www.myget.org/F/neo/api/v2/package -k ${MYGET_TOKEN} -ss https://www.myget.org/F/neo/symbols/api/v2/package -sk ${MYGET_TOKEN} env: MYGET_TOKEN: ${{ secrets.MYGET_TOKEN }} + + Release: + if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/') + needs: Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Get version + id: get_version + run: | + sudo apt install xmlstarlet + find src -name *.csproj | xargs xmlstarlet sel -t -v "concat('::set-output name=version::v',//VersionPrefix/text(),'-',//VersionSuffix/text())" | xargs echo + - name: Check tag + id: check_tag + run: curl -s -I ${{ format('https://github.com/{0}/releases/tag/{1}', github.repository, steps.get_version.outputs.version) }} | head -n 1 | cut -d$' ' -f2 | xargs printf "::set-output name=statusCode::%s" | xargs echo + - name: Create release + if: steps.check_tag.outputs.statusCode == '404' + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get_version.outputs.version }} + release_name: ${{ steps.get_version.outputs.version }} + prerelease: ${{ contains(steps.get_version.outputs.version, '-') }} + - name: Setup .NET Core + if: steps.check_tag.outputs.statusCode == '404' + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Publish to NuGet + if: steps.check_tag.outputs.statusCode == '404' + run: | + dotnet pack -o out -c Release + dotnet nuget push out/*.nupkg -s https://api.nuget.org/v3/index.json -k ${NUGET_TOKEN} + env: + NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}