GitHub 自动构建 Nuget 包
工作流程
- 用户
git push - 触发
github action - 执行用户配置的
yml脚本
如何配置?
-
首先要得到两个凭证
-
Nuget Api Key
-
进入nuget官网 https://www.nuget.org/ 并登录
-
选中API Keys
-
点击创建 Create
-
配置下 Copy 凭证 [找地方存起来]
-
-
Github Token
-
进入github官网 https://github.com 并登录
-
选中Settings
-
选中Developer settings
-
选中Personal access token
-
点击Generate new token
-
配置一下生成
-
复制后[找地方存起来]
-
-
-
配置项目中
如下图所示配置凭证
-
添加Actions
name: .NET Core on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: 建立.netcore环境 uses: actions/setup-dotnet@v1 with: dotnet-version: 3.1.301 - name: 安装依赖 run: dotnet restore - name: 构建 run: dotnet build --configuration Release --no-restore - name: 添加github仓库 run: | nuget sources add -name github -Source https://nuget.pkg.github.com/ORGANIZATION_NAME/index.json -Username ORGANIZATION_NAME -Password ${{ secrets.GitHubToken }} - name: 安装nuget uses: nuget/setup-nuget@v1 with: nuget-version: '5.x' - name: 发布生成包到github和nuget run: | nuget push ./bin/Release/*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NugetKey }} -NoSymbol nuget push ./bin/Release/*.nupkg -Source github -SkipDuplicate

浙公网安备 33010602011771号