Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintrc.yml

This file was deleted.

101 changes: 101 additions & 0 deletions .github/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Release Process

This project uses GitHub Actions to automate the release process.

## Creating a New Release

### 1. Trigger the Release Workflow

1. Go to the **Actions** tab in GitHub
2. Select the **Release** workflow from the left sidebar
3. Click **Run workflow**
4. Choose the version bump type:
- **patch**: Bug fixes and minor updates (2.2.2 → 2.2.3)
- **minor**: New features, backward compatible (2.2.2 → 2.3.0)
- **major**: Breaking changes (2.2.2 → 3.0.0)
5. Click **Run workflow**

### 2. Review the Release PR

The workflow will automatically:
- Bump the version in `package.json`
- Generate a changelog from git commits since the last release
- Update `CHANGELOG.md` with the new version entry
- Create a Pull Request with all changes

Review the PR carefully:
- Check that the version bump is correct
- Review the generated changelog
- Verify all changes look good

### 3. Merge the Release PR

Once satisfied, merge the PR to the main branch.

### 4. Create a GitHub Release

After merging:
1. Go to the **Releases** page
2. Click **Draft a new release**
3. Create a new tag matching the version (e.g., `v2.3.0`)
4. Use the changelog from the merged PR as the release notes
5. Publish the release

### 5. Publish to npm

After creating the GitHub release:

```bash
# Ensure you're on the main branch with latest changes
git checkout main
git pull origin main

# Build the package
yarn build

# Publish to npm (requires npm authentication)
npm publish
```

## Manual Release (Alternative)

If you prefer to do releases manually:

```bash
# Bump version
yarn version --patch # or --minor, --major

# Update CHANGELOG.md manually

# Commit changes
git add package.json CHANGELOG.md
git commit -m "chore: bump version to vX.Y.Z"

# Create tag
git tag vX.Y.Z

# Push changes and tag
git push origin main --tags

# Build and publish
yarn build
npm publish
```

## Changelog Format

The automated workflow generates changelog entries from git commit messages. For best results, use conventional commit format:

- `feat:` - New features
- `fix:` - Bug fixes
- `chore:` - Maintenance tasks
- `docs:` - Documentation changes
- `refactor:` - Code refactoring
- `test:` - Test updates

Example:
```
feat: add dark mode support
fix: resolve memory leak in GridWrapper
chore: update dependencies
```
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: Test & Build
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x, 22.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run linter
run: yarn lint

- name: Run type check
run: yarn type

- name: Run tests
run: yarn test --run

- name: Build package
run: yarn build

- name: Install example dependencies
working-directory: ./example
run: yarn install --frozen-lockfile

- name: Build example
working-directory: ./example
run: yarn build

- name: Check for security vulnerabilities
run: yarn audit --level moderate
continue-on-error: true
138 changes: 138 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major

jobs:
create-release-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
# Ensure this workflow only runs from the main branch
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Get current version
id: current_version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Bump version
id: bump_version
run: |
yarn version --${{ github.event.inputs.version }} --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Bumped version from ${{ steps.current_version.outputs.version }} to $NEW_VERSION"

- name: Generate changelog
id: changelog
run: |
# Get the latest tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")

if [ -z "$LATEST_TAG" ]; then
echo "No previous tag found, generating changelog from first commit"
COMMIT_RANGE=$(git rev-list --max-parents=0 HEAD)..HEAD
else
echo "Latest tag: $LATEST_TAG"
COMMIT_RANGE=$LATEST_TAG..HEAD
fi

# Generate changelog
CHANGELOG=$(git log $COMMIT_RANGE --pretty=format:"- %s (%h)" --no-merges)

# Save to file for PR body
cat > /tmp/changelog.md <<EOF
## Changes in v${{ steps.bump_version.outputs.new_version }}

$CHANGELOG
EOF

# Output for use in PR
echo "changelog<<EOF" >> $GITHUB_OUTPUT
cat /tmp/changelog.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Update CHANGELOG.md
run: |
# Create or update CHANGELOG.md
if [ ! -f CHANGELOG.md ]; then
echo "# Changelog" > CHANGELOG.md
echo "" >> CHANGELOG.md
echo "All notable changes to this project will be documented in this file." >> CHANGELOG.md
echo "" >> CHANGELOG.md
fi

# Prepare new entry
cat > /tmp/new_entry.md <<EOF
## [v${{ steps.bump_version.outputs.new_version }}] - $(date +%Y-%m-%d)

EOF

cat /tmp/changelog.md | tail -n +3 >> /tmp/new_entry.md
echo "" >> /tmp/new_entry.md

# Insert after the header
sed -i '1,/^All notable/r /tmp/new_entry.md' CHANGELOG.md || {
# If sed fails (no header found), just prepend
cat /tmp/new_entry.md CHANGELOG.md > /tmp/new_changelog.md
mv /tmp/new_changelog.md CHANGELOG.md
}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: release/v${{ steps.bump_version.outputs.new_version }}
commit-message: "chore: bump version to v${{ steps.bump_version.outputs.new_version }}"
title: "Release v${{ steps.bump_version.outputs.new_version }}"
body: |
## Release v${{ steps.bump_version.outputs.new_version }}

This PR bumps the version from **v${{ steps.current_version.outputs.version }}** to **v${{ steps.bump_version.outputs.new_version }}**.

${{ steps.changelog.outputs.changelog }}

---

### Release Checklist
- [ ] Review changelog and version bump
- [ ] Merge this PR to main
- [ ] Create a GitHub release from main with tag `v${{ steps.bump_version.outputs.new_version }}`
- [ ] Run `yarn build` locally
- [ ] Run `npm publish` to publish to npm registry

---
*This PR was automatically generated by the release workflow*
labels: |
release
automated
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import reearth from "eslint-config-reearth";

export default [
...reearth("react-align", { reactRecommended: false }),
{
ignores: ["**/dist/", "**/node_modules/", "**/*.min.js"],
},
];
21 changes: 21 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# React Align Example

This example demonstrates the usage of react-align library.

## Important Notes

- This example uses **Vite 3.x** to demonstrate compatibility with older tooling
- The example imports from the built library rather than source code
- The main package is built with Vite 7, but the library itself is compatible with projects using older Vite versions

## Running the Example

```bash
yarn install
yarn dev
```

## Known Issues

- `react-beautiful-dnd` is deprecated and may have compatibility warnings with React 18
- The library continues to work but you may see console warnings about `defaultProps`
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"@vitejs/plugin-react": "^2.2.0",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.1.0",
"typescript": "^4.8.4",
"vite": "^3.2.1"
}
Expand Down
5 changes: 3 additions & 2 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
Expand All @@ -16,5 +16,6 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["./src"]
"include": ["./src"],
"exclude": ["node_modules", "dist"]
}
Loading