From ee5d76229cc58b00917dd457cad912f8112bb82a Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Mon, 24 Mar 2025 15:43:51 +0530 Subject: [PATCH 1/4] chore: enhance GitHub Actions workflow for npm package release process --- .github/workflows/release.yml | 62 +++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 159663d..47464dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,43 +8,69 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + # Checkout the repository + - name: Checkout repository + uses: actions/checkout@v4 + + # Setup Node.js environment + - name: Setup Node.js + uses: actions/setup-node@v4 with: node-version: "22.x" - - run: npm install - - name: get-package-details + # Install dependencies + - name: Install dependencies + run: npm install + + # Fetch package details (name and version) + - name: Get package details id: package uses: codex-team/action-nodejs-package-info@v1.1 - - name: install npm packall + + # Install npm-pack-all to create a package archive + - name: Install npm-pack-all run: npm install npm-pack-all - - run: node node_modules/.bin/npm-pack-all - - uses: Klemensas/action-autotag@stable + # Pack the package into a .tgz archive + - name: Pack the npm package + run: node node_modules/.bin/npm-pack-all + + # Publish the package to npm + - name: Publish to npm + id: publish_npm + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + + # Auto-tag the new version if a change is detected + - name: Auto-tag new version id: update_tag + uses: Klemensas/action-autotag@stable with: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" tag_prefix: "v" - - name: Create Release - if: steps.update_tag.outputs.tagname + + # Create a new GitHub Release + - name: Create GitHub Release + if: steps.update_tag.outputs.tagname != '' uses: actions/create-release@v4 id: create_release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ steps.update_tag.outputs.tagname }} release_name: Release ${{ steps.update_tag.outputs.tagname }} - draft: false # Default value, but nice to set explicitly - prerelease: false # Default value, but nice to set explicitly + draft: false + prerelease: false + + # Upload the packaged .tgz file as a release asset - name: Upload Release Asset - if: steps.update_tag.outputs.tagname - id: upload-release-asset + if: steps.update_tag.outputs.tagname != '' uses: actions/upload-release-asset@v4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./${{ steps.package.outputs.name }}-${{ steps.package.outputs.version }}.tgz - asset_name: ${{ steps.package.outputs.name }}-${{ steps.package.outputs.version }}.tgz - asset_content_type: application/tgz \ No newline at end of file + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: "./${{ steps.package.outputs.name }}-${{ steps.package.outputs.version }}.tgz" + asset_name: "${{ steps.package.outputs.name }}-${{ steps.package.outputs.version }}.tgz" + asset_content_type: application/gzip From 7f89a0c85f09cfeae5e327fba82958c23778c370 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Wed, 26 Mar 2025 13:05:58 +0530 Subject: [PATCH 2/4] chore: update workflow for npm publish --- .github/workflows/release.yml | 9 +++++---- package-lock.json | 8 ++++---- package.json | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47464dd..491e840 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Release on: push: - branches: [master] + branches: [feat/2326-npm-publish] jobs: build: @@ -41,6 +41,7 @@ jobs: uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} + access: public # Uncomment this line if you want to publish the package as public for first time # Auto-tag the new version if a change is detected - name: Auto-tag new version @@ -71,6 +72,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: "./${{ steps.package.outputs.name }}-${{ steps.package.outputs.version }}.tgz" - asset_name: "${{ steps.package.outputs.name }}-${{ steps.package.outputs.version }}.tgz" - asset_content_type: application/gzip + asset_path: "./contentstack-datasync-mongodb-sdk-${{ steps.package.outputs.version }}.tgz" + asset_name: "contentstack-datasync-mongodb-sdk-${{ steps.package.outputs.version }}.tgz" + asset_content_type: application/tgz diff --git a/package-lock.json b/package-lock.json index 94b83e9..41fc5ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "datasync-mongodb-sdk", - "version": "1.0.9", + "name": "@contentstack/datasync-mongodb-sdk", + "version": "1.0.9-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "datasync-mongodb-sdk", - "version": "1.0.9", + "name": "@contentstack/datasync-mongodb-sdk", + "version": "1.0.9-beta.1", "license": "MIT", "dependencies": { "lodash": "^4.17.21", diff --git a/package.json b/package.json index 862fbab..c1783fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Contentstack Ecosystem ", - "name": "datasync-mongodb-sdk", - "version": "1.0.9", + "name": "@contentstack/datasync-mongodb-sdk", + "version": "1.0.9-beta.1", "description": "Mongodb query wrapper around contents synced via @contentstack/content-store-mongodb", "main": "dist/index.js", "scripts": { From 64d5459021385a0522fb44680f979028a8847c02 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Wed, 26 Mar 2025 13:07:32 +0530 Subject: [PATCH 3/4] chore: downgrade GitHub Actions to v1 for release and upload asset steps --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 491e840..6071ff1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,7 +54,7 @@ jobs: # Create a new GitHub Release - name: Create GitHub Release if: steps.update_tag.outputs.tagname != '' - uses: actions/create-release@v4 + uses: actions/create-release@v1 id: create_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -67,7 +67,7 @@ jobs: # Upload the packaged .tgz file as a release asset - name: Upload Release Asset if: steps.update_tag.outputs.tagname != '' - uses: actions/upload-release-asset@v4 + uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: From d2e6f96a2461c51314877a1e3f94738edde0c5d3 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Wed, 26 Mar 2025 13:12:33 +0530 Subject: [PATCH 4/4] chore: update release branch to master and bump version to 1.0.10 --- .github/workflows/release.yml | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6071ff1..99bd8c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Release on: push: - branches: [feat/2326-npm-publish] + branches: [master] jobs: build: @@ -41,7 +41,7 @@ jobs: uses: JS-DevTools/npm-publish@v3 with: token: ${{ secrets.NPM_TOKEN }} - access: public # Uncomment this line if you want to publish the package as public for first time + # access: public # Uncomment this line if you want to publish the package as public for first time # Auto-tag the new version if a change is detected - name: Auto-tag new version diff --git a/package-lock.json b/package-lock.json index 41fc5ab..78a0df1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/datasync-mongodb-sdk", - "version": "1.0.9-beta.1", + "version": "1.0.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/datasync-mongodb-sdk", - "version": "1.0.9-beta.1", + "version": "1.0.10", "license": "MIT", "dependencies": { "lodash": "^4.17.21", diff --git a/package.json b/package.json index c1783fe..346ab7c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Contentstack Ecosystem ", "name": "@contentstack/datasync-mongodb-sdk", - "version": "1.0.9-beta.1", + "version": "1.0.10", "description": "Mongodb query wrapper around contents synced via @contentstack/content-store-mongodb", "main": "dist/index.js", "scripts": {