Skip to content

v3.4.1

v3.4.1 #12

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm install
- name: Run typescript
run: npm run tsc
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test
- name: Build the project
run: npm run build
publish:
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm install
- name: Check if package version has been bumped
id: version_check
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const { execSync } = require('child_process');
// Read the current version from package.json
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const currentVersion = packageJson.version;
console.log(`Current version: ${currentVersion}`);
// Fetch the latest tags
execSync('git fetch --tags');
// Get the latest tag
let allTags = execSync('git tag --sort=-v:refname').toString().trim().split('\n')
console.log(`all tags: ${allTags}`);
let previousVersion = allTags[allTags.length - 1];
if (!previousVersion) {
previousVersion = 'none';
} else {
previousVersion = previousVersion.replace(/^v/, ''); // Remove the 'v' prefix if present
}
console.log(`Previous version: ${previousVersion}`);
// Check if the version has been bumped
if (previousVersion === currentVersion || current_version === '') {
console.log('Version has not been bumped. Exiting.');
process.exit(1);
}
// Set the current version as output
return { current_version: currentVersion };
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access=public
- name: Create GitHub Release
if: ${{ steps.version_check.outputs.current_version != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag "v${{ steps.version_check.outputs.current_version }}"
git push origin "v${{ steps.version_check.outputs.current_version }}"
release_notes=$(git log -1 --pretty=%B)
gh release create "v${{ steps.version_check.outputs.current_version }}" --title "v${{ steps.version_check.outputs.current_version }}" --notes "${release_notes}"