-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (47 loc) · 1.65 KB
/
pack-and-publish.yml
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
name: publish
on:
push:
branches: ["main"]
tags: ["v*.*.*"] # Publish semver tags as releases.
pull_request:
branches: ["main"]
env:
SOLUTION_DIR: src/Hooki
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_DIR }}
- name: Build
run: dotnet build ${{ env.SOLUTION_DIR }} --configuration Release --no-restore
- name: Test
run: dotnet test ${{ env.SOLUTION_DIR }} --no-restore
pack-and-publish:
needs: build-and-test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION_DIR }}
- name: Build
run: dotnet build ${{ env.SOLUTION_DIR }} --configuration Release --no-restore
- name: Set version and trim leading 'v'
run: |
version=$(echo ${{ github.ref_name }} | sed 's/^v//')
echo "VERSION=$version" >> $GITHUB_ENV
echo "Set VERSION to $version"
- name: Pack
run: dotnet pack ${{ env.SOLUTION_DIR }} --configuration Release --no-build -p:PackageVersion=${{env.VERSION}} --output ./nupkgs
- name: Publish to NuGet
run: dotnet nuget push "./nupkgs/Hooki.*" --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate