diff --git a/.eslintrc.json b/.eslintrc.json index 358270a9..af1765b5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -40,9 +40,6 @@ "coverage" ], "rules": { - "@typescript-eslint/no-require-imports": [ - "error" - ], "indent": [ "off" ], @@ -120,6 +117,28 @@ "@typescript-eslint/member-delimiter-style": [ "error" ], + "semi": [ + "error", + "always" + ], + "max-len": [ + "error", + { + "code": 150, + "ignoreUrls": true, + "ignoreStrings": true, + "ignoreTemplateLiterals": true, + "ignoreComments": true, + "ignoreRegExpLiterals": true + } + ], + "quote-props": [ + "error", + "consistent-as-needed" + ], + "@typescript-eslint/no-require-imports": [ + "error" + ], "import/no-extraneous-dependencies": [ "error", { @@ -159,28 +178,9 @@ "key-spacing": [ "error" ], - "semi": [ - "error", - "always" - ], - "quote-props": [ - "error", - "consistent-as-needed" - ], "no-multiple-empty-lines": [ "error" ], - "max-len": [ - "error", - { - "code": 150, - "ignoreUrls": true, - "ignoreStrings": true, - "ignoreTemplateLiterals": true, - "ignoreComments": true, - "ignoreRegExpLiterals": true - } - ], "@typescript-eslint/no-floating-promises": [ "error" ], diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..bf5dc5b7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,20 @@ +# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". + +*.snap linguist-generated +/.eslintrc.json linguist-generated +/.gitattributes linguist-generated +/.github/dependabot.yml linguist-generated +/.github/pull_request_template.md linguist-generated +/.github/workflows/build.yml linguist-generated +/.github/workflows/projenupgrade.yml linguist-generated +/.github/workflows/release.yml linguist-generated +/.mergify.yml linguist-generated +/.npmignore linguist-generated +/.projen/ linguist-generated +/.versionrc.json linguist-generated +/LICENSE linguist-generated +/package.json linguist-generated +/tsconfig.eslint.json linguist-generated +/tsconfig.jest.json linguist-generated +/tsconfig.json linguist-generated +/yarn.lock linguist-generated \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 69ccc0da..7ecf23b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,14 +17,23 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} - name: Install dependencies run: yarn install --check-files --frozen-lockfile - - name: Synthesize project files - run: npx projen - name: Set git identity run: |- - git config user.name "Auto-bump" + git config user.name "Automation" git config user.email "github-actions@github.com" - name: Build run: npx projen build - - name: Commit and push changes (if any) - run: 'git diff --exit-code || (git commit -am "chore: self mutation" && git push - origin HEAD:${{ github.event.pull_request.head.ref }})' + - name: Check for changes + id: git_diff + run: git diff --exit-code || echo "::set-output name=has_changes::true" + - if: steps.git_diff.outputs.has_changes + name: Commit and push changes (if changed) + run: 'git add . && git commit -m "chore: self mutation" && git push origin + HEAD:${{ github.event.pull_request.head.ref }}' + - if: steps.git_diff.outputs.has_changes + name: Update status check (if changed) + run: gh api -X POST /repos/${{ github.event.pull_request.head.repo.full_name + }}/check-runs -F name="build" -F head_sha="$(git rev-parse HEAD)" -F + status="completed" -F conclusion="success" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/projenupgrade.yml b/.github/workflows/projenupgrade.yml new file mode 100644 index 00000000..7e8ba8d7 --- /dev/null +++ b/.github/workflows/projenupgrade.yml @@ -0,0 +1,26 @@ +# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". + +name: ProjenUpgrade +on: + schedule: + - cron: 0 6 * * * + workflow_dispatch: {} +jobs: + upgrade: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install dependencies + run: yarn install --check-files --frozen-lockfile + - name: Upgrade projen + run: npx projen projen:upgrade + - name: Create pull request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.PROJEN_GITHUB_TOKEN }} + commit-message: "chore: upgrade projen" + branch: auto/projen-upgrade + title: "chore: upgrade projen" + body: This PR upgrades projen to the latest version + labels: auto-merge diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49bd3e50..fa10b04c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,10 +7,11 @@ on: - master workflow_dispatch: {} jobs: - build: + release: runs-on: ubuntu-latest env: CI: "true" + RELEASE: "true" steps: - name: Checkout uses: actions/checkout@v2 @@ -18,32 +19,39 @@ jobs: fetch-depth: 0 - name: Install dependencies run: yarn install --check-files --frozen-lockfile - - name: Synthesize project files - run: npx projen - name: Anti-tamper check - run: git diff --exit-code + run: git diff --ignore-space-at-eol --exit-code - name: Set git identity run: |- - git config user.name "Auto-bump" + git config user.name "Automation" git config user.email "github-actions@github.com" - name: Bump to next version run: npx projen bump - name: Build run: npx projen build - - name: Anti-tamper check - run: git diff --exit-code - - name: Push commits - run: git push origin HEAD:${{ github.ref }} - - name: Push tags - run: git push --follow-tags origin ${{ github.ref }} + - name: Check for new commits + id: git_remote + run: echo ::set-output name=latest_commit::"$(git ls-remote origin -h ${{ + github.ref }} | cut -f1)" + - name: Create release + if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} + run: gh release create v$(node -p "require('./package.json').version") -F + .changelog.tmp.md -t v$(node -p "require('./package.json').version") + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Unbump + run: npx projen unbump - name: Upload artifact + if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} uses: actions/upload-artifact@v2.1.1 with: name: dist path: dist + - name: Anti-tamper check + run: git diff --ignore-space-at-eol --exit-code release_npm: name: Release to NPM - needs: build + needs: release runs-on: ubuntu-latest container: image: jsii/superchain diff --git a/.gitignore b/.gitignore index 47f7217b..2c6d3e73 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ .eslintcache .nyc_output .yarn-integrity +/.changelog.tmp.md +/.version.tmp.json /coverage /dist /lib @@ -28,9 +30,11 @@ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json yarn-debug.log* yarn-error.log* !/.eslintrc.json +!/.gitattributes !/.github/dependabot.yml !/.github/pull_request_template.md !/.github/workflows/build.yml +!/.github/workflows/projenupgrade.yml !/.github/workflows/release.yml !/.mergify.yml !/.npmignore @@ -45,4 +49,3 @@ yarn-error.log* !/tsconfig.eslint.json !/tsconfig.jest.json !/tsconfig.json -!version.json diff --git a/.npmignore b/.npmignore index ef41ed30..d90c7c46 100644 --- a/.npmignore +++ b/.npmignore @@ -5,7 +5,6 @@ /.mergify.yml /.projen /.projenrc.js -/.versionrc.json /.vscode /coverage /src @@ -16,6 +15,7 @@ /tsconfig.json dist junit.xml +tsconfig.tsbuildinfo !/lib !/lib/**/*.d.ts !/lib/**/*.js diff --git a/.projen/deps.json b/.projen/deps.json index 6f047b19..ecf7933d 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -48,7 +48,7 @@ }, { "name": "projen", - "version": "^0.17.16", + "version": "^0.17.88", "type": "build" }, { diff --git a/.projen/tasks.json b/.projen/tasks.json index e6d9113e..c19be558 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -33,6 +33,33 @@ ], "condition": "git diff --exit-code > /dev/null" }, + "bump": { + "name": "bump", + "category": "20.release", + "description": "Bumps version based on latest git tag and generates a changelog entry", + "steps": [ + { + "exec": "git -c \"versionsort.suffix=-\" tag --sort=\"-version:refname\" --list \"v*\" | head -n1 > .version.tmp.json" + }, + { + "exec": "if [ \"$(cat .version.tmp.json)\" == \"\" ]; then echo \"v0.1.0\" > .version.tmp.json; fi" + }, + { + "exec": "standard-version" + } + ], + "condition": "! git log --oneline -1 | grep -q \"chore(release):\"" + }, + "unbump": { + "name": "unbump", + "category": "20.release", + "description": "Restores version to 0.0.0", + "steps": [ + { + "exec": "standard-version -r 0.0.0" + } + ] + }, "compile": { "name": "compile", "category": "00.build", @@ -77,6 +104,9 @@ "category": "00.build", "description": "Full release build (test+compile)", "steps": [ + { + "exec": "npx projen" + }, { "spawn": "test" }, @@ -97,31 +127,6 @@ } ] }, - "bump": { - "name": "bump", - "category": "20.release", - "description": "Commits a bump to the package version based on conventional commits", - "steps": [ - { - "exec": "standard-version" - } - ], - "condition": "! git log --oneline -1 | grep -q \"chore(release):\"" - }, - "release": { - "name": "release", - "category": "20.release", - "description": "Bumps version & push to master", - "steps": [ - { - "spawn": "bump" - }, - { - "exec": "git push --follow-tags origin master" - } - ], - "condition": "! git log --oneline -1 | grep -q \"chore(release):\"" - }, "test:watch": { "name": "test:watch", "category": "10.test", @@ -155,6 +160,14 @@ } ] }, + "default": { + "name": "default", + "steps": [ + { + "exec": "node .projenrc.js" + } + ] + }, "watch": { "name": "watch", "category": "00.build", diff --git a/.projenrc.js b/.projenrc.js index 4fec11a8..d605c885 100644 --- a/.projenrc.js +++ b/.projenrc.js @@ -11,6 +11,7 @@ const project = new TypeScriptProject({ authorOrganization: true, authorUrl: 'https://aws.amazon.com', homepage: 'https://github.com/aws/jsii-release', + projenUpgradeSecret: 'PROJEN_GITHUB_TOKEN', }); // create tarball and move to dist/js so release workflow can pick it up from there. diff --git a/.versionrc.json b/.versionrc.json index 41c43f8c..5bbe5c70 100644 --- a/.versionrc.json +++ b/.versionrc.json @@ -1,18 +1,19 @@ { "packageFiles": [ { - "filename": "version.json", - "type": "json" + "filename": ".version.tmp.json", + "type": "plain-text" } ], "bumpFiles": [ - { - "filename": "version.json", - "type": "json" - } + "package.json" ], - "commitAll": true, - "scripts": { - "postbump": "npx projen && git add ." - } + "commitAll": false, + "infile": ".changelog.tmp.md", + "header": "", + "skip": { + "commit": true, + "tag": true + }, + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." } diff --git a/package.json b/package.json index 70be57f1..7581c9e1 100644 --- a/package.json +++ b/package.json @@ -14,21 +14,22 @@ "jsii-release-pypi": "bin/jsii-release-pypi" }, "scripts": { - "projen": "npx projen", - "start": "npx projen start", "clobber": "npx projen clobber", + "bump": "npx projen bump", + "unbump": "npx projen unbump", "compile": "npx projen compile", "test:compile": "npx projen test:compile", "test": "npx projen test", "build": "npx projen build", - "bump": "npx projen bump", - "release": "npx projen release", "test:watch": "npx projen test:watch", "test:update": "npx projen test:update", "projen:upgrade": "npx projen projen:upgrade", + "default": "npx projen default", "watch": "npx projen watch", "package": "npx projen package", - "eslint": "npx projen eslint" + "eslint": "npx projen eslint", + "projen": "npx projen", + "start": "npx projen start" }, "author": { "name": "Amazon Web Services", @@ -47,7 +48,7 @@ "jest": "^26.6.3", "jest-junit": "^12", "json-schema": "^0.3.0", - "projen": "^0.17.16", + "projen": "^0.17.88", "standard-version": "^9", "ts-jest": "^26.5.0", "typescript": "^3.9.5" @@ -63,8 +64,8 @@ ], "main": "lib/index.js", "license": "Apache-2.0", - "version": "0.2.33", "homepage": "https://github.com/aws/jsii-release", + "version": "0.0.0", "jest": { "testMatch": [ "**/__tests__/**/*.ts?(x)", diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index a22596ab..06833d13 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -30,5 +30,6 @@ ], "exclude": [ "node_modules" - ] + ], + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." } diff --git a/tsconfig.jest.json b/tsconfig.jest.json index a22596ab..06833d13 100644 --- a/tsconfig.jest.json +++ b/tsconfig.jest.json @@ -30,5 +30,6 @@ ], "exclude": [ "node_modules" - ] + ], + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." } diff --git a/tsconfig.json b/tsconfig.json index 06b4c6f6..338d5318 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,5 +31,6 @@ "exclude": [ "node_modules", "lib" - ] + ], + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"npx projen\"." } diff --git a/yarn.lock b/yarn.lock index b781588c..4689f212 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2685,6 +2685,11 @@ ini@^1.3.2: resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== +ini@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ini/-/ini-2.0.0.tgz#e5fd556ecdd5726be978fa1001862eacb0a94bc5" + integrity sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA== + inquirer@^7.3.3: version "7.3.3" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003" @@ -4373,16 +4378,17 @@ progress@^2.0.0: resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== -projen@^0.17.16: - version "0.17.16" - resolved "https://registry.yarnpkg.com/projen/-/projen-0.17.16.tgz#40d109f74bf82280ee1dbc836635d199d80e2fd6" - integrity sha512-WPTvT7uK3mBrHt5CemkS791/3++OzyIcaTB2vPUt/6KViULkjpRIYYNknTXBp7hGJHKPn6NJ05/eRNATjiaiiw== +projen@^0.17.88: + version "0.17.88" + resolved "https://registry.yarnpkg.com/projen/-/projen-0.17.88.tgz#1dd28133f643401e189b2fe05fa59b1462c3a0c0" + integrity sha512-VmzWGHtB/bdll0muOOvMp/SQ5BIjbI+oA4rDj2Og227wAepjUERA7EiKptUoMOIHD1dJo7WPNcS/eKznq1UmpQ== dependencies: "@iarna/toml" "^2.2.5" chalk "^4.1.0" decamelize "^4.0.0" fs-extra "^9.0.1" glob "^7" + ini "^2.0.0" inquirer "^7.3.3" semver "^7.3.2" xmlbuilder2 "^2.4.0"