Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
woksin committed Jul 6, 2020
1 parent 2a7a125 commit 01d801a
Show file tree
Hide file tree
Showing 17 changed files with 412 additions and 37 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI/CD Workflow

env:
PRERELEASE_BRANCHES: '' # Comma separated list of prerelease branch names. 'alpha,rc, ...'
CASCADES: '' # Comma separated list of cascading repos. 'dolittle/DotNet.SDK,...'
NUGET_OUTPUT: Artifacts/NuGet

on:
push:
branches:
- '**'
pull_request:
types: [closed]

jobs:
context:
name: Establish Context
runs-on: ubuntu-latest
outputs:
version: ${{ steps.context.outputs.current-version }}
should-publish: ${{ steps.context.outputs.should-publish }}
release-type: ${{ steps.context.outputs.release-type }}
steps:
- uses: actions/checkout@v2
- name: Establish context
id: context
uses: dolittle/establish-context-action@v2
with:
prerelease-branches: ${{ env.PRERELEASE_BRANCHES }}

dot-net-ci:
name: .NET CI
runs-on: ubuntu-latest
needs: context

steps:
- uses: actions/checkout@v2
- name: Setup .Net
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- name: Build
run: dotnet build --configuration Release

create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [context, dot-net-ci]

if: ${{ needs.context.outputs.should-publish == 'true' }}

outputs:
version: ${{ steps.increment-version.outputs.next-version }}

steps:
- uses: actions/checkout@v2
- name: Increment version
id: increment-version
uses: dolittle/increment-version-action@v2
with:
version: ${{ needs.context.outputs.version }}
release-type: ${{ needs.context.outputs.release-type }}

- name: Create GitHub Release
uses: dolittle/github-release-action@v1
with:
cascading-release: false
version: ${{ steps.increment-version.outputs.next-version }}

dot-net-cd:
name: .NET CD
runs-on: ubuntu-latest
needs: [context, dot-net-ci, create-release]

if: ${{ needs.context.outputs.should-publish == 'true' }}

steps:
- uses: actions/checkout@v2
- name: Setup .Net
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- name: Create packages
run: dotnet pack --configuration Release -o ${{ env.NUGET_OUTPUT }} /p:PackageVersion=${{ needs.create-release.outputs.version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg

- name: Push NuGet packages
run: dotnet nuget push --skip-duplicate '${{ env.NUGET_OUTPUT }}/*.nupkg' --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion .vscode

This file was deleted.

38 changes: 17 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
Copyright (c) Dolittle, http://www.dolittle.com
MIT License

This software consists of voluntary contributions made by many
individuals (Authors.txt in the repository) For exact
contribution history, see the revision history and logs, available
at http://github.com/dolittle/DotNET.Core
Copyright (c) 2019 dolittle

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions Protobuf.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{B76DB529-B6EA-4128-98DF-8E23EBA06A9B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Protobuf.MSBuild", "Source\MSBuild\Protobuf.MSBuild.csproj", "{FB560E93-C095-4968-9E07-9E5DD67B9447}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Debug|x64.ActiveCfg = Debug|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Debug|x64.Build.0 = Debug|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Debug|x86.ActiveCfg = Debug|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Debug|x86.Build.0 = Debug|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Release|Any CPU.Build.0 = Release|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Release|x64.ActiveCfg = Release|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Release|x64.Build.0 = Release|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Release|x86.ActiveCfg = Release|Any CPU
{FB560E93-C095-4968-9E07-9E5DD67B9447}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FB560E93-C095-4968-9E07-9E5DD67B9447} = {B76DB529-B6EA-4128-98DF-8E23EBA06A9B}
EndGlobalSection
EndGlobal
112 changes: 112 additions & 0 deletions Source/JavaScript/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env node

let toolsPath = require.resolve('grpc-tools');
let nodeModulesRoot = toolsPath.substr(0, toolsPath.indexOf('/grpc-tools'));

console.log(`Using tooling from ${nodeModulesRoot}`);

const path = require('path');
const glob = require('glob');
const del = require('del');
const fs = require('fs');

const { exec, execSync } = require('child_process');

if (process.argv.length < 4) {
console.log('Usage:\n')
console.log('dolittle_proto_build grpc-node|grpc-web -I[include path] [source path(s)]')
console.log('\n');
console.log('The ordering of the arguments is important.')
console.log('You can have more than one include path, just add multiple `-I` options.');
process.exit(0);
return;
}

console.log('Delete existing declaration files');
del('./*.d.ts', '**/*.d.ts', '!node_modules/**/*', 'lib');

let args = '';
if (process.argv[2] == 'grpc-web') {
args = `--plugin=protoc-gen-grpc-web=${path.join(__dirname, './grpc-web/macOS/protoc-gen-grpc-web')} `;
args += '--grpc-web_out=import_style=commonjs,mode=grpcwebtext:. '
} else {
args = `--plugin=protoc-gen-grpc=$nodemodules'/.bin/grpc_tools_node_protoc_plugin' `;
args += `--grpc_out=./ `;
}
let subFolder = process.argv[3];
let hasSubFolder = subFolder !== '.';

let patterns = ['*.proto', '**/*.proto'];
let ignorePatterns = ['', '*.proto'];

const getAllFiles = function (dirPath, containing, arrayOfFiles) {
files = fs.readdirSync(dirPath)

arrayOfFiles = arrayOfFiles || []

if (dirPath.indexOf('node_modules') < 0) {

files.forEach(function (file) {

if (fs.statSync(dirPath + "/" + file).isDirectory()) {
arrayOfFiles = getAllFiles(dirPath + "/" + file, containing, arrayOfFiles)
} else {
if (file.indexOf(containing) >= 0 || containing == '') {
arrayOfFiles.push(path.join(dirPath, file));
}
}
});
}


return arrayOfFiles
}

for (var i = 3; i < process.argv.length; i++) {
let arg = process.argv[i];
if (arg.indexOf('-') == 0) {
args += `${arg} `;
continue;
}

let folder = path.join(process.cwd(), arg);
patterns.forEach((pattern, patternIndex) => {
let files = glob.sync(pattern, {
cwd: folder,
ignore: ignorePatterns[patternIndex]
});
if (files.length > 0) {
args += `${path.join(arg, pattern)} `;
}
});
}

console.log(`Looking for .proto files in '${args.trim()}'`);

process.env.nodemodules = nodeModulesRoot;

let scriptPath = path.join(__dirname, `generate_proxies.sh`);
scriptPath = `${scriptPath} ${args.trim()}`;
console.log(`Generate ${scriptPath}`)
const generate = exec(`${scriptPath}`, (error, stdout, stderr) => {
console.log(stdout);
console.log(stderr);

if (error == null) {
console.log('Transpile any TypeScript files');
execSync(`npx tsc --declaration false`, { stdio: 'inherit' });

if (process.argv[2] == 'grpc-web') {
console.log('Rename for web')

console.log(process.cwd());

const allFiles = getAllFiles(process.cwd(), 'grpc_pb.d.ts');
allFiles.forEach(_ => fs.renameSync(_, _.replace('grpc_pb','grpc_web_pb')));
}

console.log('Copy declaration files to lib')
execSync(`find . -name '*.d.ts' -not -path './node_modules/*' -not -path './lib/*' | cpio -pdm ./lib`, { stdio: 'inherit' });
}
});

11 changes: 11 additions & 0 deletions Source/JavaScript/generate_proxies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
echo "Generate Proxies"
find . -type f -iname '*.ts' ! -iname "index.*" -not -path './node_modules/*' -delete
find . -type f -iname '*.js' ! -iname "index.*" -not -path './node_modules/*' -delete

echo $*

npx protoc --js_out=import_style=commonjs,binary:./ \
--ts_out=service=grpc-node:./ \
--plugin=protoc-gen-ts=$nodemodules'/.bin/protoc-gen-ts' \
$*
Binary file not shown.
33 changes: 33 additions & 0 deletions Source/JavaScript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@dolittle/protobuf.build",
"version": "1.1.2",
"description": "",
"publishConfig": {
"access": "public"
},
"bin": {
"dolittle_proto_build": "./build.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dolittle-tools/JavaScript.Protobuf.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/dolittle-tools/JavaScript.Protobuf/issues"
},
"homepage": "https://github.com/dolittle-tools/JavaScript.Protobuf#readme",
"dependencies": {
"@types/google-protobuf": "^3.7.2",
"@types/node": "^13.13.5",
"del-cli": "^3.0.0",
"glob": "^7.1.6",
"grpc": "^1.24.2",
"grpc-tools": "^1.8.1",
"grpc-web": "^1.0.7",
"ts-protoc-gen": "^0.12.0",
"typescript": "^3.8.3"
},
"devDependencies": {}
}
6 changes: 6 additions & 0 deletions Source/MSBuild/Dolittle.Protobuf.MSBuild.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="TaskFolder;TaskAssembly">
<PropertyGroup>
<DolittleProtoProject>NotSet</DolittleProtoProject>
<DolittleProtoRoot>../</DolittleProtoRoot>
</PropertyGroup>
</Project>
25 changes: 25 additions & 0 deletions Source/MSBuild/Dolittle.Protobuf.MSBuild.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<IncludeSource>True</IncludeSource>
<Protobuf_NoWarnMissingExpected>true</Protobuf_NoWarnMissingExpected>
</PropertyGroup>

<Import Project="$(NuGetPackageRoot)grpc.tools/2.23.0/build/Grpc.Tools.props"/>
<Import Project="$(NuGetPackageRoot)grpc.tools/2.23.0/build/Grpc.Tools.targets"/>

<ItemGroup>
<Protobuf Include="$(DolittleProtoProject)/**/*.proto"
ProtoRoot="$(DolittleProtoRoot)"
OutputDir="%(RecursiveDir)"
GrpcServices="Both"
CompileOutputs="False" />
</ItemGroup>

<Target Name="DeleteSourceFiles" BeforeTargets="BeforeBuild">
<ItemGroup>
<FilesToDelete Include="**/*.cs"/>
</ItemGroup>
<Delete Files="@(FilesToDelete)"/>
</Target>
</Project>
Loading

0 comments on commit 01d801a

Please sign in to comment.