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

adds dotnet tool packaging for kiota #169

Merged
merged 9 commits into from
May 25, 2021
36 changes: 36 additions & 0 deletions .github/workflows/dotnet-tool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Dotnet tool
on:
push:
branches: [main]
tags: ['v*']
paths: ['src/**', '.github/workflows/**']
jobs:
push_to_feed:
env:
relativePath: ./src/kiota
environment:
name: staging_feeds
name: Push tool to GitHub packages
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2.3.4
- name: Setup .NET
uses: actions/setup-dotnet@v1.8.0
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore kiota.csproj
working-directory: ${{ env.relativePath }}
- name: Build
run: dotnet build kiota.csproj --no-restore -c Release
working-directory: ${{ env.relativePath }}
- name: Pack
run: dotnet pack kiota.csproj --no-restore --no-build --verbosity normal -c Release
working-directory: ${{ env.relativePath }}
- uses: actions/upload-artifact@v2
with:
name: drop
path: |
${{ env.relativePath }}/nupkg/*.nupkg
- run: dotnet nuget push "${{ env.relativePath }}/nupkg/*.nupkg" --skip-duplicate -s https://nuget.pkg.github.com/microsoft/index.json -k ${{ secrets.PUBLISH_GH_TOKEN }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Adds kiota packaging as a dotnet tool #169
- Adds input parameters validation #168
- Expands code coverage to 88% #147

## [0.0.4] - 2021-04-28

### Changed
Expand Down
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,42 @@ No additional tools are required for dotnet projects.

### Generating SDKs

You can either clone the repository and build Kiota locally, download and run binaries or run the docker image.
You can either clone the repository and [build Kiota locally](#building-kiota), [download and run binaries](#running-kiota-from-binaries), [install and run the dotnet tool](#running-kiota-from-the-dotnet-tool) or [run the docker image](#running-kiota-with-docker).

#### Running Kiota from the dotnet tool

1. Navigate to [New personal access token](https://github.com/settings/tokens/new) and generate a new token. (permissions: read:package).
1. Copy the token, you will need it later.
1. Enable the SSO on the token if you are a Microsoft employee.
1. Create a `nuget.config` file in the current directory with the following content.

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="GitHub" value="https://nuget.pkg.github.com/microsoft/index.json" />
</packageSources>
<packageSourceCredentials>
<GitHub>
<add key="Username" value="" /><!-- your github username -->
<!-- your github PAT: read:pacakges with SSO enabled for the Microsoft org (for microsoft employees only) -->
<add key="ClearTextPassword" value="" />
</GitHub>
</packageSourceCredentials>
</configuration>
```

1. Execute the following command to install the tool.

```Shell
dotnet tool install --global --configfile nuget.config kiota
```

1. Execute the following command to run kiota.

```Shell
kiota -d /some/input/description.yml -o /some/output/path --language csharp -n samespaceprefix
```

#### Running Kiota with Docker

Expand Down Expand Up @@ -72,7 +107,7 @@ Navigate to the output directory (usually under `src/kiota/bin/Release/net5.0`)
If you haven't built kiota locally, select the appropriate version from the [releases page](https://github.com/microsoft/kiota/releases).

```Shell
kiota.exe --openapi ../msgraph-sdk-powershell/openApiDocs/v1.0/mail.yml --language csharp -o ../somepath -n namespaceprefix
kiota.exe -d ../msgraph-sdk-powershell/openApiDocs/v1.0/mail.yml --language csharp -o ../somepath -n namespaceprefix
```

> Note: once your SDK is generated in your target project, you will need to add references to kiota abstractions and kiota core in your project. Refer to [Initializing target projects](#initializing-target-projects)
Expand Down
6 changes: 6 additions & 0 deletions src/kiota/kiota.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<PackAsTool>true</PackAsTool>
<ToolCommandName>kiota</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<Version>0.0.4</Version>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/microsoft/kiota</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
Expand Down