Initial BinaryLane v2 API client

This commit is contained in:
2026-08-16 21:52:42 +10:00
commit fcd0d22b0d
91 changed files with 18691 additions and 0 deletions
+91
View File
@@ -0,0 +1,91 @@
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
NUGET_XMLDOC_MODE: skip
jobs:
build-test-pack:
name: Build, test, and pack
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out source
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Set up .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6
with:
dotnet-version: 8.0.x
global-json-file: global.json
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Restore locked dependencies
run: |
dotnet restore src/BinaryLane.Api/BinaryLane.Api.csproj --locked-mode
dotnet restore tests/BinaryLane.Api.Tests/BinaryLane.Api.Tests.csproj --locked-mode
dotnet restore examples/BinaryLane.Api.Demo/BinaryLane.Api.Demo.csproj --locked-mode
- name: Build
run: |
dotnet build src/BinaryLane.Api/BinaryLane.Api.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true -p:BuildInParallel=false
dotnet build tests/BinaryLane.Api.Tests/BinaryLane.Api.Tests.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true -p:BuildInParallel=false
dotnet build examples/BinaryLane.Api.Demo/BinaryLane.Api.Demo.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true -p:BuildInParallel=false
- name: Test
run: >-
dotnet test tests/BinaryLane.Api.Tests/BinaryLane.Api.Tests.csproj --configuration Release --no-build
-m:1
--logger "trx;LogFileName=test-results.trx"
--results-directory TestResults
- name: Verify formatting
run: |
dotnet format src/BinaryLane.Api/BinaryLane.Api.csproj --verify-no-changes --no-restore
dotnet format tests/BinaryLane.Api.Tests/BinaryLane.Api.Tests.csproj --verify-no-changes --no-restore
dotnet format examples/BinaryLane.Api.Demo/BinaryLane.Api.Demo.csproj --verify-no-changes --no-restore
- name: Pack
run: >-
dotnet pack src/BinaryLane.Api/BinaryLane.Api.csproj
--configuration Release --no-build --output artifacts
-p:BuildInParallel=false
- name: Compile the demo against the packed package
run: ./eng/test-demo-package.sh artifacts
- name: Upload NuGet packages
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: nuget-packages
path: artifacts/
if-no-files-found: error
retention-days: 14
- name: Upload test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: test-results
path: TestResults/
if-no-files-found: ignore
retention-days: 14
+56
View File
@@ -0,0 +1,56 @@
name: CodeQL
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '31 4 * * 4'
workflow_dispatch:
permissions:
actions: read
contents: read
security-events: write
jobs:
analyze:
name: Analyze C#
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out source
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Set up .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6
with:
dotnet-version: 8.0.x
global-json-file: global.json
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Initialize CodeQL
uses: github/codeql-action/init@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4
with:
languages: csharp
build-mode: manual
- name: Restore locked dependencies
run: |
dotnet restore src/BinaryLane.Api/BinaryLane.Api.csproj --locked-mode
dotnet restore tests/BinaryLane.Api.Tests/BinaryLane.Api.Tests.csproj --locked-mode
dotnet restore examples/BinaryLane.Api.Demo/BinaryLane.Api.Demo.csproj --locked-mode
- name: Build for analysis
run: |
dotnet build src/BinaryLane.Api/BinaryLane.Api.csproj --configuration Release --no-restore -p:BuildInParallel=false
dotnet build tests/BinaryLane.Api.Tests/BinaryLane.Api.Tests.csproj --configuration Release --no-restore -p:BuildInParallel=false
dotnet build examples/BinaryLane.Api.Demo/BinaryLane.Api.Demo.csproj --configuration Release --no-restore -p:BuildInParallel=false
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4
+92
View File
@@ -0,0 +1,92 @@
name: Monitor upstream OpenAPI contract
on:
schedule:
- cron: '17 3 * * 1'
workflow_dispatch:
permissions:
contents: read
issues: write
concurrency:
group: contract-monitor
cancel-in-progress: false
jobs:
check:
name: Check BinaryLane OpenAPI contract
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out source
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Compare live contract with the reviewed snapshot
id: contract
shell: bash
run: |
set +e
./eng/verify-openapi-contract.sh > contract-check.txt 2>&1
status=$?
set -e
cat contract-check.txt
case "$status" in
0)
echo "changed=false" >> "$GITHUB_OUTPUT"
;;
1)
echo "changed=true" >> "$GITHUB_OUTPUT"
;;
*)
echo "The contract check could not complete (exit $status)." >&2
exit "$status"
;;
esac
- name: Upload contract-check report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: contract-check
path: contract-check.txt
if-no-files-found: ignore
retention-days: 14
- name: Open one review issue for contract drift
if: steps.contract.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
existing_count="$(gh issue list \
--repo "$GITHUB_REPOSITORY" \
--state open \
--search 'in:title "BinaryLane OpenAPI contract changed"' \
--json number \
--jq 'length')"
if [[ "$existing_count" -gt 0 ]]; then
echo "An upstream-contract review issue is already open."
exit 0
fi
{
echo "BinaryLane's public OpenAPI contract no longer matches the reviewed snapshot."
echo
echo "Review the upstream change before updating generated code or SDK behavior."
echo
echo "```text"
cat contract-check.txt
echo "```"
echo
echo "Suggested next step: run `./eng/refresh-openapi-contract.sh`, review the diff,"
echo "then update models, fixtures, API coverage, docs, and tests in one pull request."
} > issue-body.md
gh issue create \
--repo "$GITHUB_REPOSITORY" \
--title "BinaryLane OpenAPI contract changed" \
--body-file issue-body.md
+186
View File
@@ -0,0 +1,186 @@
name: Publish
on:
push:
tags:
- 'v*'
permissions:
contents: read
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
NUGET_XMLDOC_MODE: skip
jobs:
build:
name: Validate, test, and pack
if: github.repository == 'alexhopeoconnor/binarylane-dotnet'
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
package_version: ${{ steps.package_version.outputs.value }}
steps:
- name: Check out tagged source
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
- name: Set up .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6
with:
dotnet-version: 8.0.x
global-json-file: global.json
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Verify the tagged commit is reachable from main
run: |
git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "Release tags must point to a commit reachable from main." >&2
exit 1
fi
- name: Assert tag, package version, and changelog agree
run: ./eng/assert-release-version.sh "${{ github.ref_name }}"
- name: Read package version
id: package_version
run: echo "value=$(./eng/read-package-version.sh)" >> "$GITHUB_OUTPUT"
- name: Restore locked dependencies
run: |
dotnet restore src/BinaryLane.Api/BinaryLane.Api.csproj --locked-mode
dotnet restore tests/BinaryLane.Api.Tests/BinaryLane.Api.Tests.csproj --locked-mode
dotnet restore examples/BinaryLane.Api.Demo/BinaryLane.Api.Demo.csproj --locked-mode
- name: Build
run: |
dotnet build src/BinaryLane.Api/BinaryLane.Api.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true -p:BuildInParallel=false
dotnet build tests/BinaryLane.Api.Tests/BinaryLane.Api.Tests.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true -p:BuildInParallel=false
dotnet build examples/BinaryLane.Api.Demo/BinaryLane.Api.Demo.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true -p:BuildInParallel=false
- name: Test
run: dotnet test tests/BinaryLane.Api.Tests/BinaryLane.Api.Tests.csproj --configuration Release --no-build -m:1
- name: Pack
run: >-
dotnet pack src/BinaryLane.Api/BinaryLane.Api.csproj
--configuration Release --no-build --output artifacts
-p:BuildInParallel=false
- name: Compile the demo against the packed package
run: ./eng/test-demo-package.sh artifacts
- name: Upload NuGet packages
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: nuget-packages
path: artifacts/
if-no-files-found: error
retention-days: 14
publish:
name: Publish to NuGet.org
needs: build
if: github.repository == 'alexhopeoconnor/binarylane-dotnet'
runs-on: ubuntu-latest
timeout-minutes: 10
environment: release
permissions:
contents: read
id-token: write
steps:
- name: Download NuGet packages
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: nuget-packages
path: artifacts
- name: Check trusted-publishing configuration
run: |
if [[ -z "${{ secrets.NUGET_USER }}" ]]; then
echo "Set the protected release-environment secret NUGET_USER to the NuGet.org username." >&2
exit 1
fi
- name: Authenticate to NuGet.org through GitHub OIDC
id: nuget_login
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish package
env:
NUGET_API_KEY: ${{ steps.nuget_login.outputs.NUGET_API_KEY }}
run: >-
dotnet nuget push "artifacts/*.nupkg"
--source https://api.nuget.org/v3/index.json
--api-key "$NUGET_API_KEY"
--skip-duplicate
- name: Publish symbols
env:
NUGET_API_KEY: ${{ steps.nuget_login.outputs.NUGET_API_KEY }}
shell: bash
run: |
shopt -s nullglob
for package in artifacts/*.snupkg; do
dotnet nuget push "$package" \
--source https://api.nuget.org/v3/index.json \
--api-key "$NUGET_API_KEY" \
--skip-duplicate
done
release:
name: Create GitHub Release
needs:
- build
- publish
if: github.repository == 'alexhopeoconnor/binarylane-dotnet'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Check out tagged source
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- name: Download NuGet packages
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: nuget-packages
path: artifacts
- name: Extract release notes
run: ./eng/extract-release-notes.sh "${{ needs.build.outputs.package_version }}" > release-notes.md
- name: Create or update GitHub Release
env:
GH_TOKEN: ${{ github.token }}
PACKAGE_VERSION: ${{ needs.build.outputs.package_version }}
TAG_NAME: ${{ github.ref_name }}
shell: bash
run: |
if gh release view "$TAG_NAME" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
gh release upload "$TAG_NAME" artifacts/* eng/openapi/contract.json --clobber --repo "$GITHUB_REPOSITORY"
gh release edit "$TAG_NAME" \
--title "BinaryLane.Api $PACKAGE_VERSION" \
--notes-file release-notes.md \
--repo "$GITHUB_REPOSITORY"
else
gh release create "$TAG_NAME" artifacts/* eng/openapi/contract.json \
--title "BinaryLane.Api $PACKAGE_VERSION" \
--notes-file release-notes.md \
--verify-tag \
--repo "$GITHUB_REPOSITORY"
fi