-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (66 loc) · 2.35 KB
/
Copy pathrelease.yml
File metadata and controls
79 lines (66 loc) · 2.35 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
name: Release NuGet
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Read version from csproj
id: version
shell: bash
run: |
VERSION=$(grep -oPm1 '(?<=<Version>)[^<]+' Codout.Apis.Asaas/Codout.Apis.Asaas.csproj)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Detected version: $VERSION"
- name: Verify tag matches csproj version
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
TAG="${GITHUB_REF#refs/tags/v}"
CSPROJ="${{ steps.version.outputs.version }}"
if [ "$TAG" != "$CSPROJ" ]; then
echo "::error::Tag version ($TAG) does not match csproj version ($CSPROJ)"
exit 1
fi
- name: Restore
run: dotnet restore Codout.Apis.Asaas/Codout.Apis.Asaas.csproj
- name: Build
run: dotnet build Codout.Apis.Asaas/Codout.Apis.Asaas.csproj --configuration Release --no-restore
- name: Test (unit + contract — integration valida em workflow separado)
run: dotnet test Codout.Apis.Asaas.Tests/Codout.Apis.Asaas.Tests.csproj --configuration Release --filter "Category!=Integration"
- name: Pack
run: dotnet pack Codout.Apis.Asaas/Codout.Apis.Asaas.csproj --configuration Release --no-build --output ./artifacts
- name: Push to NuGet.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
dotnet nuget push "./artifacts/*.nupkg" \
--api-key "$NUGET_API_KEY" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages-${{ steps.version.outputs.version }}
path: ./artifacts/*
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: |
./artifacts/*.nupkg
./artifacts/*.snupkg
generate_release_notes: true