|
1 | | -name: .NET Core Test |
| 1 | +name: .NET Core Test and Publish |
2 | 2 |
|
3 | | -on: pull_request |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master-n3] |
| 6 | + pull_request: |
4 | 7 |
|
5 | 8 | env: |
6 | 9 | DOTNET_VERSION: 10.0.x |
7 | 10 |
|
8 | 11 | jobs: |
| 12 | + |
9 | 13 | Test: |
10 | 14 | strategy: |
11 | 15 | matrix: |
|
44 | 48 | github-token: ${{ secrets.GITHUB_TOKEN }} |
45 | 49 | format: lcov |
46 | 50 | file: ${{ github.workspace }}/TestResults/coverage/coverage.info |
| 51 | + |
| 52 | + Release: |
| 53 | + if: github.ref == 'refs/heads/master-n3' && startsWith(github.repository, 'neo-project/') |
| 54 | + needs: Test |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v5 |
| 59 | + - name: Get version |
| 60 | + id: get_version |
| 61 | + run: | |
| 62 | + sudo apt install xmlstarlet |
| 63 | + find plugins -name Directory.Build.props | xargs xmlstarlet sel -N i=http://schemas.microsoft.com/developer/msbuild/2003 -t -v "concat('version=v',//i:Version/text())" | xargs echo >> $GITHUB_OUTPUT |
| 64 | + - name: Check tag |
| 65 | + if: steps.get_version.outputs.version != 'v' && startsWith(steps.get_version.outputs.version, 'v') |
| 66 | + id: check_tag |
| 67 | + 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 "statusCode=%s" | xargs echo >> $GITHUB_OUTPUT |
| 68 | + - name: Create release |
| 69 | + if: steps.check_tag.outputs.statusCode == '404' |
| 70 | + id: create_release |
| 71 | + uses: actions/create-release@v1 |
| 72 | + env: |
| 73 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + with: |
| 75 | + tag_name: ${{ steps.get_version.outputs.version }} |
| 76 | + release_name: ${{ steps.get_version.outputs.version }} |
| 77 | + draft: true |
| 78 | + prerelease: ${{ contains(steps.get_version.outputs.version, '-') }} |
| 79 | + - name: Setup .NET Core |
| 80 | + if: steps.check_tag.outputs.statusCode == '404' |
| 81 | + uses: actions/setup-dotnet@v5 |
| 82 | + with: |
| 83 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 84 | + - name: Publish to NuGet |
| 85 | + if: steps.check_tag.outputs.statusCode == '404' |
| 86 | + run: | |
| 87 | + dotnet pack -o out -c Release |
| 88 | + dotnet nuget push out/*.nupkg -s https://api.nuget.org/v3/index.json -k ${NUGET_TOKEN} |
| 89 | + env: |
| 90 | + NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }} |
0 commit comments