From b398a7eaa801aa4767e100e2411c34b1e789dfc2 Mon Sep 17 00:00:00 2001 From: Prashant Srivastav Date: Sat, 30 Aug 2025 19:17:14 +0800 Subject: [PATCH] nodejs sdk completed --- .github/workflows/node-build.yml | 55 ++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/.github/workflows/node-build.yml b/.github/workflows/node-build.yml index fd19b4a..e42b110 100644 --- a/.github/workflows/node-build.yml +++ b/.github/workflows/node-build.yml @@ -25,35 +25,62 @@ jobs: node-version: "16" - name: Install dependencies - run: npm ci + run: | + npm ci + npm install -g postcss-cli - name: Build the package run: npm run build - name: Publish to npm + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc npm publish - tag: - runs-on: ubuntu-latest + create_release: + name: Create Release needs: build - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' - + runs-on: ubuntu-latest + permissions: + contents: write + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get version and create tag + id: version + run: | + VERSION="0.1.$(date +%Y%m%d)-$(git rev-parse --short HEAD)" + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + echo "TAG_NAME=v${VERSION}" >> $GITHUB_OUTPUT + if git tag -l "v${VERSION}" | grep -q "v${VERSION}"; then + echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT + else + echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT + fi - - name: Set Git committer identity + - name: Create and push tag + if: steps.version.outputs.TAG_EXISTS == 'false' run: | - git config --global user.email "p_srivastav@outlook.com" - git config --global user.name "Prashant Srivastav" + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "${{ steps.version.outputs.TAG_NAME }}" -m "Release ${{ steps.version.outputs.TAG_NAME }}" + git push origin "${{ steps.version.outputs.TAG_NAME }}" - - name: Tag the release - id: tag + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - NEW_TAG=$(date +'%Y%m%d%H%M%S') - git tag -a "v${NEW_TAG}" -m "Release version ${NEW_TAG}" - git push origin "v${NEW_TAG}" + echo "# Release ${{ steps.version.outputs.TAG_NAME }}" > release-notes.md + echo "" >> release-notes.md + echo "## Changes" >> release-notes.md + echo "- Automated release from commit $(git rev-parse --short HEAD)" >> release-notes.md + gh release create "${{ steps.version.outputs.TAG_NAME }}" \ + --title "Release ${{ steps.version.outputs.TAG_NAME }}" \ + --notes-file release-notes.md