在GitHub上自动发布.Net Core应用 [英] Release .Net Core Apps on GitHub Automated

查看:86
本文介绍了在GitHub上自动发布.Net Core应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想在自动生成的GitHub Repos中制作.Net Core App,并将构建的二进制文件推送到新的Release,但是我不知道在GitHub上进行设置.因此,例如,我有我的.Net Core Console应用程序,并将更改后的分支拉到master中.现在,应该在压缩二进制文件并将其附加到新发行版之后开始构建(就是我所拥有的).因此,将会有连续不断的新发行版.

I wan't to make .Net Core App in a GitHub Repos that builds automized and pushes the binaries of the build zipped to a new Release, but I have no idea to set this on GitHub up. So for example I have my .Net Core Console Application and pull my branch with changes into master. Now the build should start(thats what I have) after the build the binaries should be zipped and attached to a new Release, so there would be continious new Releases.

希望有人能理解并能提供帮助.

Hopefully someone understand and can Help.

这是我到目前为止的工作流程

Here is my workflow till now

name: .NET Core

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.1.201
    - name: Install dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --configuration Release --no-restore

推荐答案

感谢Deepak Mishra,我现在已经通过这种方式解决了

I have now solved this way thanks to Deepak Mishra

name: .NET Core

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.1.101
    - name: Install dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --configuration Release --no-restore
    - name: Zip the Build
      run: zip -r ${{ secrets.ReleaseZipName }} ./AppName/bin/Release/netcoreapp3.1/ 
    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ github.run_number }}
        release_name: Release ${{ github.ref }}
        body: New Release.
        draft: false
        prerelease: false
    - name: Upload Release Asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 
        asset_path: ./${{ secrets.ReleaseZipName }}.zip
        asset_name: ${{ secrets.ReleaseZipName }}.zip
        asset_content_type: application/zip

这篇关于在GitHub上自动发布.Net Core应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆