From a314507ce853c406a9ae729b2958e7744b188082 Mon Sep 17 00:00:00 2001 From: javacs3 Date: Wed, 8 Dec 2021 11:28:35 +0800 Subject: [PATCH] chore!: eforce v1-main branch for v1 version and main for v2 version --- .gitattributes | 2 + .github/workflows/release-main.yml | 132 ++++++++++++++++++++++++++ .github/workflows/release.yml | 6 +- .github/workflows/upgrade-v1-main.yml | 117 +++++++++++++++++++++++ .gitignore | 2 + .projen/tasks.json | 29 +++++- .projenrc.js | 12 ++- package.json | 1 + 8 files changed, 296 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release-main.yml create mode 100644 .github/workflows/upgrade-v1-main.yml diff --git a/.gitattributes b/.gitattributes index 1a28d43c..17dfc688 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,9 +7,11 @@ /.github/workflows/auto-approve.yml linguist-generated /.github/workflows/build.yml linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated +/.github/workflows/release-main.yml linguist-generated /.github/workflows/release.yml linguist-generated /.github/workflows/stale.yml linguist-generated /.github/workflows/upgrade-main.yml linguist-generated +/.github/workflows/upgrade-v1-main.yml linguist-generated /.gitignore linguist-generated /.mergify.yml linguist-generated /.npmignore linguist-generated diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml new file mode 100644 index 00000000..561990c1 --- /dev/null +++ b/.github/workflows/release-main.yml @@ -0,0 +1,132 @@ +# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". + +name: release-main +on: + push: + branches: + - main + workflow_dispatch: {} +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + latest_commit: ${{ steps.git_remote.outputs.latest_commit }} + env: + CI: "true" + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set git identity + run: |- + git config user.name "github-actions" + git config user.email "github-actions@github.com" + - name: Install dependencies + run: yarn install --check-files --frozen-lockfile + - name: release + run: npx projen release + - 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: Upload artifact + if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} + uses: actions/upload-artifact@v2.1.1 + with: + name: dist + path: dist + container: + image: jsii/superchain:1-buster-slim + release_github: + name: Publish to GitHub Releases + needs: release + runs-on: ubuntu-latest + permissions: + contents: write + if: needs.release.outputs.latest_commit == github.sha + steps: + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: dist + path: dist + - name: Release + run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R + $GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt) + --target $GITHUB_REF 2> $errout && true; exitcode=$?; if [ $exitcode + -ne 0 ] && ! grep -q "Release.tag_name already exists" $errout; then + cat $errout; exit $exitcode; fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_REF: ${{ github.ref }} + release_npm: + name: Publish to npm + needs: release + runs-on: ubuntu-latest + permissions: + contents: read + if: needs.release.outputs.latest_commit == github.sha + steps: + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: dist + path: dist + - name: Release + run: npx -p jsii-release@latest jsii-release-npm + env: + NPM_DIST_TAG: latest + NPM_REGISTRY: registry.npmjs.org + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + container: + image: jsii/superchain:1-buster-slim-node14 + release_pypi: + name: Publish to PyPI + needs: release + runs-on: ubuntu-latest + permissions: + contents: read + if: needs.release.outputs.latest_commit == github.sha + steps: + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: dist + path: dist + - name: Release + run: npx -p jsii-release@latest jsii-release-pypi + env: + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + container: + image: jsii/superchain:1-buster-slim-node14 + release_prebuilt_lambda: + name: Publish Lambda to GitHub Releases + needs: release + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: dist + path: dist + - name: Build lambda + run: docker build -t cdk-ecr-deployment-lambda lambda && docker run -v + $PWD/lambda:/out cdk-ecr-deployment-lambda cp /asset/main /out && echo + $(sha256sum lambda/main | awk '{ print $1 }') > lambda/main.sha256 + - name: Release lambda + run: "gh release upload -R $GITHUB_REPOSITORY v$(cat dist/version.txt) + lambda/main lambda/main.sha256 " + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7897d69a..5de7f504 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ name: release on: push: branches: - - main + - v1-main workflow_dispatch: {} jobs: release: @@ -26,8 +26,8 @@ jobs: git config user.email "github-actions@github.com" - name: Install dependencies run: yarn install --check-files --frozen-lockfile - - name: release - run: npx projen release + - name: release:v1-main + run: npx projen release:v1-main - name: Check for new commits id: git_remote run: echo ::set-output name=latest_commit::"$(git ls-remote origin -h ${{ diff --git a/.github/workflows/upgrade-v1-main.yml b/.github/workflows/upgrade-v1-main.yml new file mode 100644 index 00000000..78de5717 --- /dev/null +++ b/.github/workflows/upgrade-v1-main.yml @@ -0,0 +1,117 @@ +# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". + +name: upgrade-v1-main +on: + workflow_dispatch: {} + schedule: + - cron: 0 0 * * * +jobs: + upgrade: + name: Upgrade + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + conclusion: ${{ steps.build.outputs.conclusion }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: v1-main + - name: Set git identity + run: |- + git config user.name "github-actions" + git config user.email "github-actions@github.com" + - name: Install dependencies + run: yarn install --check-files --frozen-lockfile + - name: Upgrade dependencies + run: npx projen upgrade + - name: Build + id: build + run: npx projen build && echo "::set-output name=conclusion::success" || echo + "::set-output name=conclusion::failure" + - name: Create Patch + run: |- + git add . + git diff --patch --staged > .upgrade.tmp.patch + - name: Upload patch + uses: actions/upload-artifact@v2 + with: + name: .upgrade.tmp.patch + path: .upgrade.tmp.patch + container: + image: jsii/superchain:1-buster-slim + pr: + name: Create Pull Request + needs: upgrade + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + checks: write + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: v1-main + - name: Set git identity + run: |- + git config user.name "github-actions" + git config user.email "github-actions@github.com" + - name: Download patch + uses: actions/download-artifact@v2 + with: + name: .upgrade.tmp.patch + path: ${{ runner.temp }} + - name: Apply patch + run: '[ -s ${{ runner.temp }}/.upgrade.tmp.patch ] && git apply ${{ runner.temp + }}/.upgrade.tmp.patch || echo "Empty patch. Skipping."' + - name: Create Pull Request + id: create-pr + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.AUTOMATION }} + commit-message: >- + chore(deps): upgrade dependencies + + + Upgrades project dependencies. See details in [workflow run]. + + + [Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + + + ------ + + + *Automatically created by projen via the "upgrade-v1-main" workflow* + branch: github-actions/upgrade-v1-main + title: "chore(deps): upgrade dependencies" + labels: auto-approve + body: >- + Upgrades project dependencies. See details in [workflow run]. + + + [Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + + + ------ + + + *Automatically created by projen via the "upgrade-v1-main" workflow* + author: github-actions + committer: github-actions + signoff: true + - name: Update status check + if: steps.create-pr.outputs.pull-request-url != '' + run: "curl -i --fail -X POST -H \"Accept: application/vnd.github.v3+json\" -H + \"Authorization: token ${GITHUB_TOKEN}\" + https://api.github.com/repos/${{ github.repository }}/check-runs -d + '{\"name\":\"build\",\"head_sha\":\"github-actions/upgrade-v1-main\",\ + \"status\":\"completed\",\"conclusion\":\"${{ + needs.upgrade.outputs.conclusion }}\",\"output\":{\"title\":\"Created + via the upgrade-v1-main workflow.\",\"summary\":\"Action run URL: + https://github.com/${{ github.repository }}/actions/runs/${{ + github.run_id }}\"}}'" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index dfd775c1..c867809a 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ junit.xml /dist/changelog.md /dist/version.txt !/.github/workflows/release.yml +!/.github/workflows/release-main.yml !/.mergify.yml !/.github/pull_request_template.md !/test/ @@ -51,4 +52,5 @@ junit.xml .jsii tsconfig.json !/API.md +!/.github/workflows/upgrade-v1-main.yml !/.github/workflows/upgrade-main.yml diff --git a/.projen/tasks.json b/.projen/tasks.json index bc5f3548..d7eb4e88 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -186,7 +186,34 @@ "name": "release", "description": "Prepare a release from \"main\" branch", "env": { - "RELEASE": "true" + "RELEASE": "true", + "MAJOR": "2", + "PRERELEASE": true + }, + "steps": [ + { + "exec": "rm -fr dist" + }, + { + "spawn": "bump" + }, + { + "spawn": "build" + }, + { + "spawn": "unbump" + }, + { + "exec": "git diff --ignore-space-at-eol --exit-code" + } + ] + }, + "release:v1-main": { + "name": "release:v1-main", + "description": "Prepare a release from \"v1-main\" branch", + "env": { + "RELEASE": "true", + "MAJOR": "1" }, "steps": [ { diff --git a/.projenrc.js b/.projenrc.js index 5fb57ebc..c0c10d33 100644 --- a/.projenrc.js +++ b/.projenrc.js @@ -8,7 +8,17 @@ const project = new awscdk.AwsCdkConstructLibrary({ author: 'wchaws', cdkVersion: '1.134.0', cdkVersionPinning: true, - defaultReleaseBranch: 'main', + defaultReleaseBranch: 'v1-main', + majorVersion: 1, + releaseBranches: { + // 'v1-main': { + // majorVersion: 1, + // }, + main: { + majorVersion: 2, + prerelease: true, + }, + }, jsiiFqn: 'projen.AwsCdkConstructLibrary', name: 'cdk-ecr-deployment', projenUpgradeSecret: 'AUTOMATION', diff --git a/package.json b/package.json index a2c111d1..3c5b4551 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "publish:npm": "npx projen publish:npm", "publish:pypi": "npx projen publish:pypi", "release": "npx projen release", + "release:v1-main": "npx projen release:v1-main", "test": "npx projen test", "test:update": "npx projen test:update", "test:watch": "npx projen test:watch",