File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Publish to NuGet
2+
3+ on :
4+ push :
5+ # Запускать только при пуше тегов версий,
6+ # например 1.4.1 или v1.4.1
7+ tags :
8+ - ' v*'
9+ - ' [0-9]+.[0-9]+.[0-9]+'
10+
11+ jobs :
12+ build-and-publish :
13+ name : Build and publish to NuGet
14+ runs-on : ubuntu-latest
15+
16+ env :
17+ # Имя основного проекта библиотеки
18+ PROJECT_PATH : TwoCaptcha/TwoCaptcha.csproj
19+ # Версию берём из имени тега, например 1.4.1 или v1.4.1
20+ TAG_NAME : ${{ github.ref_name }}
21+
22+ steps :
23+ - name : Checkout
24+ uses : actions/checkout@v4
25+
26+ - name : Normalize version from tag
27+ id : version
28+ run : |
29+ tag="${TAG_NAME}"
30+ # Убираем префикс v, если используется формат v1.2.3
31+ version="${tag#v}"
32+ echo "version=$version" >> "$GITHUB_OUTPUT"
33+
34+ - name : Setup .NET
35+ uses : actions/setup-dotnet@v4
36+ with :
37+ dotnet-version : ' 7.0.x'
38+
39+ - name : Restore
40+ run : dotnet restore
41+
42+ - name : Build
43+ run : dotnet build $PROJECT_PATH -c Release --no-restore
44+
45+ - name : Pack
46+ run : |
47+ dotnet pack $PROJECT_PATH -c Release \
48+ -o ./artifacts \
49+ /p:PackageVersion=${{ steps.version.outputs.version }}
50+
51+ - name : Publish to NuGet
52+ run : |
53+ dotnet nuget push "artifacts/*.nupkg" \
54+ --api-key "${{ secrets.NUGET_API_KEY }}" \
55+ --source "https://api.nuget.org/v3/index.json" \
56+ --skip-duplicate
You can’t perform that action at this time.
0 commit comments