From ec803f791cdf217c6867a24d68ff050bad433a7c Mon Sep 17 00:00:00 2001 From: uid10804 Date: Sun, 6 Nov 2022 07:24:03 +0100 Subject: [PATCH 1/2] feat: release package for python --- .projenrc.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.projenrc.js b/.projenrc.js index 0e463b9..8bb6bf9 100644 --- a/.projenrc.js +++ b/.projenrc.js @@ -17,6 +17,11 @@ const project = new awscdk.AwsCdkConstructLibrary({ '/.idea', 'status.json', ], + releaseToNpm: true, + publishToPypi: { + distName: 'pharindoko.cdk-internal-gateway', + module: 'pharindoko.cdk_internal_gateway', + }, sampleCode: false, compat: true, depsUpgradeOptions: { From 7699aa877b561f619a756a9401fb6bba2c4cc1d1 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 6 Nov 2022 06:27:38 +0000 Subject: [PATCH 2/2] chore: self mutation Signed-off-by: github-actions --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 35 +++++++++++++++++++++++++++++++++++ .mergify.yml | 2 ++ .projen/tasks.json | 12 ++++++++++++ package.json | 8 +++++++- 5 files changed, 84 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b2096af..c8c233e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,3 +104,31 @@ 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@v3 + with: + node-version: 14.x + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@v3 + 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 python artifact + run: cd .repo && npx projen package:python + - name: Collect python Artifact + run: mv .repo/dist dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dfe7523..137adb4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,3 +102,38 @@ jobs: NPM_REGISTRY: registry.npmjs.org NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: npx -p publib@latest publib-npm + 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@v3 + with: + node-version: 14.x + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@v3 + 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 python artifact + run: cd .repo && npx projen package:python + - name: Collect python Artifact + run: mv .repo/dist dist + - name: Release + env: + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + run: npx -p publib@latest publib-pypi diff --git a/.mergify.yml b/.mergify.yml index fa09059..891c7aa 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -7,6 +7,7 @@ queue_rules: - -label~=(do-not-merge) - status-success=build - status-success=package-js + - status-success=package-python pull_request_rules: - name: Automatic merge on approval and successful build actions: @@ -23,3 +24,4 @@ pull_request_rules: - -label~=(do-not-merge) - status-success=build - status-success=package-js + - status-success=package-python diff --git a/.projen/tasks.json b/.projen/tasks.json index 68ce0b0..2fa9ffc 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -145,6 +145,9 @@ "steps": [ { "spawn": "package:js" + }, + { + "spawn": "package:python" } ] }, @@ -157,6 +160,15 @@ } ] }, + "package:python": { + "name": "package:python", + "description": "Create python language bindings", + "steps": [ + { + "exec": "jsii-pacmak -v --target python" + } + ] + }, "post-compile": { "name": "post-compile", "description": "Runs after successful compilation", diff --git a/package.json b/package.json index eb395fd..31e8271 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "package": "npx projen package", "package-all": "npx projen package-all", "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", @@ -122,7 +123,12 @@ "stability": "experimental", "jsii": { "outdir": "dist", - "targets": {}, + "targets": { + "python": { + "distName": "pharindoko.cdk-internal-gateway", + "module": "pharindoko.cdk_internal_gateway" + } + }, "tsc": { "outDir": "lib", "rootDir": "src"