diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ed98f5..99bd8c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,43 +8,70 @@ 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 }} + # 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 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@v1 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@v1 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: "./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..78a0df1 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.10", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "datasync-mongodb-sdk", - "version": "1.0.9", + "name": "@contentstack/datasync-mongodb-sdk", + "version": "1.0.10", "license": "MIT", "dependencies": { "lodash": "^4.17.21", diff --git a/package.json b/package.json index 862fbab..346ab7c 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.10", "description": "Mongodb query wrapper around contents synced via @contentstack/content-store-mongodb", "main": "dist/index.js", "scripts": {