From 18f5686eaf2792f89a08ae9fd9311bc71d0720fa Mon Sep 17 00:00:00 2001 From: Patrick Florek Date: Mon, 17 Jan 2022 18:10:33 +0100 Subject: [PATCH] feat: release and publish --- .github/workflows/build.yml | 50 +++++++++++++++++++++++++++ .github/workflows/release.yml | 63 +++++++++++++++++++++++++++++++++++ .mergify.yml | 4 +++ .projen/tasks.json | 30 +++++++++++++++++ .projenrc.js | 23 +++++++++++-- package.json | 16 ++++++++- 6 files changed, 183 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9aaa03e..08e1ca6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,3 +104,53 @@ jobs: run: cd .repo && npx projen package:js - name: Collect js Artifact run: mv .repo/dist dist + package-python: + needs: build + runs-on: ubuntu-latest + permissions: {} + if: "! needs.build.outputs.self_mutation_happened" + steps: + - uses: actions/setup-node@v2 + with: + node-version: 14.x + - uses: actions/setup-python@v2 + with: + python-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: build-artifact + path: dist + - name: Prepare Repository + run: mv dist .repo + - name: Install Dependencies + run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Create python artifact + 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@v2 + with: + node-version: 14.x + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: build-artifact + path: dist + - 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 4ec8eb4..c65a113 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -100,3 +100,66 @@ jobs: NPM_DIST_TAG: latest NPM_REGISTRY: registry.npmjs.org NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + release_pypi: + name: Publish to PyPI + needs: release + runs-on: ubuntu-latest + permissions: + contents: read + if: needs.release.outputs.latest_commit == github.sha + steps: + - uses: actions/setup-node@v2 + with: + node-version: 14.x + - uses: actions/setup-python@v2 + with: + python-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: build-artifact + path: dist + - name: Prepare Repository + run: mv dist .repo + - name: Install Dependencies + run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Create python artifact + run: cd .repo && npx projen package:python + - name: Collect python Artifact + run: mv .repo/dist dist + - name: Release + run: npx -p jsii-release@latest jsii-release-pypi + env: + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + 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@v2 + with: + node-version: 14.x + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: build-artifact + path: dist + - 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 + run: npx -p jsii-release@latest jsii-release-nuget + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} diff --git a/.mergify.yml b/.mergify.yml index fa09059..31c8a3f 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -7,6 +7,8 @@ queue_rules: - -label~=(do-not-merge) - 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: @@ -23,3 +25,5 @@ pull_request_rules: - -label~=(do-not-merge) - 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 ad68c09..5da5c2a 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -135,6 +135,24 @@ "steps": [ { "spawn": "package:js" + }, + { + "spawn": "package:python" + }, + { + "spawn": "package:dotnet" + } + ] + }, + "package:dotnet": { + "name": "package:dotnet", + "description": "Create dotnet language bindings", + "steps": [ + { + "exec": "jsii_version=$(node -p \"JSON.parse(fs.readFileSync('.jsii')).jsiiVersion.split(' ')[0]\")" + }, + { + "exec": "npx jsii-pacmak@$jsii_version -v --target dotnet" } ] }, @@ -150,6 +168,18 @@ } ] }, + "package:python": { + "name": "package:python", + "description": "Create python language bindings", + "steps": [ + { + "exec": "jsii_version=$(node -p \"JSON.parse(fs.readFileSync('.jsii')).jsiiVersion.split(' ')[0]\")" + }, + { + "exec": "npx jsii-pacmak@$jsii_version -v --target python" + } + ] + }, "post-compile": { "name": "post-compile", "description": "Runs after successful compilation", diff --git a/.projenrc.js b/.projenrc.js index 4fe399c..3d8200e 100644 --- a/.projenrc.js +++ b/.projenrc.js @@ -1,4 +1,4 @@ -const { awscdk } = require("projen"); +const { awscdk, javascript } = require("projen"); const project = new awscdk.AwsCdkConstructLibrary({ author: "Andreas Forster", authorAddress: "andreas.forster@pepperize.com", @@ -6,7 +6,6 @@ const project = new awscdk.AwsCdkConstructLibrary({ license: "MIT", copyrightOwner: "Pepperize UG (haftungsbeschränkt)", cdkVersion: "1.139.0", - defaultReleaseBranch: "main", name: "@pepperize/cdk-private-bucket", description: "This project provides a CDK construct for creating private S3 bucket.", keywords: ["aws", "cdk", "bucket", "s3"], @@ -31,6 +30,26 @@ const project = new awscdk.AwsCdkConstructLibrary({ }, }, + defaultReleaseBranch: "main", + npmAccess: javascript.NpmAccess.PUBLIC, + release: { + releaseEveryCommit: true, + }, + releaseToNpm: true, + publishToNuget: { + dotNetNamespace: "Pepperize.CDK", + packageId: "Pepperize.CDK.PrivateBucket", + }, + publishToPypi: { + distName: "pepperize.cdk-private-bucket", + module: "pepperize_cdk_private_bucket", + }, + // publishToMaven: { + // javaPackage: "your_java_package", + // mavenGroupId: "your_package_group_id", + // mavenArtifactId: "your_package_target_id", + // }, + gitignore: [".idea/", "*.iml"], cdkDependencies: ["@aws-cdk/aws-s3"], // v1 diff --git a/package.json b/package.json index 063b4a0..d335d5a 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "eslint": "npx projen eslint", "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", "post-upgrade": "npx projen post-upgrade", "pre-compile": "npx projen pre-compile", @@ -78,6 +80,9 @@ ], "main": "lib/index.js", "license": "MIT", + "publishConfig": { + "access": "public" + }, "version": "0.0.0", "jest": { "testMatch": [ @@ -124,7 +129,16 @@ "stability": "stable", "jsii": { "outdir": "dist", - "targets": {}, + "targets": { + "python": { + "distName": "pepperize.cdk-private-bucket", + "module": "pepperize_cdk_private_bucket" + }, + "dotnet": { + "namespace": "Pepperize.CDK", + "packageId": "Pepperize.CDK.PrivateBucket" + } + }, "tsc": { "outDir": "lib", "rootDir": "src"