Repository navigation
57 lines (54 loc) · 1.63 KB
/
Copy pathrelease.yml
File metadata and controls
57 lines (54 loc) · 1.63 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
46
47
48
49
50
51
52
53
54
55
56
57
name: 发布到 NuGet
on:
release:
types: [published]
permissions:
contents: read
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
environment: nuget
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: "8.0.x"
- name: Set release version
id: version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
echo "发布标签必须使用 vX.Y.Z 或 SemVer 预发布格式,当前为 $RELEASE_TAG"
exit 1
fi
echo "value=${RELEASE_TAG#v}" >> "$GITHUB_OUTPUT"
- name: Test
run: >-
dotnet test
tests/LatticeHub.Pole.Client.Tests/LatticeHub.Pole.Client.Tests.csproj
--configuration Release
- name: Pack
run: >-
dotnet pack
src/LatticeHub.Pole.Client/LatticeHub.Pole.Client.csproj
--configuration Release
--no-restore
-p:PackageVersion=${{ steps.version.outputs.value }}
--output artifacts
- name: Log in to NuGet
id: nuget-login
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}
- name: Publish to NuGet
env:
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: >-
dotnet nuget push "artifacts/*.nupkg"
--api-key "$NUGET_API_KEY"
--source https://api.nuget.org/v3/index.json
--skip-duplicate