diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..feaa7d9d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,52 @@ +name: Publish to npm + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - "package.json" + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-node@v6 + with: + node-version: 22.x + registry-url: "https://registry.npmjs.org" + + - name: Install dependencies + run: npm install --frozen-lockfile + + - name: Lint + run: npm run lint + + - name: Test + run: npm run test + env: + CI: true + + - name: Build + run: npm run build + + - name: Verify dist contents + run: | + echo "Contents of packages/react-hotkeys-hook/dist/:" + ls -la packages/react-hotkeys-hook/dist/ + if [ ! -f packages/react-hotkeys-hook/dist/index.js ]; then + echo "ERROR: dist/index.js not found" + exit 1 + fi + if [ ! -f packages/react-hotkeys-hook/dist/index.d.ts ]; then + echo "ERROR: dist/index.d.ts not found" + exit 1 + fi + + - name: Publish to npm + run: npm publish --tolerate-republish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 00000000..7dacbcf8 --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -0,0 +1,86 @@ +name: Version Bump + +on: + pull_request: + types: [opened, synchronize, reopened] + paths: + - "packages/react-hotkeys-hook/**" + - ".github/workflows/publish.yml" + +permissions: + contents: write + pull-requests: write + +jobs: + version-bump: + runs-on: ubuntu-latest + if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-version-bump') }} + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + + - uses: actions/setup-node@v6 + with: + node-version: 22.x + + - name: Install Claude Code + run: npm install -g @anthropic-ai/claude-code + + - name: Run Claude Version Bump Analysis + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + claude --dangerously-skip-permissions --model sonnet -p " + You are analyzing PR #${{ github.event.pull_request.number }} for @humanlayer/react-hotkeys-hook version bump. + + ## Context + - Package: root package.json (publishes from packages/react-hotkeys-hook/dist) + - Package name: @humanlayer/react-hotkeys-hook + - PR Title: ${{ github.event.pull_request.title }} + + ## Instructions + + 1. Read the PR diff using: gh pr diff ${{ github.event.pull_request.number }} + 2. Read the commit messages using: gh pr view ${{ github.event.pull_request.number }} --json commits + 3. Check the current version: cat package.json | jq -r '.version' + 4. Check if version differs from base branch: git show origin/${{ github.base_ref }}:package.json | jq -r '.version' + + ## Decision Logic + + If the user ALREADY bumped the version (current != base): + - Analyze whether you agree with their bump level + - If you agree: explain why their choice is correct + - If you disagree: explain what bump level you would recommend and why + - DO NOT make any changes - just provide your analysis + + If the user has NOT bumped the version (current == base): + - Determine the appropriate bump level based on changes: + - MAJOR: Breaking API changes, removed exports, changed hook signatures + - MINOR: New features, new exports, new options (backwards compatible) + - PATCH: Bug fixes, documentation, refactoring, dependency updates + - Bump BOTH package.json files: + - npm version --no-git-tag-version + - cd packages/react-hotkeys-hook && npm version --no-git-tag-version + - Commit: git add package.json packages/react-hotkeys-hook/package.json && git commit -m 'chore: bump @humanlayer/react-hotkeys-hook to ' + - Push: git push + + ## Final Output + + End your response with a clear summary formatted like: + + ## Version Bump Summary + + **Package**: @humanlayer/react-hotkeys-hook + **Action**: instead of user's | no changes needed> + **Reasoning**: + " 2>&1 | tee CLAUDE_OUTPUT.md + + - name: Comment on PR + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr comment ${{ github.event.pull_request.number }} --body-file CLAUDE_OUTPUT.md --edit-last || \ + gh pr comment ${{ github.event.pull_request.number }} --body-file CLAUDE_OUTPUT.md diff --git a/package.json b/package.json index 2464ddb8..4b1e54b1 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { - "name": "react-hotkeys-hook", - "description": "React hook for handling keyboard shortcuts", - "version": "5.2.4", + "name": "@humanlayer/react-hotkeys-hook", + "description": "React hook for handling keyboard shortcuts (HumanLayer fork)", + "version": "5.2.5", "sideEffects": false, "repository": { "type": "git", - "url": "https://github.com/JohannesKlauss/react-keymap-hook.git" + "url": "https://github.com/humanlayer/react-hotkeys-hook.git" }, - "homepage": "https://react-hotkeys-hook.vercel.app/", + "homepage": "https://github.com/humanlayer/react-hotkeys-hook", "author": "Johannes Klauss", "type": "module", "main": "packages/react-hotkeys-hook/dist/index.js", @@ -32,7 +32,7 @@ "build": "npm run -w packages/react-hotkeys-hook build", "build:documentation": "npm run -w packages/documentation build", "test": "npm run -w packages/react-hotkeys-hook test", - "prepublishOnly": "npm run test && npm run lint && npm run build", + "prepack": "npm run build", "format": "npx @biomejs/biome format --write packages", "lint": "npx @biomejs/biome lint --write packages" }, @@ -43,6 +43,9 @@ "react": ">=16.8.0", "react-dom": ">=16.8.0" }, + "publishConfig": { + "access": "public" + }, "devDependencies": { "@biomejs/biome": "2.3.11" } diff --git a/packages/react-hotkeys-hook/package.json b/packages/react-hotkeys-hook/package.json index 5b85d066..64f44efb 100644 --- a/packages/react-hotkeys-hook/package.json +++ b/packages/react-hotkeys-hook/package.json @@ -1,6 +1,6 @@ { "name": "react-hotkeys-hook", - "version": "5.2.4", + "version": "5.2.5", "type": "module", "scripts": { "dev": "vite",