-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
183 lines (173 loc) · 5.61 KB
/
action.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: "Generate Refit API Client using Refitter"
description: "Generates a Refit Client SDK using Refitter from an OpenAPI Specifications file"
branding:
icon: code
color: green
inputs:
openapi-url:
description: If set, the OpenAPI document will be loaded from this URL instead of openapi-file.
required: false
openapi-file:
description: The path to the OpenAPI document to generate a client library for
required: false
default: openapi.json
namespace:
description: The default namespace used for the generated types
required: false
use-api-response:
description: Return Task<IApiResponse<T>> instead of Task<T>
required: false
default: false
type: boolean
cancellation-tokens:
description: Use cancellation tokens
required: false
default: false
type: boolean
command-args:
description: Optional, additional arguments to pass through to Refitter
required: false
type: string
publish-artifacts:
description: Publish the generated nuget package as a build artifact
required: false
type: boolean
default: true
multiple-interfaces:
type: choice
description: Generate a Refit interface for each endpoint. May be one of ByEndpoint, ByTag
options:
- ByEndpoint
- ByTag
output-filename:
description: Generated output filename
required: false
type: string
default: Output.cs
version:
description: The version number used for the NuGet package
required: false
type: string
default: 1.0.${{ github.run_number }}
target-framework:
description: The target framework used in the Client SDK
required: false
type: string
default: net6.0
package-id:
required: false
type: string
title:
required: false
type: string
root-namespace:
required: false
type: string
assembly:
required: false
type: string
authors:
required: false
type: string
product:
required: false
type: string
company:
required: false
type: string
description:
required: false
type: string
project-url:
required: false
type: string
license:
required: false
type: string
default: GPL-3.0-only
repository-type:
required: false
type: string
default: git
runs:
using: composite
steps:
- name: Install Refitter
run: dotnet tool install --global refitter
shell: pwsh
- name: Generate Client Interface
run: |
$input = ""
if ("${{ inputs.openapi-url }}") {
$input = "${{ inputs.openapi-url }}"
} else {
$input = "${{ inputs.openapi-file }}"
}
$args = ""
if ("${{ inputs.namespace }}") {
$args = "$args --namespace ${{ inputs.namespace }}"
}
if ("${{ inputs.use-api-response }}") {
$args = "$args --use-api-response"
}
if ("${{ inputs.cancellation-tokens }}") {
$args = "$args --cancellation-tokens"
}
if ("${{ inputs.multiple-interfaces }}") {
$args = "$args --multiple-interfaces ${{ inputs.multiple-interfaces }}"
}
Write-Host "refitter $input $args ${{ inputs.command-args }}"
Start-Process refitter `
-Args "$input $args ${{ inputs.command-args }} --output ${{ inputs.output-filename }}" `
-NoNewWindow `
-PassThru `
-Wait
shell: pwsh
- name: Generated C# project
run: |
@'
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>${{ inputs.target-framework }}</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Authors>${{ inputs.authors }}</Authors>
<Product>${{ inputs.product }}</Product>
<PackageId>${{ inputs.package-id }}</PackageId>
<AssemblyName>${{ inputs.assembly }}</AssemblyName>
<Company>${{ inputs.company }}</Company>
<Description>${{ inputs.description }}</Description>
<PackageLicenseExpression>${{ inputs.license }}</PackageLicenseExpression>
<PackageProjectUrl>${{ inputs.project-url }}</PackageProjectUrl>
<RepositoryUrl>${{ inputs.project-url }}</RepositoryUrl>
<RepositoryType>${{ inputs.repository-type }}</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>embedded</DebugType>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IsPackable>true</IsPackable>
<TieredCompilation>true</TieredCompilation>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Refit" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
</ItemGroup>
</Project>
'@ | Out-File Build.csproj
Get-Content Build.csproj | Write-Host
shell: pwsh
- name: Build
run: dotnet build -c Release /p:UseSourceLink=true -p:PackageVersion="${{ inputs.version }}"
shell: pwsh
- name: Pack
run: dotnet pack --no-build -c Release /p:UseSourceLink=true -p:PackageVersion="${{ inputs.version }}" --output .
shell: pwsh
- name: Publish Client SDK Artifact
if: ${{ inputs.publish-artifacts }}
uses: actions/upload-artifact@v3
with:
name: NuGet Pacakge
path: |
**/*.nupkg