【问题标题】:Release .Net Core Apps on GitHub Automated在 GitHub 上自动发布 .Net Core 应用程序
【发布时间】:2020-08-08 23:19:42
【问题描述】:

我不想在 GitHub Repos 中制作 .Net Core 应用程序,它会自动构建并将构建的二进制文件推送到新版本,但我不知道在 GitHub 上进行设置。 因此,例如,我有我的 .Net Core 控制台应用程序并将我的分支与更改拉到 master 中。现在构建应该在构建之后开始(这就是我所拥有的)二进制文件应该被压缩并附加到一个新的版本,所以会有连续的新版本。

希望有人理解并可以提供帮助。

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

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

【问题讨论】:

  • 您需要使用 VSTS(azure devops) 或 Jenkins 等工具
  • @DeepakMishra 对不起,我认为你错过了理解我,或者我低估了我的目标我不想将应用程序部署到任何服务,Git Hub 有一个发布功能,你可以手动上传一些二进制文件等。和 realese 从这个页面你也可以下载版本,但我不想手动上传我的二进制文件。
  • 您可以从项目属性或 .csproj 文件中附加构建后事件。然后你可以从那个事件中运行你的 github api。
  • 如果我理解正确,您正在尝试将 bin/release 上传到 github 上的某个位置。您可以从项目属性或 .csproj 文件中附加构建后事件。然后你可以从那个事件中运行你的 github api。或者,您可以使用将在您的代码上使用 msbuild/vsbuild 任务的工具,然后发布到 github 版本。必须有github Release的上传api。
  • @DeepakMishra 很酷,我会试试的,谢谢

标签: github .net-core devops github-actions


【解决方案1】:

感谢 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 2021-09-13
    • 2020-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多