Skip to content

Commit 3e25741

Browse files
committed
workflow
1 parent 5abfdf6 commit 3e25741

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

0 commit comments

Comments
 (0)