From eee6bc64c1a3d3ad729205c2a3dca1f26bbda4a9 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Wed, 5 Apr 2023 18:34:40 +0530 Subject: [PATCH 01/19] automate publishing code to npmjs --- .github/workflows/build.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea65b59b..8486de88 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,4 +22,12 @@ jobs: - run: npm install - run: npm test env: - CI: true \ No newline at end of file + CI: true + - name: Build package + if: ${{ github.ref == 'refs/heads/master' }} + run: npm run build + - name: Publish package + if: ${{ github.ref == 'refs/heads/master' }} + run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} From 6a2ff4efd566c2e9dc638fd17436451ef1299c04 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 18:50:11 +0530 Subject: [PATCH 02/19] running against main branch and node 20 --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8486de88..f206857a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - node_version: [14.x, 16.x, 18.x] + node_version: [16.x, 18.x, 20.x] os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v3 @@ -24,10 +24,10 @@ jobs: env: CI: true - name: Build package - if: ${{ github.ref == 'refs/heads/master' }} + if: ${{ github.ref == 'refs/heads/main' }} run: npm run build - name: Publish package - if: ${{ github.ref == 'refs/heads/master' }} + if: ${{ github.ref == 'refs/heads/main' }} run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} From 218698db8cdad2ac87f9907a0cfa39437829d5c6 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 18:57:21 +0530 Subject: [PATCH 03/19] adds condition publish based on version change --- .github/workflows/build.yml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f206857a..11fda2cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,11 +23,29 @@ jobs: - run: npm test env: CI: true - - name: Build package - if: ${{ github.ref == 'refs/heads/main' }} + - name: Check if version changed + id: version-check + run: | + if [ "${GITHUB_REF#refs/heads/}" == "main" ]; then + previous_version=$(git show HEAD:package.json | jq -r .version) + current_version=$(jq -r .version package.json) + + if [ "$previous_version" != "$current_version" ]; then + echo "Version changed. Publishing..." + echo "::set-output name=version_changed::true" + else + echo "Version unchanged. Skipping publish." + echo "::set-output name=version_changed::false" + fi + else + echo "Not on the main branch. Skipping publish." + echo "::set-output name=version_changed::false" + fi + - name: Build package on version change + if: steps.version-check.outputs.version_changed == 'true' run: npm run build - - name: Publish package - if: ${{ github.ref == 'refs/heads/main' }} + - name: Publish package on version change + if: steps.version-check.outputs.version_changed == 'true' run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} From 6895e2f74a8b64e993270c14a229b97d9f74be41 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 19:05:45 +0530 Subject: [PATCH 04/19] changes to test --- .github/workflows/build.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11fda2cd..4aaff925 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,26 +26,21 @@ jobs: - name: Check if version changed id: version-check run: | - if [ "${GITHUB_REF#refs/heads/}" == "main" ]; then - previous_version=$(git show HEAD:package.json | jq -r .version) - current_version=$(jq -r .version package.json) + previous_version=$(git show HEAD:package.json | jq -r .version) + current_version=$(jq -r .version package.json) - if [ "$previous_version" != "$current_version" ]; then - echo "Version changed. Publishing..." - echo "::set-output name=version_changed::true" - else - echo "Version unchanged. Skipping publish." - echo "::set-output name=version_changed::false" - fi + if [ "$previous_version" != "$current_version" ]; then + echo "Version changed. Publishing..." + echo "::set-output name=version_changed::true" else - echo "Not on the main branch. Skipping publish." + echo "Version unchanged. Skipping publish." echo "::set-output name=version_changed::false" fi - name: Build package on version change if: steps.version-check.outputs.version_changed == 'true' run: npm run build - name: Publish package on version change - if: steps.version-check.outputs.version_changed == 'true' + if: ${{ github.ref == 'refs/heads/main' }} run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} From 18f1bff90df46c4b95b06dafa9755d3322f3276e Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 19:15:26 +0530 Subject: [PATCH 05/19] Update script to remove deprecated ones --- .github/workflows/build.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4aaff925..638d2ba0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,21 +26,26 @@ jobs: - name: Check if version changed id: version-check run: | - previous_version=$(git show HEAD:package.json | jq -r .version) - current_version=$(jq -r .version package.json) - - if [ "$previous_version" != "$current_version" ]; then - echo "Version changed. Publishing..." - echo "::set-output name=version_changed::true" + if [ ${{ github.ref == 'refs/heads/main' }} ]; then + previous_version=$(git show HEAD:package.json | jq -r .version) + current_version=$(jq -r .version package.json) + + if [ "$previous_version" != "$current_version" ]; then + echo "Version changed. Publishing..." + echo "VERSION_CHANGED=true" >> $GITHUB_ENV + else + echo "Version unchanged. Skipping publish." + echo "VERSION_CHANGED=false" >> $GITHUB_ENV + fi else - echo "Version unchanged. Skipping publish." - echo "::set-output name=version_changed::false" + echo "Not on the main branch. Skipping publish." + echo "VERSION_CHANGED=false" >> $GITHUB_ENV fi - name: Build package on version change - if: steps.version-check.outputs.version_changed == 'true' + if: env.VERSION_CHANGED == 'true' run: npm run build - name: Publish package on version change - if: ${{ github.ref == 'refs/heads/main' }} + if: env.VERSION_CHANGED == 'true' run: npm publish env: NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} From 18e6d70e1db876ecc1c03556e0ec48b9eab9ce42 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 19:18:20 +0530 Subject: [PATCH 06/19] ensuring that build happens only once --- .github/workflows/build.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 638d2ba0..f9de4f73 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,16 +13,23 @@ jobs: matrix: node_version: [16.x, 18.x, 20.x] os: [ubuntu-latest, macos-latest, windows-latest] + env: + PUBLISHED: 'false' # Flag to track if npm publish has been done + steps: - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node_version }} + - run: npm install + - run: npm test env: CI: true + - name: Check if version changed id: version-check run: | @@ -41,11 +48,12 @@ jobs: echo "Not on the main branch. Skipping publish." echo "VERSION_CHANGED=false" >> $GITHUB_ENV fi - - name: Build package on version change - if: env.VERSION_CHANGED == 'true' - run: npm run build - - name: Publish package on version change - if: env.VERSION_CHANGED == 'true' - run: npm publish + + - name: Build and Publish on version change + if: env.VERSION_CHANGED == 'true' && env.PUBLISHED == 'false' + run: | + npm run build + npm publish + echo "PUBLISHED=true" >> $GITHUB_ENV env: NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} From 17c8f73444e374f0b9b766e016ea799898f642bc Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 19:41:40 +0530 Subject: [PATCH 07/19] changes script to run only after all 9 workflows are successful --- .github/workflows/build.yml | 87 +++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f9de4f73..760a6f05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,34 +1,25 @@ name: Generator SpringBoot + on: push: branches: - '**' + jobs: - build: - name: npm test - runs-on: ${{ matrix.os }} - timeout-minutes: 20 - strategy: - fail-fast: false - matrix: - node_version: [16.x, 18.x, 20.x] - os: [ubuntu-latest, macos-latest, windows-latest] - env: - PUBLISHED: 'false' # Flag to track if npm publish has been done + publish: + name: npm publish + runs-on: ubuntu-latest + needs: [build-windows, build-macos, build-ubuntu] + if: always() steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node_version }} - - - run: npm install - - - run: npm test - env: - CI: true + node-version: 20 - name: Check if version changed id: version-check @@ -50,10 +41,60 @@ jobs: fi - name: Build and Publish on version change - if: env.VERSION_CHANGED == 'true' && env.PUBLISHED == 'false' + if: env.VERSION_CHANGED == 'true' run: | npm run build npm publish - echo "PUBLISHED=true" >> $GITHUB_ENV env: - NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + + common-steps: + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node_version }} + + - run: npm install + + - run: npm test + env: + CI: true + +# Define separate jobs for each matrix combination + build-windows: + needs: [] + strategy: + matrix: + os: [windows-latest] + node_version: [16.x, 18.x, 20.x] + runs-on: ${{ matrix.os }} + steps: + - name: Run common steps + uses: ./.github/actions/common-steps + + build-macos: + needs: [] + strategy: + matrix: + os: [macos-latest] + node_version: [16.x, 18.x, 20.x] + runs-on: ${{ matrix.os }} + steps: + - name: Run common steps + uses: ./.github/actions/common-steps + + build-ubuntu: + needs: [] + strategy: + matrix: + os: [ubuntu-latest] + node_version: [16.x, 18.x, 20.x] + runs-on: ${{ matrix.os }} + steps: + - name: Run common steps + uses: ./.github/actions/common-steps From 235410cb07087b9fbdf83ca483fb418345091482 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 20:12:25 +0530 Subject: [PATCH 08/19] adds checkout action --- .github/workflows/build.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 22de0b33..616490cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Use Node.js uses: actions/setup-node@v3 @@ -50,29 +50,30 @@ jobs: common-steps: runs-on: ${{ matrix.os }} - steps: - - name: Checkout code - uses: actions/checkout@v3 + timeout-minutes: 20 + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node_version }} - - run: npm install - - run: npm test env: CI: true - # Define separate jobs for each matrix combination +# Define separate jobs for each matrix combination build-windows: needs: [] strategy: matrix: os: [windows-latest] node_version: [16.x, 18.x, 20.x] - runs-on: ${{ matrix.os }} steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Run common steps uses: ./.github/actions/common-steps @@ -82,8 +83,9 @@ jobs: matrix: os: [macos-latest] node_version: [16.x, 18.x, 20.x] - runs-on: ${{ matrix.os }} steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Run common steps uses: ./.github/actions/common-steps @@ -93,7 +95,8 @@ jobs: matrix: os: [ubuntu-latest] node_version: [16.x, 18.x, 20.x] - runs-on: ${{ matrix.os }} steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Run common steps uses: ./.github/actions/common-steps From d1f14dcec3592497a82fe2f6f74d242f0e3f3650 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 20:17:36 +0530 Subject: [PATCH 09/19] fix indentation issue --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 616490cd..d3eab9cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,10 +50,10 @@ jobs: common-steps: runs-on: ${{ matrix.os }} - timeout-minutes: 20 - strategy: + timeout-minutes: 20 + strategy: fail-fast: false - steps: + steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 @@ -72,7 +72,7 @@ jobs: os: [windows-latest] node_version: [16.x, 18.x, 20.x] steps: - - name: Checkout code + - name: Checkout code uses: actions/checkout@v4 - name: Run common steps uses: ./.github/actions/common-steps @@ -84,7 +84,7 @@ jobs: os: [macos-latest] node_version: [16.x, 18.x, 20.x] steps: - - name: Checkout code + - name: Checkout code uses: actions/checkout@v4 - name: Run common steps uses: ./.github/actions/common-steps @@ -96,7 +96,7 @@ jobs: os: [ubuntu-latest] node_version: [16.x, 18.x, 20.x] steps: - - name: Checkout code + - name: Checkout code uses: actions/checkout@v4 - name: Run common steps uses: ./.github/actions/common-steps From dd1fa6885ed83dc061acddec420a40ace53e6833 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 20:20:19 +0530 Subject: [PATCH 10/19] fix indendation --- .github/workflows/build.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3eab9cf..2c776fc0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,16 +50,17 @@ jobs: common-steps: runs-on: ${{ matrix.os }} - timeout-minutes: 20 - strategy: - fail-fast: false steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node_version }} + - run: npm install + - run: npm test env: CI: true @@ -71,6 +72,7 @@ jobs: matrix: os: [windows-latest] node_version: [16.x, 18.x, 20.x] + runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -83,6 +85,7 @@ jobs: matrix: os: [macos-latest] node_version: [16.x, 18.x, 20.x] + runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -95,6 +98,7 @@ jobs: matrix: os: [ubuntu-latest] node_version: [16.x, 18.x, 20.x] + runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v4 From 8d2967a69d762d4d0e9a23d2d2bac2e19750368d Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 20:23:31 +0530 Subject: [PATCH 11/19] copy steps to make build successful --- .github/workflows/build.yml | 45 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c776fc0..7db2ac11 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,12 +48,17 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - common-steps: +# Define separate jobs for each matrix combination + build-windows: + needs: [] + strategy: + matrix: + os: [windows-latest] + node_version: [16.x, 18.x, 20.x] runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: @@ -65,20 +70,6 @@ jobs: env: CI: true -# Define separate jobs for each matrix combination - build-windows: - needs: [] - strategy: - matrix: - os: [windows-latest] - node_version: [16.x, 18.x, 20.x] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Run common steps - uses: ./.github/actions/common-steps - build-macos: needs: [] strategy: @@ -89,8 +80,16 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Run common steps - uses: ./.github/actions/common-steps + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node_version }} + + - run: npm install + + - run: npm test + env: + CI: true build-ubuntu: needs: [] @@ -102,5 +101,11 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Run common steps - uses: ./.github/actions/common-steps + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node_version }} + - run: npm install + - run: npm test + env: + CI: true From 3b6bdd0aac431a389a8948c7515542077c47a467 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 20:27:43 +0530 Subject: [PATCH 12/19] adds timeout --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7db2ac11..ab9d77e0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,6 +51,7 @@ jobs: # Define separate jobs for each matrix combination build-windows: needs: [] + timeout-minutes: 20 strategy: matrix: os: [windows-latest] @@ -72,6 +73,7 @@ jobs: build-macos: needs: [] + timeout-minutes: 20 strategy: matrix: os: [macos-latest] @@ -93,6 +95,7 @@ jobs: build-ubuntu: needs: [] + timeout-minutes: 20 strategy: matrix: os: [ubuntu-latest] From 7b3298fd5890ac5d2b20522575f72a5869c6ec94 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Fri, 13 Oct 2023 20:31:47 +0530 Subject: [PATCH 13/19] polish From 8bc221238c80204bd1cd1634faf69e3d58b00de5 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sat, 28 Oct 2023 10:57:41 +0530 Subject: [PATCH 14/19] drop node 16 support --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab9d77e0..d1efa0b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,7 +55,7 @@ jobs: strategy: matrix: os: [windows-latest] - node_version: [16.x, 18.x, 20.x] + node_version: [18.x, 20.x] runs-on: ${{ matrix.os }} steps: - name: Checkout code @@ -77,7 +77,7 @@ jobs: strategy: matrix: os: [macos-latest] - node_version: [16.x, 18.x, 20.x] + node_version: [18.x, 20.x] runs-on: ${{ matrix.os }} steps: - name: Checkout code @@ -99,7 +99,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node_version: [16.x, 18.x, 20.x] + node_version: [18.x, 20.x] runs-on: ${{ matrix.os }} steps: - name: Checkout code From 5e8d2409dabb7fcaa92490280f8b455725ff5456 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Tue, 27 May 2025 20:07:02 +0530 Subject: [PATCH 15/19] polish build.yml to handle after build is sucessful --- .github/workflows/build.yml | 153 +++++++++++++++--------------------- 1 file changed, 62 insertions(+), 91 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8ce8c92..c1b90072 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,114 +1,85 @@ name: Generator SpringBoot - on: push: branches: - '**' jobs: - publish: - name: npm publish - runs-on: ubuntu-latest - needs: [build-windows, build-macos, build-ubuntu] - if: always() - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: 20 - - - name: Check if version changed - id: version-check - run: | - if [ ${{ github.ref == 'refs/heads/main' }} ]; then - previous_version=$(git show HEAD:package.json | jq -r .version) - current_version=$(jq -r .version package.json) - - if [ "$previous_version" != "$current_version" ]; then - echo "Version changed. Publishing..." - echo "VERSION_CHANGED=true" >> $GITHUB_ENV - else - echo "Version unchanged. Skipping publish." - echo "VERSION_CHANGED=false" >> $GITHUB_ENV - fi - else - echo "Not on the main branch. Skipping publish." - echo "VERSION_CHANGED=false" >> $GITHUB_ENV - fi - - - name: Build and Publish on version change - if: env.VERSION_CHANGED == 'true' - run: | - npm run build - npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - -# Define separate jobs for each matrix combination - build-windows: - needs: [] - timeout-minutes: 20 - strategy: - matrix: - os: [windows-latest] - node_version: [18.x, 20.x] + build: + name: npm test runs-on: ${{ matrix.os }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node_version }} - - - run: npm install - - - run: npm test - env: - CI: true - - build-macos: - needs: [] timeout-minutes: 20 strategy: + fail-fast: false matrix: - os: [macos-latest] - node_version: [18.x, 20.x] - runs-on: ${{ matrix.os }} + node_version: [22.x, 20.x] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for checking version changes + + - name: Use Node.js ${{ matrix.node_version }} + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node_version }} - + - run: npm install - + - run: npm test env: CI: true - build-ubuntu: - needs: [] - timeout-minutes: 20 - strategy: - matrix: - os: [ubuntu-latest] - node_version: [18.x, 20.x] - runs-on: ${{ matrix.os }} + publish: + name: Publish to NPM + needs: build # Wait for all build matrix jobs to complete successfully + if: github.ref == 'refs/heads/main' # Only run on main branch + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for checking version changes + + - name: Check for version change + id: check_version + run: | + # Get the version from the current commit's package.json + CURRENT_VERSION=$(node -p "require('./package.json').version") + + # Determine previous commit on main branch + git fetch origin main + PREV_COMMIT=$(git rev-parse HEAD^1) + + # Get package.json from the previous commit + git show $PREV_COMMIT:package.json > prev_package.json + + # Extract previous version + PREV_VERSION=$(node -p "require('./prev_package.json').version") + + echo "Current version: $CURRENT_VERSION" + echo "Previous version: $PREV_VERSION" + + if [ "$CURRENT_VERSION" != "$PREV_VERSION" ]; then + echo "Version changed from $PREV_VERSION to $CURRENT_VERSION" + echo "version_changed=true" >> $GITHUB_OUTPUT + else + echo "Version unchanged" + echo "version_changed=false" >> $GITHUB_OUTPUT + fi + + - name: Setup Node.js + if: steps.check_version.outputs.version_changed == 'true' uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node_version }} - - run: npm install - - run: npm test + node-version: 22.x + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + if: steps.check_version.outputs.version_changed == 'true' + run: npm ci + + - name: Publish to NPM + if: steps.check_version.outputs.version_changed == 'true' + run: npm publish env: - CI: true + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 3a118598d3d01c8525290172837739e32fe36900 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Tue, 27 May 2025 20:18:07 +0530 Subject: [PATCH 16/19] Update build.yml --- .github/workflows/build.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c1b90072..7980b8ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,10 @@ on: push: branches: - '**' + pull_request: + types: [closed] + branches: + - main jobs: build: @@ -29,17 +33,22 @@ jobs: - run: npm test env: CI: true - publish: name: Publish to NPM needs: build # Wait for all build matrix jobs to complete successfully - if: github.ref == 'refs/heads/main' # Only run on main branch + # Only run when: + # 1. The code is on the main branch + # 2. It's either a direct push or a merged PR + # 3. All 6 matrix checks have passed (enforced by 'needs: build') + if: | + (github.ref == 'refs/heads/main') && + (github.event_name == 'push' || + (github.event_name == 'pull_request' && github.event.pull_request.merged == true)) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Fetch all history for checking version changes - - name: Check for version change id: check_version run: | @@ -48,13 +57,20 @@ jobs: # Determine previous commit on main branch git fetch origin main - PREV_COMMIT=$(git rev-parse HEAD^1) + + # For pull requests, use the base commit + if [ "${{ github.event_name }}" == "pull_request" ]; then + PREV_COMMIT="${{ github.event.pull_request.base.sha }}" + else + # For direct pushes, use the parent commit + PREV_COMMIT=$(git rev-parse HEAD^1) + fi # Get package.json from the previous commit - git show $PREV_COMMIT:package.json > prev_package.json + git show $PREV_COMMIT:package.json > prev_package.json || echo "No previous package.json found" # Extract previous version - PREV_VERSION=$(node -p "require('./prev_package.json').version") + PREV_VERSION=$(node -p "require('./prev_package.json').version" 2>/dev/null || echo "0.0.0") echo "Current version: $CURRENT_VERSION" echo "Previous version: $PREV_VERSION" From 44112196f3c9983b357fb038995da1b094e0fc05 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sat, 20 Sep 2025 13:22:55 +0000 Subject: [PATCH 17/19] create saperate relese workflow --- .github/workflows/build.yml | 67 ----------------------------------- .github/workflows/release.yml | 31 ++++++++++++++++ 2 files changed, 31 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7980b8ef..1499d879 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,8 +20,6 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetch all history for checking version changes - name: Use Node.js ${{ matrix.node_version }} uses: actions/setup-node@v4 @@ -33,69 +31,4 @@ jobs: - run: npm test env: CI: true - publish: - name: Publish to NPM - needs: build # Wait for all build matrix jobs to complete successfully - # Only run when: - # 1. The code is on the main branch - # 2. It's either a direct push or a merged PR - # 3. All 6 matrix checks have passed (enforced by 'needs: build') - if: | - (github.ref == 'refs/heads/main') && - (github.event_name == 'push' || - (github.event_name == 'pull_request' && github.event.pull_request.merged == true)) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetch all history for checking version changes - - name: Check for version change - id: check_version - run: | - # Get the version from the current commit's package.json - CURRENT_VERSION=$(node -p "require('./package.json').version") - - # Determine previous commit on main branch - git fetch origin main - - # For pull requests, use the base commit - if [ "${{ github.event_name }}" == "pull_request" ]; then - PREV_COMMIT="${{ github.event.pull_request.base.sha }}" - else - # For direct pushes, use the parent commit - PREV_COMMIT=$(git rev-parse HEAD^1) - fi - - # Get package.json from the previous commit - git show $PREV_COMMIT:package.json > prev_package.json || echo "No previous package.json found" - - # Extract previous version - PREV_VERSION=$(node -p "require('./prev_package.json').version" 2>/dev/null || echo "0.0.0") - - echo "Current version: $CURRENT_VERSION" - echo "Previous version: $PREV_VERSION" - - if [ "$CURRENT_VERSION" != "$PREV_VERSION" ]; then - echo "Version changed from $PREV_VERSION to $CURRENT_VERSION" - echo "version_changed=true" >> $GITHUB_OUTPUT - else - echo "Version unchanged" - echo "version_changed=false" >> $GITHUB_OUTPUT - fi - - - name: Setup Node.js - if: steps.check_version.outputs.version_changed == 'true' - uses: actions/setup-node@v4 - with: - node-version: 22.x - registry-url: 'https://registry.npmjs.org' - - - name: Install dependencies - if: steps.check_version.outputs.version_changed == 'true' - run: npm ci - - - name: Publish to NPM - if: steps.check_version.outputs.version_changed == 'true' - run: npm publish - env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..83db34d1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release to NPM +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' # Matches semantic version tags like 1.2.3 + +jobs: + release: + name: Publish to NPM + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.x + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + env: + CI: true + + - name: Publish to NPM + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file From 350ca200ee248c99e9eb95f99418965171830ed5 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sat, 20 Sep 2025 13:24:20 +0000 Subject: [PATCH 18/19] restore original behaviour --- .github/workflows/build.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1499d879..31019203 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,10 +3,6 @@ on: push: branches: - '**' - pull_request: - types: [closed] - branches: - - main jobs: build: @@ -31,4 +27,3 @@ jobs: - run: npm test env: CI: true - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 112fe9759e9a39f8ad6083473c86406b993a5fa4 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sat, 20 Sep 2025 19:08:25 +0530 Subject: [PATCH 19/19] Update .github/workflows/release.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83db34d1..008c3367 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,4 +28,4 @@ jobs: - name: Publish to NPM run: npm publish env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} \ No newline at end of file