This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Release to npm #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release to npm | |
| on: | |
| push: | |
| tags: | |
| - "v*" # Trigger only on version tags | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required for creating releases | |
| packages: write # Required for publishing packages | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Required for tag information | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org/ | |
| - name: Install dependencies | |
| run: npm install -g pnpm && pnpm install --no-frozen-lockfile | |
| - name: Build project | |
| run: pnpm run build | |
| - name: Get version from tag | |
| id: get_version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Generate Release Notes | |
| id: release_notes | |
| run: | | |
| # Get the previous tag | |
| PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| if [ -z "$PREVIOUS_TAG" ]; then | |
| # If no previous tag exists, get all commits | |
| CHANGELOG=$(git log --pretty=format:"* %s (%h)" --no-merges) | |
| else | |
| # Get commits since last tag | |
| CHANGELOG=$(git log --pretty=format:"* %s (%h)" --no-merges ${PREVIOUS_TAG}..HEAD) | |
| fi | |
| # Save changelog to a file with proper escaping | |
| echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT | |
| echo "$CHANGELOG" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Publish to npm | |
| run: pnpm publish --no-git-checks | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: "Release v${{ steps.get_version.outputs.VERSION }}" | |
| body: | | |
| ## What's Changed | |
| ${{ steps.release_notes.outputs.CHANGELOG }} | |
| ## Installation | |
| ```bash | |
| pnpm add @chaibuilder/runtime@${{ steps.get_version.outputs.VERSION }} | |
| ``` | |
| draft: false | |
| prerelease: false | |
| make_latest: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |