From a0b5f409406e6fa1dc1ec7632f89b6d9c5ab2205 Mon Sep 17 00:00:00 2001 From: Hien To Date: Tue, 28 May 2024 13:41:50 +0700 Subject: [PATCH] Add CICD --- .github/workflows/cortex-node-publish.yml | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/cortex-node-publish.yml diff --git a/.github/workflows/cortex-node-publish.yml b/.github/workflows/cortex-node-publish.yml new file mode 100644 index 00000000..4c523736 --- /dev/null +++ b/.github/workflows/cortex-node-publish.yml @@ -0,0 +1,36 @@ +name: Publish cortex js Package to npmjs +on: + push: + tags: ["v[0-9]+.[0-9]+.[0-9]+"] + +jobs: + build-and-publish-plugins: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: "0" + + - name: Install jq + uses: dcarbone/install-jq-action@v2.0.1 + + - name: "Update version by tag" + run: | + # Remove the v prefix + new_version=${GITHUB_REF#refs/tags/v} + + # Replace the old version with the new version in package.json + jq --arg version "$new_version" '.version = $version' ./package.json > /tmp/package.json && mv /tmp/package.json ./package.json + + # Print the new version + echo "Updated package.json version to: $new_version" + + # Setup .npmrc file to publish to npm + - uses: actions/setup-node@v3 + with: + node-version: "20.x" + registry-url: "https://registry.npmjs.org" + - run: yarn install && yarn build + - run: yarn publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file