Skip to content

Updated package.json #27

Updated package.json

Updated package.json #27

Workflow file for this run

name: Build and Release Source Code
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Get Latest Release Version
id: get_version
run: |
LATEST_TAG=$(git ls-remote --tags origin | grep -o 'refs/tags/v[0-9]*\.[0-9]*\.[0-9]*$' | sed 's/refs\/tags\///' | sort -V | tail -n 1)
if [[ -z "$LATEST_TAG" ]]; then
TAG_NAME="v1.0.0" # Start from v1.0.0 if no tags found
else
if [[ $LATEST_TAG =~ v([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
PATCH=$((PATCH + 1)) # Increment patch version
TAG_NAME="v${MAJOR}.${MINOR}.${PATCH}"
else
TAG_NAME="v1.0.1" # Fallback if no valid tag found
fi
fi
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
- name: Create Git Tag
run: |
git tag ${{ env.TAG_NAME }}
git push origin ${{ env.TAG_NAME }} || echo "Tag already exists, skipping push."
- name: Get Changelog
id: changelog
run: |
CHANGELOG=$(git log --pretty=format:'- %s' $(git describe --tags --abbrev=0)..HEAD)
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_ENV
- name: Create GitHub Release
uses: softprops/[email protected]
with:
tag_name: ${{ env.TAG_NAME }}
body: |
## Changelog
${{ env.CHANGELOG }}
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}