Github自動構建Nuget包
阿新 • • 發佈:2020-11-03
工作流程
- 使用者
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