diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 271fbdc4..f304bba3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -141,3 +141,31 @@ jobs: run: cd .repo && npx projen package:python - name: Collect python Artifact run: mv .repo/dist dist + package-dotnet: + needs: build + runs-on: ubuntu-latest + permissions: {} + if: "! needs.build.outputs.self_mutation_happened" + steps: + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 + with: + node-version: 20.x + - uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 + with: + dotnet-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@b4aefff88e83a2676a730654e1ce3dce61880379 + with: + name: build-artifact + path: dist + - name: Restore build artifact permissions + run: cd dist && setfacl --restore=permissions-backup.acl + continue-on-error: true + - name: Prepare Repository + run: mv dist .repo + - name: Install Dependencies + run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Create dotnet artifact + run: cd .repo && npx projen package:dotnet + - name: Collect dotnet Artifact + run: mv .repo/dist dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18124c0b..98f227df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -147,3 +147,37 @@ jobs: TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} run: npx -p publib@latest publib-pypi + release_nuget: + name: Publish to NuGet Gallery + needs: release + runs-on: ubuntu-latest + permissions: + contents: read + if: needs.release.outputs.latest_commit == github.sha + steps: + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 + with: + node-version: 20.x + - uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 + with: + dotnet-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@b4aefff88e83a2676a730654e1ce3dce61880379 + with: + name: build-artifact + path: dist + - name: Restore build artifact permissions + run: cd dist && setfacl --restore=permissions-backup.acl + continue-on-error: true + - name: Prepare Repository + run: mv dist .repo + - name: Install Dependencies + run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Create dotnet artifact + run: cd .repo && npx projen package:dotnet + - name: Collect dotnet Artifact + run: mv .repo/dist dist + - name: Release + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + run: npx -p publib@latest publib-nuget diff --git a/.mergify.yml b/.mergify.yml index 299617cc..b4e099da 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -9,6 +9,7 @@ queue_rules: - status-success=build - status-success=package-js - status-success=package-python + - status-success=package-dotnet pull_request_rules: - name: Automatic merge on approval and successful build actions: @@ -26,3 +27,4 @@ pull_request_rules: - status-success=build - status-success=package-js - status-success=package-python + - status-success=package-dotnet diff --git a/.projen/tasks.json b/.projen/tasks.json index 0501abbc..b67f293c 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -181,6 +181,18 @@ }, { "spawn": "package:python" + }, + { + "spawn": "package:dotnet" + } + ] + }, + "package:dotnet": { + "name": "package:dotnet", + "description": "Create dotnet language bindings", + "steps": [ + { + "exec": "jsii-pacmak -v --target dotnet" } ] }, diff --git a/.projenrc.ts b/.projenrc.ts index 7ecacdc3..c1cd6fe4 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -32,6 +32,11 @@ const PUBLICATION_NAMESPACE = 'cdklabs'; const PROJECT_NAME = 'generative-ai-cdk-constructs'; const CDK_VERSION: string = '2.143.0'; +function camelCaseIt(input: string): string { + // Hypens and dashes to spaces and then CamelCase... + return input.replace(/-/g, ' ').replace(/_/g, ' ').replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, _) { if (+match === 0) return ''; return match.toUpperCase(); }); +} + const project = new awscdk.AwsCdkConstructLibrary({ author: 'Amazon Web Services - Prototyping and Cloud Engineering', authorAddress: 'https://aws.amazon.com', @@ -80,6 +85,11 @@ const project = new awscdk.AwsCdkConstructLibrary({ // twineRegistryUrl: '${{ secrets.TWINE_REGISTRY_URL }}', }, + publishToNuget: { + dotNetNamespace: camelCaseIt(PUBLICATION_NAMESPACE)+'.'+camelCaseIt(PROJECT_NAME), + packageId: camelCaseIt(PUBLICATION_NAMESPACE)+'.'+camelCaseIt(PROJECT_NAME), + }, + codeCov: true, codeCovTokenSecret: 'CODECOV_TOKEN', @@ -138,6 +148,8 @@ project.github?.actions.set('actions/checkout@v4', 'actions/checkout@b4ffde65f46 project.github?.actions.set('actions/download-artifact@v3', 'actions/download-artifact@b4aefff88e83a2676a730654e1ce3dce61880379'); // https://github.com/projen/projen/issues/3529 project.github?.actions.set('actions/download-artifact@v4', 'actions/download-artifact@b4aefff88e83a2676a730654e1ce3dce61880379'); project.github?.actions.set('actions/github-script@v6', 'actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410'); +project.github?.actions.set('actions/setup-dotnet@v3', 'actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3'); +project.github?.actions.set('actions/setup-dotnet@v4', 'actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3'); project.github?.actions.set('actions/setup-node@v3', 'actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8'); // https://github.com/projen/projen/issues/3529 project.github?.actions.set('actions/setup-node@v4', 'actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8'); project.github?.actions.set('actions/setup-python@v4', 'actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d'); // https://github.com/projen/projen/issues/3529 diff --git a/package.json b/package.json index 426b4955..a0e06793 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "generate-models-containers": "npx projen generate-models-containers", "package": "npx projen package", "package-all": "npx projen package-all", + "package:dotnet": "npx projen package:dotnet", "package:js": "npx projen package:js", "package:python": "npx projen package:python", "post-compile": "npx projen post-compile", @@ -148,6 +149,10 @@ "python": { "distName": "cdklabs.generative-ai-cdk-constructs", "module": "cdklabs.generative_ai_cdk_constructs" + }, + "dotnet": { + "namespace": "Cdklabs.GenerativeAiCdkConstructs", + "packageId": "Cdklabs.GenerativeAiCdkConstructs" } }, "tsc": {