From 5d292f71b1a12059c215ce7b3e726915b54169e8 Mon Sep 17 00:00:00 2001 From: Yohta Kimura <38206553+rajyan@users.noreply.github.com> Date: Thu, 3 Oct 2024 00:57:16 +0900 Subject: [PATCH] chore: update projen (#154) Fixes #153 --- .github/workflows/build.yml | 60 +++++++++++++++++++----------- .github/workflows/release.yml | 43 +++++++++++++-------- .github/workflows/upgrade-main.yml | 14 +++---- .projen/tasks.json | 2 +- package.json | 2 +- yarn.lock | 8 ++-- 6 files changed, 79 insertions(+), 50 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb428a5..aef6dbd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: lts/* - name: Install dependencies run: yarn install --check-files - name: build @@ -31,26 +31,26 @@ jobs: id: self_mutation run: |- git add . - git diff --staged --patch --exit-code > .repo.patch || echo "self_mutation_happened=true" >> $GITHUB_OUTPUT + git diff --staged --patch --exit-code > repo.patch || echo "self_mutation_happened=true" >> $GITHUB_OUTPUT working-directory: ./ - name: Upload patch if: steps.self_mutation.outputs.self_mutation_happened - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v4.4.0 with: - name: .repo.patch - path: .repo.patch + name: repo.patch + path: repo.patch overwrite: true - name: Fail build on mutation if: steps.self_mutation.outputs.self_mutation_happened run: |- echo "::error::Files were changed during build (see build log). If this was triggered from a fork, you will need to update your branch." - cat .repo.patch + cat repo.patch exit 1 - name: Backup artifact permissions run: cd dist && getfacl -R . > permissions-backup.acl continue-on-error: true - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v4.4.0 with: name: build-artifact path: dist @@ -71,10 +71,10 @@ jobs: - name: Download patch uses: actions/download-artifact@v4 with: - name: .repo.patch + 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."' + 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" @@ -89,12 +89,13 @@ jobs: package-js: needs: build runs-on: ubuntu-latest - permissions: {} - if: "! needs.build.outputs.self_mutation_happened" + permissions: + contents: read + if: ${{ !needs.build.outputs.self_mutation_happened }} steps: - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: lts/* - name: Download build artifacts uses: actions/download-artifact@v4 with: @@ -103,23 +104,32 @@ jobs: - 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: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + path: .repo - name: Install Dependencies run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Extract build artifact + run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo + - name: Move build artifact out of the way + run: mv dist dist.old - name: Create js artifact run: cd .repo && npx projen package:js - - name: Collect js Artifact + - 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" + permissions: + contents: read + if: ${{ !needs.build.outputs.self_mutation_happened }} steps: - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: lts/* - uses: actions/setup-python@v5 with: python-version: 3.x @@ -131,11 +141,19 @@ jobs: - 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: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + path: .repo - name: Install Dependencies run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Extract build artifact + run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo + - name: Move build artifact out of the way + run: mv dist dist.old - name: Create python artifact run: cd .repo && npx projen package:python - - name: Collect python Artifact + - name: Collect python artifact run: mv .repo/dist dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 302912a..9c33b49 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,9 @@ on: branches: - main workflow_dispatch: {} +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false jobs: release: runs-on: ubuntu-latest @@ -28,7 +31,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: lts/* - name: Install dependencies run: yarn install --check-files --frozen-lockfile - name: release @@ -36,7 +39,7 @@ jobs: - name: Check if version has already been tagged id: check_tag_exists run: |- - TAG=$(cat dist/dist/releasetag.txt) + 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 @@ -50,7 +53,7 @@ jobs: continue-on-error: true - name: Upload artifact if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v4.4.0 with: name: build-artifact path: dist @@ -68,7 +71,7 @@ jobs: steps: - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: lts/* - name: Download build artifacts uses: actions/download-artifact@v4 with: @@ -77,10 +80,6 @@ jobs: - 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: Collect GitHub Metadata - run: mv .repo/dist dist - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -98,7 +97,7 @@ jobs: steps: - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: lts/* - name: Download build artifacts uses: actions/download-artifact@v4 with: @@ -107,13 +106,19 @@ jobs: - 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: Checkout + uses: actions/checkout@v4 + with: + path: .repo - name: Install Dependencies run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Extract build artifact + run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo + - name: Move build artifact out of the way + run: mv dist dist.old - name: Create js artifact run: cd .repo && npx projen package:js - - name: Collect js Artifact + - name: Collect js artifact run: mv .repo/dist dist - name: Release env: @@ -132,7 +137,7 @@ jobs: steps: - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: lts/* - uses: actions/setup-python@v5 with: python-version: 3.x @@ -144,13 +149,19 @@ jobs: - 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: Checkout + uses: actions/checkout@v4 + with: + path: .repo - name: Install Dependencies run: cd .repo && yarn install --check-files --frozen-lockfile + - name: Extract build artifact + run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo + - name: Move build artifact out of the way + run: mv dist dist.old - name: Create python artifact run: cd .repo && npx projen package:python - - name: Collect python Artifact + - name: Collect python artifact run: mv .repo/dist dist - name: Release env: diff --git a/.github/workflows/upgrade-main.yml b/.github/workflows/upgrade-main.yml index 2e63a26..64f1d30 100644 --- a/.github/workflows/upgrade-main.yml +++ b/.github/workflows/upgrade-main.yml @@ -21,7 +21,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: lts/* - name: Install dependencies run: yarn install --check-files --frozen-lockfile - name: Upgrade dependencies @@ -30,14 +30,14 @@ jobs: id: create_patch run: |- git add . - git diff --staged --patch --exit-code > .repo.patch || echo "patch_created=true" >> $GITHUB_OUTPUT + 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 + uses: actions/upload-artifact@v4.4.0 with: - name: .repo.patch - path: .repo.patch + name: repo.patch + path: repo.patch overwrite: true pr: name: Create Pull Request @@ -54,10 +54,10 @@ jobs: - name: Download patch uses: actions/download-artifact@v4 with: - name: .repo.patch + 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."' + 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" diff --git a/.projen/tasks.json b/.projen/tasks.json index c61a912..6937497 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -155,7 +155,7 @@ "description": "Creates the distribution package", "steps": [ { - "exec": "rsync -a . .repo --exclude .git --exclude node_modules && rm -rf dist && mv .repo dist", + "spawn": "package:js", "condition": "node -e \"if (!process.env.CI) process.exit(1)\"" }, { diff --git a/package.json b/package.json index a771be8..e28418e 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "jsii-pacmak": "^1.103.1", "jsii-rosetta": "1.x", "prettier": "^2.8.8", - "projen": "^0.86.6", + "projen": "^0.88.0", "ts-jest": "^27", "ts-node": "^10.9.2", "typescript": "~4.9.5" diff --git a/yarn.lock b/yarn.lock index 62cc1c6..58e803b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4385,10 +4385,10 @@ process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== -projen@^0.86.6: - version "0.86.6" - resolved "https://registry.yarnpkg.com/projen/-/projen-0.86.6.tgz#65943163283a291fedbd61c53a9c3cbd21c109dd" - integrity sha512-UBDdUrNku6y4fTx++YXVMi9NqaaWOUzEAzPVSVtUkOdW0itV7YfE9GxXRbVrM8gB+b3doem1o1kdddaEkfsuDw== +projen@^0.88.0: + version "0.88.0" + resolved "https://registry.yarnpkg.com/projen/-/projen-0.88.0.tgz#4e3664fddc7fc0614827981c221e65776dbda390" + integrity sha512-7A6OAgL7Gz6R2yWMUlqMqZw7r5jOeqfpNLg+BZbLg3UXbtPsdOjPDp0NroGXxFkqW7NcVPzs7/lF7DZ6H9pRSQ== dependencies: "@iarna/toml" "^2.2.5" case "^1.6.3"