Skip to content

Commit

Permalink
feat: feat: added github workflow to create auto release
Browse files Browse the repository at this point in the history
  • Loading branch information
shahrear33 authored and stainless-app[bot] committed Jan 8, 2025
1 parent df80313 commit 70b7271
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/release-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release on Merge

on:
pull_request:
types:
- closed

jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensures full history for comparison

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci # Ensures a clean install

- name: Check for version change
id: check_version
run: |
PREV_VERSION=$(git show HEAD^:package.json | jq -r .version)
NEW_VERSION=$(jq -r .version package.json)
echo "Previous version: $PREV_VERSION"
echo "New version: $NEW_VERSION"
if [ "$PREV_VERSION" != "$NEW_VERSION" ]; then
echo "Version has changed to $NEW_VERSION"
echo "VERSION_CHANGED=true" >> $GITHUB_ENV
echo "RELEASE_TAG=v$NEW_VERSION" >> $GITHUB_ENV
else
echo "No version change detected."
echo "VERSION_CHANGED=false" >> $GITHUB_ENV
fi
- name: Create GitHub Release
if: env.VERSION_CHANGED == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.RELEASE_TAG }}
name: Release ${{ env.RELEASE_TAG }}
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to NPM (Optional)
if: env.VERSION_CHANGED == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.VLM_NPM_TOKEN || secrets.NPM_TOKEN }}

0 comments on commit 70b7271

Please sign in to comment.