Skip to content

Merge pull request #2 from ArtemLazarchuk/implement-better-UI #6

Merge pull request #2 from ArtemLazarchuk/implement-better-UI

Merge pull request #2 from ArtemLazarchuk/implement-better-UI #6

name: Distribute Library
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build-and-distribute:
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 ci
- name: Build library
run: npm run build:lib
- name: Deploy to build branch
if: github.ref == 'refs/heads/main'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Create or switch to build branch
git checkout -B build
# Remove everything except dist and essential files
git rm -rf . || true
git reset --hard
# Copy dist contents to root
cp -r dist/* ./
# Copy essential files for npm package from main branch
git checkout main -- package.json README.md
# Update package.json for build branch
node -e "
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.name = 'toroid-wireframe-clouds';
pkg.main = './index.js';
pkg.module = './index.js';
pkg.types = './index.d.ts';
pkg.exports = {
'.': {
'import': './index.js',
'types': './index.d.ts'
}
};
pkg.files = ['*.js', '*.d.ts', '*.json', '*.md'];
delete pkg.scripts;
delete pkg.devDependencies;
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
"
# Add all files
git add .
# Commit and push
git commit -m "Build library from main branch [skip ci]"
git push origin build --force