Skip to content

Commit 18e4a10

Browse files
authored
Create nugets via GitHub actions (#154)
1 parent bcea557 commit 18e4a10

File tree

2 files changed

+135
-2
lines changed

2 files changed

+135
-2
lines changed

.github/workflows/dotnet.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
branches: [ main ]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
build:
912

@@ -26,10 +29,44 @@ jobs:
2629
- name: Restore dependencies
2730
run: dotnet restore
2831
- name: Build
29-
run: dotnet build --no-restore
32+
run: dotnet build --configuration=Release --no-restore
3033
- name: Test
3134
timeout-minutes: 2
32-
run: dotnet test --no-build
35+
run: dotnet test --configuration=Release --no-build
36+
- name: Pack NuGet packages (PR validation)
37+
if: matrix.dotnet-version == '8.0.x'
38+
run: |
39+
dotnet pack Activout.RestClient/Activout.RestClient.csproj \
40+
-p:PackageVersion=1.0.0-pr${{ github.event.pull_request.number }}.${{ github.run_number }} \
41+
--configuration=Release \
42+
--no-build \
43+
--include-symbols \
44+
--include-source
45+
dotnet pack Activout.RestClient.Json/Activout.RestClient.Json.csproj \
46+
-p:PackageVersion=1.0.0-pr${{ github.event.pull_request.number }}.${{ github.run_number }} \
47+
--configuration=Release \
48+
--no-build \
49+
--include-symbols \
50+
--include-source
51+
dotnet pack Activout.RestClient.Newtonsoft.Json/Activout.RestClient.Newtonsoft.Json.csproj \
52+
-p:PackageVersion=1.0.0-pr${{ github.event.pull_request.number }}.${{ github.run_number }} \
53+
--configuration=Release \
54+
--no-build \
55+
--include-symbols \
56+
--include-source
57+
dotnet pack Activout.RestClient.Xml/Activout.RestClient.Xml.csproj \
58+
-p:PackageVersion=1.0.0-pr${{ github.event.pull_request.number }}.${{ github.run_number }} \
59+
--configuration=Release \
60+
--no-build \
61+
--include-symbols \
62+
--include-source
63+
- name: Upload NuGet packages
64+
if: matrix.dotnet-version == '8.0.x'
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: nuget-packages-pr${{ github.event.pull_request.number }}-run${{ github.run_number }}
68+
path: |
69+
**/*.symbols.nupkg
3370
# - name: Archive test results
3471
# uses: actions/upload-artifact@v4
3572
# if: always()

.github/workflows/release.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build-and-publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v4
19+
with:
20+
dotnet-version: '8.0.x'
21+
22+
- name: Extract version from tag
23+
id: get_version
24+
run: |
25+
# Remove 'v' prefix if present (e.g., v1.2.3 -> 1.2.3)
26+
VERSION=${GITHUB_REF#refs/tags/}
27+
VERSION=${VERSION#v}
28+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
29+
echo "Building version: $VERSION"
30+
31+
- name: Restore dependencies
32+
run: dotnet restore
33+
34+
- name: Build
35+
run: dotnet build --configuration=Release --no-restore
36+
37+
- name: Test
38+
timeout-minutes: 2
39+
run: dotnet test --configuration=Release --no-build
40+
41+
- name: Pack Activout.RestClient
42+
run: |
43+
dotnet pack Activout.RestClient/Activout.RestClient.csproj \
44+
-p:PackageVersion=${{ steps.get_version.outputs.VERSION }} \
45+
--configuration=Release \
46+
--no-build \
47+
--include-symbols \
48+
--include-source \
49+
--output ./nupkgs
50+
51+
- name: Pack Activout.RestClient.Json
52+
run: |
53+
dotnet pack Activout.RestClient.Json/Activout.RestClient.Json.csproj \
54+
-p:PackageVersion=${{ steps.get_version.outputs.VERSION }} \
55+
--configuration=Release \
56+
--no-build \
57+
--include-symbols \
58+
--include-source \
59+
--output ./nupkgs
60+
61+
- name: Pack Activout.RestClient.Newtonsoft.Json
62+
run: |
63+
dotnet pack Activout.RestClient.Newtonsoft.Json/Activout.RestClient.Newtonsoft.Json.csproj \
64+
-p:PackageVersion=${{ steps.get_version.outputs.VERSION }} \
65+
--configuration=Release \
66+
--no-build \
67+
--include-symbols \
68+
--include-source \
69+
--output ./nupkgs
70+
71+
- name: Pack Activout.RestClient.Xml
72+
run: |
73+
dotnet pack Activout.RestClient.Xml/Activout.RestClient.Xml.csproj \
74+
-p:PackageVersion=${{ steps.get_version.outputs.VERSION }} \
75+
--configuration=Release \
76+
--no-build \
77+
--include-symbols \
78+
--include-source \
79+
--output ./nupkgs
80+
81+
- name: List generated packages
82+
run: ls -lh ./nupkgs/
83+
84+
- name: Upload packages to release
85+
uses: softprops/action-gh-release@v2
86+
with:
87+
files: ./nupkgs/*.symbols.nupkg
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Push to NuGet.org
92+
run: |
93+
dotnet nuget push ./nupkgs/*.symbols.nupkg \
94+
--api-key ${{ secrets.NUGET_API_KEY }} \
95+
--source https://api.nuget.org/v3/index.json \
96+
--skip-duplicate

0 commit comments

Comments
 (0)