From 87f488093600bc700a8dfdb758f9716f168ad115 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:32:53 -0700 Subject: [PATCH] chore: enable publishing for v2 --- .gitattributes | 2 - .github/workflows/release-v2-main.yml | 78 ----------------------- .github/workflows/release.yml | 10 +-- .github/workflows/upgrade-main.yml | 89 --------------------------- .gitignore | 3 +- .projen/files.json | 2 - .projen/tasks.json | 25 +++----- .projenrc.ts | 36 ++++++++--- package.json | 4 +- 9 files changed, 43 insertions(+), 206 deletions(-) delete mode 100644 .github/workflows/release-v2-main.yml delete mode 100644 .github/workflows/upgrade-main.yml diff --git a/.gitattributes b/.gitattributes index 66b916d..9674faa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,9 +7,7 @@ /.github/workflows/auto-approve.yml linguist-generated /.github/workflows/build.yml linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated -/.github/workflows/release-v2-main.yml linguist-generated /.github/workflows/release.yml linguist-generated -/.github/workflows/upgrade-main.yml linguist-generated /.github/workflows/upgrade-v2-main.yml linguist-generated /.gitignore linguist-generated /.mergify.yml linguist-generated diff --git a/.github/workflows/release-v2-main.yml b/.github/workflows/release-v2-main.yml deleted file mode 100644 index d5214a2..0000000 --- a/.github/workflows/release-v2-main.yml +++ /dev/null @@ -1,78 +0,0 @@ -# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". - -name: release-v2-main -on: - push: - branches: - - v2-main - workflow_dispatch: {} -jobs: - release: - runs-on: ubuntu-latest - permissions: - contents: write - outputs: - latest_commit: ${{ steps.git_remote.outputs.latest_commit }} - tag_exists: ${{ steps.check_tag_exists.outputs.exists }} - env: - CI: "true" - steps: - - name: Checkout - uses: actions/checkout@v4 - 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:v2-main - run: npx projen release:v2-main - - name: Check if version has already been tagged - id: check_tag_exists - run: |- - TAG=$(cat dist/releasetag.txt) - ([ ! -z "$TAG" ] && git ls-remote -q --exit-code --tags origin $TAG && (echo "exists=true" >> $GITHUB_OUTPUT)) || (echo "exists=false" >> $GITHUB_OUTPUT) - cat $GITHUB_OUTPUT - - name: Check for new commits - id: git_remote - run: |- - echo "latest_commit=$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" >> $GITHUB_OUTPUT - cat $GITHUB_OUTPUT - - name: Backup artifact permissions - if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} - run: cd dist && getfacl -R . > permissions-backup.acl - continue-on-error: true - - name: Upload artifact - if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} - uses: actions/upload-artifact@v4 - with: - name: build-artifact - path: dist - overwrite: true - release_github: - name: Publish to GitHub Releases - needs: release - runs-on: ubuntu-latest - permissions: - contents: write - if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha - steps: - - uses: actions/setup-node@v4 - with: - node-version: 18.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: Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_REPOSITORY: ${{ github.repository }} - GITHUB_REF: ${{ github.sha }} - run: 'echo "DRY 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"' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c5a0a6..27d57ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ name: release on: push: branches: - - main + - v2-main workflow_dispatch: {} jobs: release: @@ -27,8 +27,10 @@ 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: Shrinkwrap + run: npx projen shrinkwrap + - name: release:v2-main + run: npx projen release:v2-main - name: Check if version has already been tagged id: check_tag_exists run: |- @@ -75,4 +77,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_REF: ${{ github.sha }} - run: 'echo "DRY 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 -p 2> $errout && true; exitcode=$?; if [ $exitcode -ne 0 ] && ! grep -q "Release.tag_name already exists" $errout; then cat $errout; exit $exitcode; fi"' + 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 diff --git a/.github/workflows/upgrade-main.yml b/.github/workflows/upgrade-main.yml deleted file mode 100644 index 3d9fe61..0000000 --- a/.github/workflows/upgrade-main.yml +++ /dev/null @@ -1,89 +0,0 @@ -# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". - -name: upgrade-main -on: - workflow_dispatch: {} - schedule: - - cron: 0 0 * * * -jobs: - upgrade: - name: Upgrade - runs-on: ubuntu-latest - permissions: - contents: read - outputs: - patch_created: ${{ steps.create_patch.outputs.patch_created }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: main - - name: Install dependencies - run: yarn install --check-files --frozen-lockfile - - name: Upgrade dependencies - run: npx projen upgrade - - name: Find mutations - id: create_patch - run: |- - git add . - git diff --staged --patch --exit-code > .repo.patch || echo "patch_created=true" >> $GITHUB_OUTPUT - working-directory: ./ - - name: Upload patch - if: steps.create_patch.outputs.patch_created - uses: actions/upload-artifact@v4 - with: - name: .repo.patch - path: .repo.patch - overwrite: true - pr: - name: Create Pull Request - needs: upgrade - runs-on: ubuntu-latest - permissions: - contents: read - if: ${{ needs.upgrade.outputs.patch_created }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: main - - name: Download patch - uses: actions/download-artifact@v4 - with: - name: .repo.patch - path: ${{ runner.temp }} - - name: Apply patch - run: '[ -s ${{ runner.temp }}/.repo.patch ] && git apply ${{ runner.temp }}/.repo.patch || echo "Empty patch. Skipping."' - - name: Set git identity - run: |- - git config user.name "github-actions" - git config user.email "github-actions@github.com" - - name: Create Pull Request - id: create-pr - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.PROJEN_GITHUB_TOKEN }} - commit-message: |- - chore(deps): upgrade dependencies - - Upgrades project dependencies. See details in [workflow run]. - - [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - - ------ - - *Automatically created by projen via the "upgrade-main" workflow* - branch: github-actions/upgrade-main - title: "chore(deps): upgrade dependencies" - labels: auto-approve - body: |- - Upgrades project dependencies. See details in [workflow run]. - - [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - - ------ - - *Automatically created by projen via the "upgrade-main" workflow* - author: github-actions - committer: github-actions - signoff: true diff --git a/.gitignore b/.gitignore index c0fb610..20e4a36 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ jspm_packages/ **/*.d.ts **/*.js **/.DS_Store +npm-shrinkwrap.json /test-reports/ junit.xml !/jest.config.json @@ -42,9 +43,7 @@ junit.xml /dist/changelog.md /dist/version.txt !/.github/workflows/release.yml -!/.github/workflows/release-v2-main.yml !/.mergify.yml -!/.github/workflows/upgrade-main.yml !/.github/workflows/upgrade-v2-main.yml !/.github/pull_request_template.md !/test/ diff --git a/.projen/files.json b/.projen/files.json index 1e2e44e..219a466 100644 --- a/.projen/files.json +++ b/.projen/files.json @@ -6,9 +6,7 @@ ".github/workflows/auto-approve.yml", ".github/workflows/build.yml", ".github/workflows/pull-request-lint.yml", - ".github/workflows/release-v2-main.yml", ".github/workflows/release.yml", - ".github/workflows/upgrade-main.yml", ".github/workflows/upgrade-v2-main.yml", ".gitignore", ".mergify.yml", diff --git a/.projen/tasks.json b/.projen/tasks.json index b1ae082..b5dac5b 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -155,13 +155,12 @@ "name": "pre-compile", "description": "Prepare the project for compilation" }, - "release": { - "name": "release", - "description": "Prepare a release from \"main\" branch", + "release:v2-main": { + "name": "release:v2-main", + "description": "Prepare a release from \"v2-main\" branch", "env": { "RELEASE": "true", - "MAJOR": "3", - "PRERELEASE": "rc" + "MAJOR": "2" }, "steps": [ { @@ -181,28 +180,20 @@ } ] }, - "release:v2-main": { - "name": "release:v2-main", - "description": "Prepare a release from \"v2-main\" branch", - "env": { - "RELEASE": "true", - "MAJOR": "2" - }, + "shrinkwrap": { + "name": "shrinkwrap", "steps": [ - { - "exec": "rm -fr dist" - }, { "spawn": "bump" }, { - "spawn": "build" + "exec": "npm shrinkwrap" }, { "spawn": "unbump" }, { - "exec": "git diff --ignore-space-at-eol --exit-code" + "exec": "git checkout HEAD -- yarn.lock" } ] }, diff --git a/.projenrc.ts b/.projenrc.ts index 92fc68c..954555b 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -2,15 +2,8 @@ import { typescript } from 'projen'; const project = new typescript.TypeScriptProject({ name: 'cdk-assets', projenrcTs: true, - publishDryRun: true, - defaultReleaseBranch: 'main', - majorVersion: 3, - prerelease: 'rc', - releaseBranches: { - 'v2-main': { - majorVersion: 2, - }, - }, + defaultReleaseBranch: 'v2-main', + majorVersion: 2, autoApproveUpgrades: true, autoApproveOptions: { allowedUsernames: ['aws-cdk-automation'], @@ -83,7 +76,13 @@ const project = new typescript.TypeScriptProject({ include: ['bin/**/*.ts'], }, srcdir: 'lib', - gitignore: ['**/*.d.ts', '**/*.js', '**/.DS_Store'], + gitignore: ['**/*.d.ts', '**/*.js', '**/.DS_Store', 'npm-shrinkwrap.json'], + releaseWorkflowSetupSteps: [ + { + name: 'Shrinkwrap', + run: 'npx projen shrinkwrap', + }, + ], }); project.addPackageIgnore('*.ts'); @@ -96,4 +95,21 @@ project.eslint?.addRules({ ], }); +project.addTask('shrinkwrap', { + steps: [ + { + spawn: 'bump', + }, + { + exec: 'npm shrinkwrap', + }, + { + spawn: 'unbump', + }, + { + exec: 'git checkout HEAD -- yarn.lock', + }, + ], +}); + project.synth(); diff --git a/package.json b/package.json index 31915b7..7651eb6 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "post-compile": "npx projen post-compile", "post-upgrade": "npx projen post-upgrade", "pre-compile": "npx projen pre-compile", - "release": "npx projen release", "release:v2-main": "npx projen release:v2-main", + "shrinkwrap": "npx projen shrinkwrap", "test": "npx projen test", "test:watch": "npx projen test:watch", "unbump": "npx projen unbump", @@ -80,4 +80,4 @@ "version": "0.0.0", "types": "lib/index.d.ts", "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." -} \ No newline at end of file +}