Skip to content

2.3.0-29

2.3.0-29 #52

Workflow file for this run

name: CD
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write
id-token: write # Required for OIDC
jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.event.head_commit.author.email != 'github-actions[bot]@users.noreply.github.com'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
registry-url: "https://registry.npmjs.org"
- name: Upgrade npm
run: npm install -g npm@latest
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Get latest tag and increment version
id: version
run: |
# Get the latest tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
echo "Latest tag: $LATEST_TAG"
# Extract version without 'v' prefix
VERSION_WITHOUT_V=${LATEST_TAG#v}
echo "Version without v: $VERSION_WITHOUT_V"
# Extract the base version and increment number
if [[ $VERSION_WITHOUT_V =~ ^([0-9]+\.[0-9]+\.[0-9]+)-([0-9]+)$ ]]; then
BASE_VERSION="${BASH_REMATCH[1]}"
INCREMENT_NUMBER="${BASH_REMATCH[2]}"
else
echo "Error: Tag format doesn't match expected pattern"
exit 1
fi
# Increment the number
NEW_INCREMENT=$((INCREMENT_NUMBER + 1))
NEW_VERSION="$BASE_VERSION-$NEW_INCREMENT"
echo "New version: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Install dependencies
run: npm ci
- name: Run lint
run: npm run lint
- name: Download wheels
run: npm run download-wheels
- name: Run tests
run: npm test
- name: Update version and create tag
run: |
NEW_VERSION="${{ steps.version.outputs.new_version }}"
npm version $NEW_VERSION
- name: Build package
run: npm run build
- name: Push tag and version commit
run: |
NEW_VERSION="${{ steps.version.outputs.new_version }}"
git push origin main
git push origin "v$NEW_VERSION"
- name: Publish to npm
run: npm publish --tag latest
- name: Pack npm package
run: |
npm pack
echo "package_file=$(ls *.tgz)" >> $GITHUB_OUTPUT
id: package
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.new_version }}
name: Release v${{ steps.version.outputs.new_version }}
body: |
# Automated release v${{ steps.version.outputs.new_version }}
## 📦 Package
This release includes the package that was published to the NPM registry.
## 🚀 Installation
```bash
npm i aksharamukha@${{ steps.version.outputs.new_version }}
```
files: ${{ steps.package.outputs.package_file }}
draft: false
prerelease: false
deploy:
name: Deploy website
runs-on: ubuntu-latest
needs: publish
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.event.head_commit.author.email != 'github-actions[bot]@users.noreply.github.com'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Install dependencies
working-directory: ./docs
run: npm ci
- name: Run lint
working-directory: ./docs
run: npm run lint
- name: Build package
working-directory: ./docs
run: npm run build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/out