github - 在 GitHub 上自动发布 .Net Core 应用程序
问题描述
我不想在 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
解决方案
感谢 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
推荐阅读
- r - 在向量中应用自己的函数
- javascript - 打开shadow DOM css风格操作reactJS?
- c# - How can I set the color of a sprite with the URP Sprite-Lit-Default material in Unity?
- git - 在不更改提交哈希和保留标签的情况下重新签署以前的提交
- java - String 和 Casting 的算术运算
- spring-boot - 加入多个表并且模型中有关系时如何将sql结果集映射到我的实体模型
- r - 将一列中包含的数据拆分为R中的3列
- c# - 如何在 C# 中使用 Npgsql 4.1.5.0 中的游标 INOUT 参数调用 PostgreSQL 13 存储过程(无函数)
- javascript - PHP Javascript多步表单的问题
- reactjs - 如何在 gatsby-source-dynamodb 上设置多个表