diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad61be5a..d3a7080a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -113,3 +113,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 3e06a8b6..453c1eeb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -113,3 +113,39 @@ jobs: NPM_REGISTRY: npm.pkg.github.com NPM_TOKEN: ${{ secrets.GITHUB_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_REPOSITORY_URL: ${{ secrets.TWINE_REGISTRY_URL }} + 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 154b39fa..299617cc 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/.npmignore b/.npmignore index 17232a26..2dea3ac6 100644 --- a/.npmignore +++ b/.npmignore @@ -22,4 +22,17 @@ dist tsconfig.tsbuildinfo /.eslintrc.json !.jsii -/use-cases/ +/docs/ +header.js +.eslintrc.json +.gitattributes +.github +.gitignore +.mergify.yml +.node-version +.npmignore +.projen +.projenrc.ts +projenrc +tsconfig.dev.json +yarn.lock diff --git a/.projen/tasks.json b/.projen/tasks.json index df3372cd..99568f07 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -154,6 +154,9 @@ "steps": [ { "spawn": "package:js" + }, + { + "spawn": "package:python" } ] }, @@ -166,6 +169,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 70e6ef4b..c5ad760b 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -46,6 +46,12 @@ const project = new awscdk.AwsCdkConstructLibrary({ npmRegistryUrl: 'https://npm.pkg.github.com', npmTokenSecret: 'GITHUB_TOKEN', + publishToPypi: { + distName: PROJECT_NAME, + module: PROJECT_NAME.replace(/-/g, '_'), // PEP 8, convert hypens + twineRegistryUrl: '${{ secrets.TWINE_REGISTRY_URL }}', + }, + codeCov: true, codeCovTokenSecret: 'CODECOV_TOKEN', @@ -73,8 +79,24 @@ buildMonthlyIssuesMetricsWorkflow(project); buildUpdateContributorsWorkflow(project); buildAutoApproveWorkflow(project); -// We don't want to package the use cases -project.npmignore?.addPatterns('/use-cases/'); +// We don't want to package certain things +project.npmignore?.addPatterns( + '/docs/', + 'header.js', + '.gitattributes', + '.eslintrc.json', + '.gitattributes', + '.github', + '.gitignore', + '.mergify.yml', + '.node-version', + '.npmignore', + '.projen', + '.projenrc.ts', + 'projenrc', + 'tsconfig.dev.json', + 'yarn.lock', +); // Add License header automatically project.eslint?.addPlugins('header'); diff --git a/README.md b/README.md index 46c0db5d..1f1a9703 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ # Amazon Emerging Tech CDK Constructs - - ---- - ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge) > All classes are under active development and subject to non-backward compatible changes or removal in any @@ -11,7 +7,6 @@ > This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package. --- - ## Table of contents diff --git a/package.json b/package.json index 07f8e032..84ad58ff 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,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": "experimental", "jsii": { "outdir": "dist", - "targets": {}, + "targets": { + "python": { + "distName": "emerging-tech-cdk-constructs", + "module": "emerging_tech_cdk_constructs" + } + }, "tsc": { "outDir": "lib", "rootDir": "src"