diff --git a/src/index.ts b/src/index.ts index ac7c51b2..e43abb9b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -351,29 +351,32 @@ export class CdktfProviderProject extends cdk.JsiiProject { deprecationDate, isDeprecated: !!isDeprecated, }); - const upgradeScript = new CheckForUpgradesScriptFile(this, { - providerVersion, - fqproviderName, - }); - new ProviderUpgrade(this, { - checkForUpgradesScriptPath: upgradeScript.path, - workflowRunsOn, - nodeHeapSize: maxOldSpaceSize, - }); new CustomizedLicense(this, options.creationYear); new GithubIssues(this, { providerName }); new AutoApprove(this); new AutoCloseCommunityIssues(this, { providerName }); new Automerge(this); new LockIssues(this); - new AlertOpenPrs(this, { - slackWebhookUrl: "${{ secrets.ALERT_PRS_SLACK_WEBHOOK_URL }}", - repository, - }); - new ForceRelease(this, { - workflowRunsOn, - repositoryUrl, + + const upgradeScript = new CheckForUpgradesScriptFile(this, { + providerVersion, + fqproviderName, }); + if (!isDeprecated) { + new ProviderUpgrade(this, { + checkForUpgradesScriptPath: upgradeScript.path, + workflowRunsOn, + nodeHeapSize: maxOldSpaceSize, + }); + new AlertOpenPrs(this, { + slackWebhookUrl: "${{ secrets.ALERT_PRS_SLACK_WEBHOOK_URL }}", + repository, + }); + new ForceRelease(this, { + workflowRunsOn, + repositoryUrl, + }); + } new TextFile(this, ".github/CODEOWNERS", { lines: [ diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index fbed6481..00c8129d 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -34,16 +34,12 @@ project { /.github/CODEOWNERS linguist-generated /.github/ISSUE_TEMPLATE/config.yml linguist-generated /.github/pull_request_template.md linguist-generated -/.github/workflows/alert-open-prs.yml linguist-generated /.github/workflows/auto-approve.yml linguist-generated /.github/workflows/auto-close-community-issues.yml linguist-generated /.github/workflows/auto-close-community-prs.yml linguist-generated /.github/workflows/automerge.yml linguist-generated /.github/workflows/build.yml linguist-generated -/.github/workflows/force-release.yml linguist-generated /.github/workflows/lock.yml linguist-generated -/.github/workflows/next-cdktf-version-pr.yml linguist-generated -/.github/workflows/provider-upgrade.yml linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated /.github/workflows/release.yml linguist-generated /.github/workflows/stale.yml linguist-generated @@ -75,39 +71,6 @@ contact_links: about: Please file issues with pre-built providers in our main repository. ", ".github/pull_request_template.md": "Fixes #", - ".github/workflows/alert-open-prs.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". - -name: alert-open-prs -on: - workflow_dispatch: {} - schedule: - - cron: "* */12 * * 1-5" -jobs: - check-open-prs: - runs-on: ubuntu-latest - permissions: - pull-requests: read - env: {} - steps: - - name: Find old PRs - id: old_prs - env: - GH_TOKEN: \${{ github.token }} - run: |- - PR_LINKS=$(gh pr list --state open --repo="cdktf/cdktf-provider-random" --search "created:<$(date -d '-2hours' +%FT%TZ)" --json url --jq "map(.url)" ) - if [ "$PR_LINKS" == "[]" ]; then - echo "No PRs open for more than 2 hour(s)" - else - echo "pr_links=$PR_LINKS" >> $GITHUB_OUTPUT - fi - - name: Alert Slack on old PRs - if: \${{ steps.old_prs.outputs.pr_links }} - uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 - env: - SLACK_WEBHOOK_URL: \${{ secrets.ALERT_PRS_SLACK_WEBHOOK_URL }} - with: - payload: "{\\"pr_links\\":\\"\${{ join(fromJSON(steps.old_prs.outputs.pr_links), ', ') }}\\"}" -", ".github/workflows/auto-approve.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". name: auto-approve @@ -448,104 +411,6 @@ jobs: run: cd .repo && npx projen package:go - name: Collect go Artifact run: mv .repo/dist dist -", - ".github/workflows/force-release.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". - -name: force-release -on: - workflow_dispatch: - inputs: - sha: - name: sha - type: string - required: true - description: The sha of the commit to release - publish_to_go: - name: publish_to_go - type: boolean - required: true - description: Whether to publish to Go Repository -jobs: - force-release: - runs-on: ubuntu-latest - permissions: - contents: write - env: - CI: "true" - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - with: - ref: \${{ inputs.sha }} - fetch-depth: 0 - - name: Set git config safe.directory - run: git config --global --add safe.directory $(pwd) - - name: Set git identity - run: |- - git config user.name "github-actions" - git config user.email "github-actions@github.com" - - name: Setup Node.js - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 - with: {} - - name: Install dependencies - run: yarn install --check-files --frozen-lockfile - - name: build - run: npx projen build - - name: Backup artifact permissions - run: cd dist && getfacl -R . > permissions-backup.acl - continue-on-error: true - - name: Upload artifact - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - name: build-artifact - path: dist - force_release_golang: - name: Publish to Github Go Repository - needs: force-release - runs-on: ubuntu-latest - permissions: - contents: read - env: - CI: "true" - steps: - - name: Setup Node.js - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 - with: {} - - name: Setup Go - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe - with: - go-version: ^1.16.0 - - name: Download build artifacts - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a - 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 Artifact - run: cd .repo && npx projen package:go - - name: Setup Copywrite tool - uses: hashicorp/setup-copywrite@867a1a2a064a0626db322392806428f7dc59cb3e - - name: Copy copywrite hcl file - run: cp .repo/.copywrite.hcl .repo/dist/go/.copywrite.hcl - - name: Add headers using Copywrite tool - run: cd .repo/dist/go && copywrite headers - - name: Remove copywrite hcl file - run: rm -f .repo/dist/go/.copywrite.hcl - - name: Collect go Artifact - run: mv .repo/dist dist - - name: Release - if: \${{ inputs.publish_to_go }} - env: - GIT_USER_NAME: CDK for Terraform Team - GIT_USER_EMAIL: github-team-tf-cdk@hashicorp.com - GITHUB_TOKEN: \${{ secrets.GO_GITHUB_TOKEN }} - run: npx -p publib@latest publib-golang ", ".github/workflows/lock.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". @@ -560,133 +425,12 @@ jobs: pull-requests: write issues: write steps: - - uses: dessant/lock-threads@d42e5f49803f3c4e14ffee0378e31481265dda22 + - uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 with: issue-comment: I'm going to lock this issue because it has been closed for at least 7 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please [open a new issue](https://github.com/cdktf/cdktf-provider-project/issues/new) so we can investigate further. issue-inactive-days: 7 pr-comment: I'm going to lock this pull request because it has been closed for at least 7 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please [open a new issue](https://github.com/cdktf/cdktf-provider-project/issues/new) so we can investigate further. pr-inactive-days: 7 -", - ".github/workflows/next-cdktf-version-pr.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". - -name: next-cdktf-version-pr -on: - workflow_dispatch: {} -jobs: - pr-against-next: - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - env: - CI: "true" - CHECKPOINT_DISABLE: "1" - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - with: - ref: \${{ github.event.pull_request.head.ref }} - repository: \${{ github.event.pull_request.head.repo.full_name }} - - name: Remove old PR - env: - GH_TOKEN: \${{ secrets.GITHUB_TOKEN }} - run: |- - PR_NUMBER_TO_CLOSE=$(gh pr list | grep "cdktf-next-pr" | awk '{ print $1 }') - if [ -z "$PR_NUMBER_TO_CLOSE" ]; then - echo "No PR to close" - else - gh pr close $PR_NUMBER_TO_CLOSE - fi - - name: Install - run: yarn install - - name: Upgrade CDKTF - run: |- - CDKTF_VERSION=$(yarn info cdktf --json | jq -r '.data | .["dist-tags"] | .next') - sed -i "s/cdktfVersion: ".*",/cdktfVersion: \\"$CDKTF_VERSION\\",/" .projenrc.js - cat .projenrc.js - - name: Run projen - run: yarn run upgrade - - name: Regenerate bindings - run: yarn run fetch && yarn run compile && yarn run docgen - - name: Create PR - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 - with: - token: \${{ secrets.GITHUB_TOKEN }} - branch: cdktf-next-pr - branch-suffix: random - commit-message: "chore: upgrade CDKTF to @next preview version" - title: "chore: preview upgrading CDKTF to @next version" - delete-branch: true - draft: true - body: DO NOT MERGE! This is an automated PR that tests the pre-built provider generation against preview builds of CDKTF -", - ".github/workflows/provider-upgrade.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". - -name: provider-upgrade -on: - schedule: - - cron: 0 3 * * * - workflow_dispatch: {} -jobs: - upgrade: - runs-on: ubuntu-latest - permissions: - pull-requests: write - issues: write - contents: write - statuses: write - env: - NODE_OPTIONS: --max-old-space-size=6656 - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - run: yarn install - - id: check_version - run: yarn check-if-new-provider-version - - name: get provider current version - id: current_version - if: \${{ steps.check_version.outputs.new_version == 'available' }} - run: echo "value=$(jq -r '.cdktf.provider.version' package.json)" >> $GITHUB_OUTPUT - - if: \${{ steps.check_version.outputs.new_version == 'available' }} - env: - CHECKPOINT_DISABLE: "1" - GH_TOKEN: \${{ secrets.GITHUB_TOKEN }} - run: yarn fetch - - name: get provider updated version - id: new_version - if: \${{ steps.check_version.outputs.new_version == 'available' }} - run: echo "value=$(jq -r '. | to_entries[] | .value' src/version.json)" >> $GITHUB_OUTPUT - - name: Determine if this is a minor or patch release - id: release - if: \${{ steps.check_version.outputs.new_version == 'available' }} - env: - CURRENT_VERSION: \${{ steps.current_version.outputs.value }} - NEW_VERSION: \${{ steps.new_version.outputs.value }} - run: |- - CURRENT_VERSION_MINOR=$(cut -d "." -f 2 <<< "$CURRENT_VERSION") - NEW_VERSION_MINOR=$(cut -d "." -f 2 <<< "$NEW_VERSION") - [[ "$CURRENT_VERSION_MINOR" != "$NEW_VERSION_MINOR" ]] && IS_MINOR_RELEASE=true || IS_MINOR_RELEASE=false - [[ "$IS_MINOR_RELEASE" == "true" ]] && SEMANTIC_TYPE=feat || SEMANTIC_TYPE=fix - echo "is_minor=$IS_MINOR_RELEASE" >> $GITHUB_OUTPUT - echo "type=$SEMANTIC_TYPE" >> $GITHUB_OUTPUT - - if: \${{ steps.check_version.outputs.new_version == 'available' }} - run: yarn compile - - if: \${{ steps.check_version.outputs.new_version == 'available' }} - run: yarn docgen - - name: Create Pull Request - if: \${{ steps.check_version.outputs.new_version == 'available' }} - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 - with: - branch: auto/provider-upgrade - commit-message: "\${{ steps.release.outputs.type }}: upgrade provider from \`\${{ steps.current_version.outputs.value }}\` to version \`\${{ steps.new_version.outputs.value }}\`" - title: "\${{ steps.release.outputs.type }}: upgrade provider from \`\${{ steps.current_version.outputs.value }}\` to version \`\${{ steps.new_version.outputs.value }}\`" - body: This PR upgrades the underlying Terraform provider to version \${{ steps.new_version.outputs.value }} - labels: automerge,auto-approve - token: \${{ secrets.GH_TOKEN }} - delete-branch: true - committer: team-tf-cdk - author: Team Terraform CDK - signoff: true ", ".github/workflows/pull-request-lint.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". @@ -1283,8 +1027,6 @@ tsconfig.json package-lock.json !/cdktf.json !/README.md -!/scripts/check-for-upgrades.js -!/.github/workflows/provider-upgrade.yml !/LICENSE !/.github/ISSUE_TEMPLATE/config.yml !/.github/workflows/auto-approve.yml @@ -1292,9 +1034,7 @@ package-lock.json !/.github/workflows/auto-close-community-prs.yml !/.github/workflows/automerge.yml !/.github/workflows/lock.yml -!/.github/workflows/next-cdktf-version-pr.yml -!/.github/workflows/alert-open-prs.yml -!/.github/workflows/force-release.yml +!/scripts/check-for-upgrades.js !/.github/CODEOWNERS !/scripts/should-release.js API.md @@ -1328,7 +1068,6 @@ docs scripts .projenrc.js .copywrite.hcl -.mergify.yml ", ".projen/deps.json": "{ "dependencies": [ @@ -1382,7 +1121,7 @@ scripts }, { "name": "jsii-rosetta", - "version": "~5.1.2", + "version": "~5.2.0", "type": "build" }, { @@ -1394,6 +1133,11 @@ scripts "name": "projen", "type": "build" }, + { + "name": "semver", + "version": "^7.5.3", + "type": "build" + }, { "name": "standard-version", "version": "^9", @@ -1439,16 +1183,12 @@ scripts ".github/CODEOWNERS", ".github/ISSUE_TEMPLATE/config.yml", ".github/pull_request_template.md", - ".github/workflows/alert-open-prs.yml", ".github/workflows/auto-approve.yml", ".github/workflows/auto-close-community-issues.yml", ".github/workflows/auto-close-community-prs.yml", ".github/workflows/automerge.yml", ".github/workflows/build.yml", - ".github/workflows/force-release.yml", ".github/workflows/lock.yml", - ".github/workflows/next-cdktf-version-pr.yml", - ".github/workflows/provider-upgrade.yml", ".github/workflows/pull-request-lint.yml", ".github/workflows/release.yml", ".github/workflows/stale.yml", @@ -1510,14 +1250,6 @@ scripts ], "condition": "! git log --oneline -1 | grep -q \\"chore(release):\\"" }, - "check-if-new-provider-version": { - "name": "check-if-new-provider-version", - "steps": [ - { - "exec": "node ./scripts/check-for-upgrades.js" - } - ] - }, "clobber": { "name": "clobber", "description": "hard resets to HEAD of origin and cleans the local repo", @@ -1802,13 +1534,13 @@ scripts }, "steps": [ { - "exec": "npx npm-check-updates@16 --upgrade --target=minor --peer --dep=dev,peer,prod,optional --filter=@actions/core,@cdktf/provider-project,@types/node,dot-prop,jsii-diff,jsii-docgen,jsii-pacmak,projen,standard-version,typescript" + "exec": "npx npm-check-updates@16 --upgrade --target=minor --peer --dep=dev,peer,prod,optional --filter=@actions/core,@cdktf/provider-project,@types/node,dot-prop,jsii-diff,jsii-docgen,jsii-pacmak,projen,semver,standard-version,typescript" }, { "exec": "yarn install --check-files" }, { - "exec": "yarn upgrade @actions/core @cdktf/provider-project @types/node dot-prop jsii-diff jsii-docgen jsii-pacmak projen standard-version typescript" + "exec": "yarn upgrade @actions/core @cdktf/provider-project @types/node dot-prop jsii-diff jsii-docgen jsii-pacmak projen semver standard-version typescript" }, { "exec": "npx projen" @@ -2273,7 +2005,6 @@ You can also visit a hosted version of the documentation on [constructs.dev](htt "scripts": { "build": "npx projen build", "bump": "npx projen bump", - "check-if-new-provider-version": "npx projen check-if-new-provider-version", "clobber": "npx projen clobber", "compat": "npx projen compat", "compile": "jsii --silence-warnings=reserved-word", @@ -2320,8 +2051,9 @@ You can also visit a hosted version of the documentation on [constructs.dev](htt "jsii-diff": "*", "jsii-docgen": "^10.2.3", "jsii-pacmak": "*", - "jsii-rosetta": "~5.1.2", + "jsii-rosetta": "~5.2.0", "projen": "*", + "semver": "^7.5.3", "standard-version": "^9", "typescript": "*" }, @@ -3924,8 +3656,6 @@ tsconfig.json package-lock.json !/cdktf.json !/README.md -!/scripts/check-for-upgrades.js -!/.github/workflows/provider-upgrade.yml !/LICENSE !/.github/ISSUE_TEMPLATE/config.yml !/.github/workflows/auto-approve.yml @@ -3933,6 +3663,8 @@ package-lock.json !/.github/workflows/auto-close-community-prs.yml !/.github/workflows/automerge.yml !/.github/workflows/lock.yml +!/scripts/check-for-upgrades.js +!/.github/workflows/provider-upgrade.yml !/.github/workflows/alert-open-prs.yml !/.github/workflows/force-release.yml !/.github/CODEOWNERS @@ -6650,8 +6382,6 @@ tsconfig.json package-lock.json !/cdktf.json !/README.md -!/scripts/check-for-upgrades.js -!/.github/workflows/provider-upgrade.yml !/LICENSE !/.github/ISSUE_TEMPLATE/config.yml !/.github/workflows/auto-approve.yml @@ -6659,6 +6389,8 @@ package-lock.json !/.github/workflows/auto-close-community-prs.yml !/.github/workflows/automerge.yml !/.github/workflows/lock.yml +!/scripts/check-for-upgrades.js +!/.github/workflows/provider-upgrade.yml !/.github/workflows/alert-open-prs.yml !/.github/workflows/force-release.yml !/.github/CODEOWNERS @@ -9325,8 +9057,6 @@ tsconfig.json package-lock.json !/cdktf.json !/README.md -!/scripts/check-for-upgrades.js -!/.github/workflows/provider-upgrade.yml !/LICENSE !/.github/ISSUE_TEMPLATE/config.yml !/.github/workflows/auto-approve.yml @@ -9334,6 +9064,8 @@ package-lock.json !/.github/workflows/auto-close-community-prs.yml !/.github/workflows/automerge.yml !/.github/workflows/lock.yml +!/scripts/check-for-upgrades.js +!/.github/workflows/provider-upgrade.yml !/.github/workflows/alert-open-prs.yml !/.github/workflows/force-release.yml !/.github/CODEOWNERS