-
Notifications
You must be signed in to change notification settings - Fork 4
45 lines (43 loc) · 1.72 KB
/
publish-nuget-core.yml
File metadata and controls
45 lines (43 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: publish-nuget
run-name: 发布Core nuget包,版本:${{ github.ref_name }}
on:
push:
tags:
- "*"
jobs:
publish-nuget-packages:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: 安装.NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
- name: 恢复依赖
run: dotnet restore ./NapPlana.Net.Core/NapPlana.Net.Core.csproj
- name: 获取tag
id: version
shell: bash
run: |
ref="${GITHUB_REF_NAME}"
# Strip leading 'v' if present (e.g., v1.2.3 -> 1.2.3)
if [[ "$ref" == v* ]]; then
ref="${ref#v}"
fi
echo "PACKAGE_VERSION=$ref" >> "$GITHUB_ENV"
echo "package_version=$ref" >> "$GITHUB_OUTPUT"
- name: 构建
run: dotnet build --no-restore -c Release ./NapPlana.Net.Core/NapPlana.Net.Core.csproj
- name: 创建软件包
run: dotnet pack --no-build -c Release -p:PackageVersion=${{ env.PACKAGE_VERSION }} ./NapPlana.Net.Core/NapPlana.Net.Core.csproj
- name: 添加nuget源
run: dotnet nuget add source --username stevesensei --password ${{ secrets.TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/napplana/index.json"
- name: 推送到github packages
run: dotnet nuget push ./NapPlana.Net.Core/bin/Release/*.nupkg --api-key ${{ secrets.TOKEN }} --source github --skip-duplicate
- name: 推送到nuget
run: dotnet nuget push ./NapPlana.Net.Core/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_GALLERY_TOKEN }} --source nuget.org --skip-duplicate