From 064c4b97588b78ea2c2f437c6924fde7121d9de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20M=C3=A1rquez=20P=C3=A9rez?= Date: Thu, 9 Nov 2023 20:06:57 +0100 Subject: [PATCH] feat(codestarconnection): add python deployment of the package we have added a new deployment package for python --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 35 +++++++++++++++++++++++++++++++++++ .mergify.yml | 2 ++ .projen/tasks.json | 12 ++++++++++++ .projenrc.ts | 4 ++++ package.json | 8 +++++++- 6 files changed, 88 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c4d39d2..b1c5717 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -108,3 +108,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: 18.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 3866ce2..581ad62 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -107,3 +107,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: 18.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 154b39f..299617c 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -8,6 +8,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: @@ -24,3 +25,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 d3a6c90..6d3a268 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -179,6 +179,9 @@ "steps": [ { "spawn": "package:js" + }, + { + "spawn": "package:python" } ] }, @@ -191,6 +194,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/.projenrc.ts b/.projenrc.ts index 7beb32f..140a710 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -14,6 +14,10 @@ const project = new awscdk.AwsCdkConstructLibrary({ repositoryUrl: 'https://github.com/JumpToTheCloud/aws-codestarconnection', prettier: true, keywords: ['aws', 'cdk', 'codestarconnection'], + publishToPypi: { + distName: 'aws-codestarconnection', + module: 'aws_codestarconnection', + }, prettierOptions: { settings: { trailingComma: TrailingComma.ES5, diff --git a/package.json b/package.json index f2dfe2b..dbd1a84 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,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", @@ -124,7 +125,12 @@ "stability": "stable", "jsii": { "outdir": "dist", - "targets": {}, + "targets": { + "python": { + "distName": "aws-codestarconnection", + "module": "aws_codestarconnection" + } + }, "tsc": { "outDir": "lib", "rootDir": "src"