chore: bump version to 2.2.8 #76
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 PRs | |
SINCE_DATE="1970-01-01" | |
else | |
# Get date of previous tag | |
SINCE_DATE=$(git log -1 --format=%aI $PREVIOUS_TAG) | |
fi | |
# Use GitHub API to get PRs merged since the last tag | |
REPO_NAME="${GITHUB_REPOSITORY}" | |
CHANGELOG=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${REPO_NAME}/pulls?state=closed&sort=updated&direction=desc&per_page=100" | \ | |
jq -r ".[] | select(.merged_at != null) | select(.merged_at > \"${SINCE_DATE}\") | \"* \(.title) ([#\(.number)](\(.html_url)))\"") | |
# 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/sdk@${{ steps.get_version.outputs.VERSION }} | |
``` | |
draft: false | |
prerelease: false | |
make_latest: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |