-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (114 loc) · 4.43 KB
/
ci.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: CI
on:
push:
paths:
- '**'
branches:
- '**'
tags:
- '*.*.*'
workflow_dispatch:
jobs:
build-test:
name: Build & Test
runs-on: ubuntu-22.04
permissions:
contents: read
packages: read
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Add GitHub Packages source
if: ${{ github.event_name != 'pull_request' && !startsWith( github.ref_name, 'dependabot/' ) }}
run: dotnet nuget add source --name github --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
- name: Restore dependencies
run: dotnet restore
- name: Build projects
run: dotnet build --nologo --configuration Release --no-restore
- name: Run tests
run: dotnet test --nologo --configuration Release --no-build
- name: Launch examples
run: dotnet run --configuration Release --no-build --project JsonExtensions.Examples/JsonExtensions.Examples.csproj
- name: Package library
run: dotnet pack --nologo --configuration Release --no-build JsonExtensions/JsonExtensions.csproj
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: viral32111.JsonExtensions
path: |
JsonExtensions/bin/Release/net7.0/*
JsonExtensions/bin/Release/*.nupkg
- name: Upload examples artifact
uses: actions/upload-artifact@v4
with:
name: viral32111.JsonExtensions.Examples
path: JsonExtensions.Examples/bin/Release/net7.0/*
- name: Upload tests artifact
uses: actions/upload-artifact@v4
with:
name: viral32111.JsonExtensions.Tests
path: JsonExtensions.Tests/bin/Release/net7.0/*
publish:
name: Publish
runs-on: ubuntu-22.04
needs: build-test
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
permissions:
contents: read
packages: write
steps:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Download package artifact
uses: actions/download-artifact@v4
with:
name: viral32111.JsonExtensions
path: JsonExtensions
- name: Add GitHub Packages source
run: dotnet nuget add source --name github --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
- name: Push to GitHub Packages
run: dotnet nuget push --source github --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} JsonExtensions/viral32111.JsonExtensions.*.nupkg
- name: Push to NuGet Gallery
run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} JsonExtensions/viral32111.JsonExtensions.*.nupkg
release:
name: Release
runs-on: ubuntu-22.04
needs: build-test
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
permissions:
contents: write
steps:
- name: Download package artifact
uses: actions/download-artifact@v4
with:
name: viral32111.JsonExtensions
path: JsonExtensions
- name: Download examples artifact
uses: actions/download-artifact@v4
with:
name: viral32111.JsonExtensions.Examples
path: JsonExtensions.Examples
- name: Download tests artifact
uses: actions/download-artifact@v4
with:
name: viral32111.JsonExtensions.Tests
path: JsonExtensions.Tests
- name: Bundle package artifact
run: zip -r viral32111.JsonExtensions.zip JsonExtensions
- name: Bundle examples artifact
run: zip -r viral32111.JsonExtensions.Examples.zip JsonExtensions.Examples
- name: Bundle tests artifact
run: zip -r viral32111.JsonExtensions.Tests.zip JsonExtensions.Tests
- name: Create draft release
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: ${{ github.ref_name }}
files: viral32111.JsonExtensions*.zip
token: ${{ secrets.GITHUB_TOKEN }}