Skip to content

Commit 7a0a040

Browse files
committed
Add C# SDK
1 parent 73a5940 commit 7a0a040

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1211
-46
lines changed

.buildkite/pipeline.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@
5959
key: "ruby",
6060
sdk_label: "sdk-ruby",
6161
app_label: "app-ruby"
62+
},
63+
{
64+
icon: ":csharp:",
65+
label: "C#",
66+
key: "csharp",
67+
sdk_label: "sdk-csharp",
68+
app_label: "app-csharp"
6269
}
6370
]
6471

.buildkite/release.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"GITHUB_TOKEN",
1212
"NPM_TOKEN",
1313
"PYPI_TOKEN",
14-
"GEM_HOST_API_KEY"
14+
"GEM_HOST_API_KEY",
15+
"NUGET_API_KEY"
1516
]
1617
}},
1718
{ "rubygems-oidc#v0.2.0": { role: "rg_oidc_akr_emf87k6zphtb7x7adyrk" } },
@@ -22,7 +23,8 @@
2223
parameters: {
2324
NPM_TOKEN: "/prod/buildkite-sdk/npm-token",
2425
PYPI_TOKEN: "/prod/buildkite-sdk/pypi-token",
25-
GITHUB_TOKEN: "/prod/buildkite-sdk/github-token"
26+
GITHUB_TOKEN: "/prod/buildkite-sdk/github-token",
27+
NUGET_API_KEY: "/prod/buildkite-sdk/nuget-api-key"
2628
}
2729
}}
2830
]
@@ -79,6 +81,13 @@
7981
key: "ruby",
8082
sdk_label: "sdk-ruby",
8183
app_label: "app-ruby"
84+
},
85+
{
86+
icon: ":csharp:",
87+
label: "C#",
88+
key: "csharp",
89+
sdk_label: "sdk-csharp",
90+
app_label: "app-csharp"
8291
}
8392
]
8493

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ __pycache__
1212
/coverage
1313
/reports
1414

15+
# C# build artifacts
16+
bin/
17+
obj/
18+
*.user
19+
*.suo
20+
*.sln.cache
21+
*.userprefs
22+
*.pidb
23+
*.userprefs
24+
*.sln.ide
25+
*.nupkg
26+
*.snupkg
27+
apps/csharp/bin/
28+
apps/csharp/obj/
29+
sdk/csharp/bin/
30+
sdk/csharp/obj/
31+
32+
# C# DocFX documentation artifacts
33+
sdk/csharp/api/
34+
sdk/csharp/_site/
35+
1536
node_modules
1637
dist
1738
out
@@ -21,5 +42,20 @@ tmp
2142

2243
Gemfile.lock
2344

45+
# Generated schema and environment files (regenerated by gen-types.js)
46+
sdk/typescript/src/schema.ts
47+
sdk/python/src/buildkite_sdk/schema.py
48+
sdk/go/sdk/schema/schema.go
49+
sdk/ruby/lib/schema.rb
50+
sdk/csharp/src/Buildkite.Sdk/Schema.cs
51+
sdk/typescript/src/environment.ts
52+
sdk/python/src/buildkite_sdk/environment.py
53+
sdk/go/sdk/buildkite/environment.go
54+
sdk/ruby/lib/environment.rb
55+
sdk/csharp/src/Buildkite.Sdk/Environment.cs
56+
57+
# Auto-generated solution file
58+
*.sln
59+
2460
.DS_Store
2561
Thumbs.db

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ RUN curl https://mise.run | sh
2121
RUN mise install node@latest && mise use --global node@latest
2222
RUN mise install python@latest && mise use --global python@latest
2323
RUN mise install go@latest && mise use --global go@latest
24+
RUN mise install dotnet@latest && mise use --global dotnet@latest
2425

2526
# Install Python tools.
2627
RUN pip install --no-cache-dir uv black

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
A multi-language SDK for [Buildkite](https://buildkite.com)! 🪁
66

7-
Consumes the [Buildkite pipeline schema](https://github.com/buildkite/pipeline-schema) and generates and publishes packages for TypeScript or JavaScript, Python, Go, and Ruby.
7+
Consumes the [Buildkite pipeline schema](https://github.com/buildkite/pipeline-schema) and generates and publishes packages for TypeScript or JavaScript, Python, Go, Ruby, and C#.
88

99
## Installing and using the SDKs
1010

@@ -16,9 +16,10 @@ Learn more about how to set up the Buildkite SDK for each langauge, and use it t
1616

1717
To work on the SDK, you'll need current versions of the following tools:
1818

19-
- [Node.js](https://nodejs.org/en/download), [Python](https://www.python.org/downloads/), [Go](https://go.dev/doc/install), [Ruby](https://www.ruby-lang.org/en/documentation/installation/)
19+
- [Node.js](https://nodejs.org/en/download), [Python](https://www.python.org/downloads/), [Go](https://go.dev/doc/install), [Ruby](https://www.ruby-lang.org/en/documentation/installation/), [.NET](https://dotnet.microsoft.com/download)
2020
- For Python: [uv](https://docs.astral.sh/uv/), [Black](https://black.readthedocs.io/en/stable/)
2121
- For Ruby: [Bundler](https://bundler.io/)
22+
- For C#: [.NET SDK](https://dotnet.microsoft.com/download)
2223

2324
See `mise.toml` for details. (We also recommend [Mise](https://mise.jdx.dev/) for tool-version management.) If you're on a Mac, and you use [Homebrew](https://brew.sh/), you can run `brew bundle` and `mise install` to get all you need:
2425

@@ -121,14 +122,16 @@ All SDKs version on the same cadence. To publish a new version (of all SDKs), fo
121122
- https://pypi.org/project/buildkite-sdk/
122123
- https://pkg.go.dev/github.com/buildkite/buildkite-sdk/sdk/go (this usually takes a minute or two)
123124
- https://rubygems.org/gems/buildkite-sdk
125+
- https://www.nuget.org/packages/Buildkite.Sdk
124126
125127
### Required environment variables
126128
127129
The following environment variables are required for releasing and publishing:
128130
129131
- `GITHUB_TOKEN` for creating GitHub releases (with `@octokit/rest`)
130132
- `NPM_TOKEN` for publishing to npm (with `npm publish`)
131-
- `PYPI_TOKEN` fror publishing to PyPI (with `uv publish`)
133+
- `PYPI_TOKEN` for publishing to PyPI (with `uv publish`)
132134
- `GEM_HOST_API_KEY` for publishing to RubyGems (with `gem push`)
135+
- `NUGET_API_KEY` for publishing to NuGet (with `dotnet nuget push`)
133136
134137
See the `publish:all` and `release:all` tasks in `./project.json` for details.

apps/csharp/App.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<ProjectReference Include="../../sdk/csharp/Buildkite.Sdk.csproj" />
9+
</ItemGroup>
10+
</Project>

apps/csharp/Program.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.IO;
3+
using System.Net;
4+
using Buildkite.Sdk;
5+
6+
var pipeline = new Pipeline();
7+
8+
pipeline.AddStep(new CommandStep
9+
{
10+
Label = "some-label",
11+
Command = "echo 'Hello, world!'"
12+
});
13+
14+
Directory.CreateDirectory("../../out/apps/csharp");
15+
16+
var json = pipeline.ToJson();
17+
File.WriteAllText("../../out/apps/csharp/pipeline.json", json);
18+
19+
var yaml = pipeline.ToYaml();
20+
File.WriteAllText("../../out/apps/csharp/pipeline.yaml", yaml);

apps/csharp/project.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "app-csharp",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "apps/csharp",
5+
"projectType": "application",
6+
"tags": [],
7+
"targets": {
8+
"install": {
9+
"executor": "nx:run-commands",
10+
"options": {
11+
"commands": ["dotnet restore"],
12+
"cwd": "apps/csharp"
13+
}
14+
},
15+
"clean": {
16+
"executor": "nx:run-commands",
17+
"options": {
18+
"commands": ["dotnet clean", "rimraf bin", "rimraf obj"],
19+
"cwd": "apps/csharp"
20+
},
21+
"cache": false
22+
},
23+
"format": {
24+
"executor": "nx:run-commands",
25+
"options": {
26+
"commands": ["dotnet format"],
27+
"cwd": "apps/csharp"
28+
},
29+
"cache": false
30+
},
31+
"build": {
32+
"executor": "nx:run-commands",
33+
"outputs": ["{workspaceRoot}/dist/apps/csharp"],
34+
"options": {
35+
"commands": [
36+
"rimraf ../../dist/apps/csharp",
37+
"mkdir -p ../../dist/apps/csharp",
38+
"dotnet build --configuration Release --output ../../dist/apps/csharp"
39+
],
40+
"cwd": "apps/csharp",
41+
"parallel": false
42+
},
43+
"cache": false
44+
},
45+
"run": {
46+
"executor": "nx:run-commands",
47+
"dependsOn": ["build"],
48+
"options": {
49+
"commands": ["dotnet run"],
50+
"cwd": "apps/csharp"
51+
}
52+
},
53+
"test": {
54+
"options": {
55+
"passWithNoTests": true
56+
}
57+
}
58+
}
59+
}

infra/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ const errorDocument = config.require("errorDocument");
1010
// Create an S3 bucket to hold the docs.
1111
const bucket = new aws.s3.BucketV2("bucket", {
1212
tags: {
13-
Name: 'bk-sdk-docs-bucket',
14-
CostBucket: 'marketing-site',
15-
VantaNoAlert: 'Bucket intentionally public',
13+
Name: "bk-sdk-docs-bucket",
14+
CostBucket: "marketing-site",
15+
VantaNoAlert: "Bucket intentionally public",
1616
},
1717
});
1818

19-
2019
const bucketWebsite = new aws.s3.BucketWebsiteConfigurationV2(
2120
"bucket-website",
2221
{

mise.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node = "latest"
33
python = "latest"
44
go = "latest"
55
ruby = "latest"
6+
dotnet = "9.0"

0 commit comments

Comments
 (0)