-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (65 loc) · 2.3 KB
/
publish.yml
File metadata and controls
82 lines (65 loc) · 2.3 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Publish to NuGet
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Set up Docker Compose
uses: docker/setup-compose-action@v1
- name: Start Docker Compose services
working-directory: ./NullOpsDevs.LibSsh.Test
run: docker compose up -d
- name: Build test project (Release)
run: dotnet build -c Release --self-contained -r linux-x64 ./NullOpsDevs.LibSsh.Test/NullOpsDevs.LibSsh.Test.csproj
- name: Run tests
working-directory: ./NullOpsDevs.LibSsh.Test/bin/Release/net9.0/linux-x64/
run: ./NullOpsDevs.LibSsh.Test
- name: Cleanup Docker Compose
if: always()
working-directory: ./NullOpsDevs.LibSsh.Test
run: docker compose down -v
publish:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Extract version from tag
id: get_version
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "VERSION=$TAG_NAME" >> $GITHUB_OUTPUT
echo "Building version: $TAG_NAME"
- name: Build library with version
run: dotnet build -c Release /p:Version=${{ steps.get_version.outputs.VERSION }} ./NullOpsDevs.LibSsh/NullOpsDevs.LibSsh.csproj
- name: Pack NuGet package
run: dotnet pack -c Release --no-build /p:Version=${{ steps.get_version.outputs.VERSION }} ./NullOpsDevs.LibSsh/NullOpsDevs.LibSsh.csproj -o ./artifacts
- name: Publish to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ steps.get_version.outputs.VERSION }}
tag_name: ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
files: ./artifacts/*.nupkg
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}