Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add csharp nuget #84

Merged
merged 28 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/csharp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "csharp"
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-push:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@master
with:
dotnet-version: 3.1.100

- name: copy wechaty proto
run: .\copy.ps1
working-directory: .\csharp\Wechaty.Grpc\buildTool
shell: powershell

- name: publish on version change
uses: rohith/publish-nuget@v2
with:
PROJECT_FILE_PATH: .\csharp\Wechaty.Grpc\Wechaty.Grpc.csproj
VERSION_FILE_PATH: .\csharp\Wechaty.Grpc\common.props
NUGET_KEY: ${{ secrets.NUGET_APIKEY }}
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,18 @@ target/

# Python
python/src/

# csharp
*.nupkg
.vs/
*.suo
*.user
*.userosscache
*.sln.docstates

csharp/Wechaty.Grpc/.vs/
csharp/Wechaty.Grpc/proto
csharp/Wechaty.Grpc/obj/
csharp/Wechaty.Grpc/bin/
csharp/Wechaty.Grpc/nupkg/package/

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ Maintainer:

- [@zhangchunsheng](https://github.com/zhangchunsheng) - Chunsheng ZHANG (张春生)

### Csharp

[Wechaty.Grpc @ Nuget](https://www.nuget.org/packages/Wechaty.Grpc)

Maintainer:

- [@Darren](https://github.com/jesn) - Darren (郑波)


## DEVELOPMENT

### Debug
Expand Down Expand Up @@ -204,6 +213,12 @@ TCP hole punching

- [gRPC typing stubs for Python](https://github.com/shabbyrobe/grpc-stubs)

#### csharp grpc
- [An introduction to NuGet (microsoft)](https://docs.microsoft.com/en-us/nuget/what-is-nuget)
- [Create a gRPC client and server in ASP.NET Core (microsoft)](https://docs.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start?view=aspnetcore-3.1&tabs=visual-studio)
- [ASP.NET Core 3.0 使用gRPC (晓晨Master) ](https://www.cnblogs.com/stulzq/p/11581967.html)


## HISTORY

### v0.17 (Aug 5, 2020)
Expand Down
23 changes: 23 additions & 0 deletions csharp/Wechaty.Grpc/Wechaty.Grpc.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<Import Project="./common.props" />

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.13.0" />
<PackageReference Include="Grpc.Core" Version="2.31.0" />
<PackageReference Include="Grpc.Tools" Version="2.31.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Protobuf Include="proto\wechaty\**\*.proto" GrpcServices="Client" />
</ItemGroup>
<ItemGroup>
<Folder Include="nupkg\" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions csharp/Wechaty.Grpc/Wechaty.Grpc.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30225.117
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wechaty.Grpc", "Wechaty.Grpc.csproj", "{71241DF7-C770-45CC-9FEA-AF6A09CA96FC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{71241DF7-C770-45CC-9FEA-AF6A09CA96FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71241DF7-C770-45CC-9FEA-AF6A09CA96FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71241DF7-C770-45CC-9FEA-AF6A09CA96FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71241DF7-C770-45CC-9FEA-AF6A09CA96FC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {56949C51-6758-44D0-8503-0729A013F881}
EndGlobalSection
EndGlobal
20 changes: 20 additions & 0 deletions csharp/Wechaty.Grpc/buildTool/common.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Paths

# csharp build Folder
$buildFolder = (Get-Item -Path "./" -Verbose).FullName

# wechaty root folder
$rootFolder = Join-Path $buildFolder "../../../"

# wechaty proto folder
$wechatyProtoFolder=Join-Path $rootFolder "proto"

# chsarp solution Folder
$solutionFolder = Join-Path $rootFolder "csharp/Wechaty.Grpc"

# get package.json data
$packageData=Get-Content (Join-Path $rootFolder "package.json") | ConvertFrom-Json

# get package.json version
$version=($packageData | Select-Object -Property version).version

39 changes: 39 additions & 0 deletions csharp/Wechaty.Grpc/buildTool/copy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
. ".\common.ps1"


# Get-ChildItem $projectFolder | ?{$_.psiscontainer -eq $false}

Set-Location $buildFolder

# csharp wechaty proto folder
$csharpProtoFolder=Join-Path $solutionFolder "proto"

# if csharp proto folder is exists, delete if exists
if(Test-Path $csharpProtoFolder)
{
Remove-Item -Path $csharpProtoFolder -Recurse -Force
}

# copy wechaty proto folder to csharp proto folder
Copy-Item $wechatyProtoFolder $solutionFolder -Recurse

$puppetFilePath = Join-Path $csharpProtoFolder "wechaty/puppet.proto"
# get puppet.proto content
$file = Get-Content $puppetFilePath

# update import as csharp catalog
$file.Replace("import public `"puppet/","import public `"proto/wechaty/puppet/") | set-Content $puppetFilePath


# update common.props version as package.json version
$commonPropPath = Join-Path $solutionFolder "common.props"
$commonPropsData = Get-Content $commonPropPath

$versionNode="<Version>" + $version + "</Version>"
echo $versionNode
$commonPropsData -Replace "<Version>(.*)</Version>" , $versionNode | set-Content $commonPropPath

Set-Location $buildFolder



19 changes: 19 additions & 0 deletions csharp/Wechaty.Grpc/common.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>latest</LangVersion>
<Version>0.17.3</Version>
<authors>Darren</authors>
<owners>Darren</owners>
<description>wechaty grpc</description>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<PackageiconUrl>https://wechaty.js.org/img/wechaty-icon.svg</PackageiconUrl>
<PackageProjectUrl>https://github.com/Chatie/grpc</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Chatie/grpc</RepositoryUrl>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.3" PrivateAssets="All" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions proto/wechaty/puppet/base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

enum PayloadType {
PAYLOAD_TYPE_UNKNOWN = 0;
Expand Down
1 change: 1 addition & 0 deletions proto/wechaty/puppet/contact.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

import "google/protobuf/wrappers.proto";

Expand Down
1 change: 1 addition & 0 deletions proto/wechaty/puppet/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

enum EventType {
EVENT_TYPE_UNSPECIFIED = 0;
Expand Down
1 change: 1 addition & 0 deletions proto/wechaty/puppet/friendship.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

import "google/protobuf/wrappers.proto";

Expand Down
1 change: 1 addition & 0 deletions proto/wechaty/puppet/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

import "google/protobuf/wrappers.proto";

Expand Down
1 change: 1 addition & 0 deletions proto/wechaty/puppet/room.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

import "google/protobuf/wrappers.proto";

Expand Down
1 change: 1 addition & 0 deletions proto/wechaty/puppet/room_invitation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

import "google/protobuf/wrappers.proto";

Expand Down
1 change: 1 addition & 0 deletions proto/wechaty/puppet/room_member.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

message RoomMemberPayloadRequest {
string id = 1;
Expand Down
1 change: 1 addition & 0 deletions proto/wechaty/puppet/tag.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

import "google/protobuf/wrappers.proto";

Expand Down