Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 7 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
"generatorName": "fernapi/fern-csharp-sdk",
"generatorVersion": "2.80.0",
"generatorConfig": {
"namespace": "CloudpdfApi",
"package-id": "CloudpdfApi"
"namespace": "CloudPDF",
"package-id": "CloudPDF",
"client-class-name": "CloudPDFClient",
"environment-class-name": "CloudPDFEnvironment",
"base-exception-class-name": "CloudPDFException",
"base-api-exception-class-name": "CloudPDFApiException"
},
"originGitCommit": "232d5e0240d5673a73c9ea7c7ae9e7b937fdd5b3",
"originGitCommit": "a0adb9e77ef16feaef2358d71b247b4f5a98fd23",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0-next.1",
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/sdk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ jobs:
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- run: dotnet build src/CloudpdfApi/CloudpdfApi.csproj -c Release -f net8.0
- run: dotnet build src/CloudPDF/CloudPDF.csproj -c Release -f net8.0
- run: dotnet pack src/CloudPDF/CloudPDF.csproj -c Release -o /tmp/cloudpdf-nuget
143 changes: 143 additions & 0 deletions .github/workflows/sdk-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: SDK Release

on:
push:
branches: [main]
paths-ignore:
- '.github/**'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: sdk-release
cancel-in-progress: false

jobs:
release:
name: Publish CloudPDF
if: github.event_name == 'workflow_dispatch' || vars.SDK_AUTO_PUBLISH_ENABLED == 'true'
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Verify generated release version
id: version
run: |
python - <<'PY'
import json
import os
import xml.etree.ElementTree as ET

project = ET.parse('src/CloudPDF/CloudPDF.csproj').getroot()
package_id = project.findtext('./PropertyGroup/PackageId')
version = project.findtext('./PropertyGroup/Version')
with open('cloudpdf-generation.json', encoding='utf-8') as file:
generation = json.load(file)
if generation['language'] != 'csharp':
raise RuntimeError('generation language is not csharp')
if package_id != 'CloudPDF':
raise RuntimeError(f'unexpected NuGet package {package_id}')
if version != generation['sdkVersion']:
raise RuntimeError(f'package version {version} does not match generated version {generation["sdkVersion"]}')
prerelease = '-' in generation['canonicalVersion']
with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as output:
output.write(f'version={version}\n')
output.write(f'tag=v{version}\n')
output.write(f'prerelease={str(prerelease).lower()}\n')
PY

- name: Pack NuGet package
run: dotnet pack src/CloudPDF/CloudPDF.csproj -c Release -o dist

- name: Protect immutable release tag
id: release-tag
env:
RELEASE_TAG: ${{ steps.version.outputs.tag }}
run: |
git fetch --force --tags origin
if git rev-parse --quiet --verify "refs/tags/$RELEASE_TAG" >/dev/null; then
tagged_commit="$(git rev-list -n 1 "$RELEASE_TAG")"
if [ "$tagged_commit" != "$GITHUB_SHA" ]; then
if git diff --quiet "$RELEASE_TAG" "$GITHUB_SHA" -- . ':(exclude).github/**'; then
echo "::notice::Reusing $RELEASE_TAG after a workflow-only change."
else
echo "::error::Release tag $RELEASE_TAG already points to different package source at $tagged_commit; bump the SDK version."
exit 1
fi
fi
echo "existed=true" >> "$GITHUB_OUTPUT"
else
git config user.name cloudpdf-sdk-bot
git config user.email hello@cloudpdf.com
git tag -a "$RELEASE_TAG" -m "CloudPDF .NET SDK $RELEASE_TAG"
git push origin "refs/tags/$RELEASE_TAG"
echo "existed=false" >> "$GITHUB_OUTPUT"
fi

- name: Check NuGet publication state
id: registry
env:
VERSION: ${{ steps.version.outputs.version }}
TAG_EXISTED: ${{ steps.release-tag.outputs.existed }}
run: |
normalized_version="$(printf '%s' "$VERSION" | tr '[:upper:]' '[:lower:]')"
package_url="https://api.nuget.org/v3-flatcontainer/cloudpdf/$normalized_version/cloudpdf.$normalized_version.nupkg"
http_status="$(curl --silent --show-error --output /dev/null --write-out '%{http_code}' "$package_url")"
case "$http_status" in
200)
if [ "$TAG_EXISTED" != 'true' ]; then
echo "::error::CloudPDF $VERSION already exists on NuGet but its release tag did not exist."
exit 1
fi
echo "publish=false" >> "$GITHUB_OUTPUT"
;;
404)
echo "publish=true" >> "$GITHUB_OUTPUT"
;;
*)
echo "::error::NuGet returned HTTP $http_status while checking CloudPDF $VERSION."
exit 1
;;
esac

- name: Exchange GitHub identity for a NuGet API key
if: steps.registry.outputs.publish == 'true'
id: nuget-login
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}

- name: Publish to NuGet
if: steps.registry.outputs.publish == 'true'
env:
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: dotnet nuget push "dist/CloudPDF.${{ steps.version.outputs.version }}.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json

- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.version.outputs.tag }}
PRERELEASE: ${{ steps.version.outputs.prerelease }}
run: |
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
exit 0
fi
args=(--verify-tag --generate-notes --title "CloudPDF .NET SDK $RELEASE_TAG")
if [ "$PRERELEASE" = 'true' ]; then args+=(--prerelease); fi
gh release create "$RELEASE_TAG" "${args[@]}"
4 changes: 4 additions & 0 deletions CloudPDF.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Solution>
<Project Path="src/CloudPDF.Test/CloudPDF.Test.csproj" />
<Project Path="src/CloudPDF/CloudPDF.csproj" />
</Solution>
4 changes: 0 additions & 4 deletions CloudpdfApi.slnx

This file was deleted.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Cloudpdf C# Library
# CloudPDF .NET SDK

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Cloudpdf%2FC%23)
[![nuget shield](https://img.shields.io/nuget/v/CloudpdfApi)](https://nuget.org/packages/CloudpdfApi)
[![nuget shield](https://img.shields.io/nuget/v/CloudPDF)](https://nuget.org/packages/CloudPDF)

The Cloudpdf C# library provides convenient access to the Cloudpdf APIs from C#.
The official .NET SDK for the CloudPDF API.

## Table of Contents

Expand All @@ -29,7 +29,7 @@ This SDK requires:
## Installation

```sh
dotnet add package CloudpdfApi
dotnet add package CloudPDF
```

## Reference
Expand All @@ -41,9 +41,9 @@ A full reference for this library is available [here](./reference.md).
Instantiate and use the client with the following:

```csharp
using CloudpdfApi;
using CloudPDF;

var client = new CloudpdfApiClient("TOKEN");
var client = new CloudPDFClient("TOKEN");
await client.Tenants.CreateAsync(new TenantsCreateRequest { Id = "id" });
```

Expand All @@ -53,11 +53,11 @@ When the API returns a non-success status code (4xx or 5xx response), a subclass
will be thrown.

```csharp
using CloudpdfApi;
using CloudPDF;

try {
var response = await client.Tenants.CreateAsync(...);
} catch (CloudpdfApiApiException e) {
} catch (CloudPDFApiException e) {
System.Console.WriteLine(e.Body);
System.Console.WriteLine(e.StatusCode);

Expand Down Expand Up @@ -125,7 +125,7 @@ var response = await client.Tenants.CreateAsync(
Access raw HTTP response data (status code, headers, URL) alongside parsed response data using the `.WithRawResponse()` method.

```csharp
using CloudpdfApi;
using CloudPDF;

// Access raw response data (status code, headers, etc.) alongside the parsed response
var result = await client.Tenants.CreateAsync(...).WithRawResponse();
Expand Down Expand Up @@ -205,7 +205,7 @@ var response = await client.Tenants.CreateAsync(
This SDK uses forward-compatible enums that can handle unknown values gracefully.

```csharp
using CloudpdfApi;
using CloudPDF;

// Using a built-in value
var listDocumentsRequestState = ListDocumentsRequestState.Pending;
Expand Down
2 changes: 1 addition & 1 deletion cloudpdf-generation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "6858ce7912e9063d8fb171ade95fc473db01c5971a3af241a612dda79cc05100",
"gitCommit": "232d5e0240d5673a73c9ea7c7ae9e7b937fdd5b3",
"gitCommit": "a0adb9e77ef16feaef2358d71b247b4f5a98fd23",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
Loading
Loading