diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6100381..9e299f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -120,3 +120,40 @@ 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: + contents: read + if: ${{ !needs.build.outputs.self_mutation_happened }} + steps: + - uses: actions/setup-node@v4 + with: + node-version: 22.4.x + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifact + path: dist + - name: Restore build artifact permissions + run: cd dist && setfacl --restore=permissions-backup.acl + continue-on-error: true + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + path: .repo + - name: Install Dependencies + run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Extract build artifact + run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo + - name: Move build artifact out of the way + run: mv dist dist.old + - 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 ab015dc..38672a3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,6 +63,7 @@ jobs: needs: - release - release_npm + - release_pypi runs-on: ubuntu-latest permissions: contents: write @@ -126,3 +127,44 @@ jobs: NPM_CONFIG_PROVENANCE: "true" 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.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha + steps: + - uses: actions/setup-node@v4 + with: + node-version: 22.4.x + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifact + path: dist + - name: Restore build artifact permissions + run: cd dist && setfacl --restore=permissions-backup.acl + continue-on-error: true + - name: Checkout + uses: actions/checkout@v4 + with: + path: .repo + - name: Install Dependencies + run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Extract build artifact + run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo + - name: Move build artifact out of the way + run: mv dist dist.old + - 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 e8c3ed2..7d902e8 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 merge_method: squash commit_message_template: |- {{ title }} (#{{ number }}) @@ -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 78317de..22f57bc 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -170,6 +170,9 @@ "steps": [ { "spawn": "package:js" + }, + { + "spawn": "package:python" } ] }, @@ -182,6 +185,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 96bd8d6..f94b601 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -23,5 +23,9 @@ const project = new awscdk.AwsCdkConstructLibrary({ secret: 'GITHUB_TOKEN', allowedUsernames: ['yicr'], }, + publishToPypi: { + distName: 'gammarers.aws-codeconnections-host-custom-resource', + module: 'gammarers.aws_codeconnections_host_custom_resource', + }, }); project.synth(); \ No newline at end of file diff --git a/README.md b/README.md index 3f88104..0eb7016 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,14 @@ npm install @gammarers/aws-codeconnections-host-custom-resource yarn add @gammarers/aws-codeconnections-host-custom-resource ``` +### Python + +#### install by pip + +```shell +pip install gammarers.aws-budgets-notification +``` + ## Example ```typescript diff --git a/package.json b/package.json index 5e04314..48537fc 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,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", @@ -121,7 +122,12 @@ "stability": "stable", "jsii": { "outdir": "dist", - "targets": {}, + "targets": { + "python": { + "distName": "gammarers.aws-codeconnections-host-custom-resource", + "module": "gammarers.aws_codeconnections_host_custom_resource" + } + }, "tsc": { "outDir": "lib", "rootDir": "src"