Skip to content
Open
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
88 changes: 88 additions & 0 deletions .github/workflows/bump-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Bump package version

on:
workflow_call:
inputs:
workspace:
required: true
type: string
description: 'Yarn workspace name'
path:
required: true
type: string
description: 'Package directory relative to repo root'

jobs:
bump:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Check if package was modified and version needs bump
id: check
run: |
# Exit cleanly if the package directory was not touched in this PR
if git diff --quiet ${{ github.event.pull_request.base.sha }} HEAD -- ${{ inputs.path }}; then
echo "No changes detected in ${{ inputs.path }}."
echo "should-bump=false" >> $GITHUB_OUTPUT
exit 0
fi

# Compare old (base) and new (HEAD) version strings
OLD_VERSION=$(git show ${{ github.event.pull_request.base.sha }}:${{ inputs.path }}/package.json | jq -r '.version')
NEW_VERSION=$(jq -r '.version' ${{ inputs.path }}/package.json)

if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
echo "Version already bumped by developer ($OLD_VERSION → $NEW_VERSION)."
echo "should-bump=false" >> $GITHUB_OUTPUT
exit 0
fi

echo "should-bump=true" >> $GITHUB_OUTPUT

- name: Determine bump level from conventional commits
id: level
if: steps.check.outputs.should-bump == 'true'
run: |
# Gather full commit messages (subject + body) only for commits touching this package
COMMITS=$(git log ${{ github.event.pull_request.base.sha }}..HEAD --format=%B -- ${{ inputs.path }})

if echo "$COMMITS" | grep -qE '^[a-z]+(\([^)]+\))?!:'; then
LEVEL=major
elif echo "$COMMITS" | grep -qE 'BREAKING[- ]CHANGE'; then
LEVEL=major
elif echo "$COMMITS" | grep -qE '^feat(\([^)]*\))?:'; then
LEVEL=minor
else
LEVEL=patch
fi

echo "level=$LEVEL" >> $GITHUB_OUTPUT
echo "Bumping ${{ inputs.workspace }} with $LEVEL level"

- uses: actions/setup-node@v4
if: steps.check.outputs.should-bump == 'true'
with:
node-version-file: '.nvmrc'

- run: corepack enable
if: steps.check.outputs.should-bump == 'true'

- run: yarn
if: steps.check.outputs.should-bump == 'true'

- name: Bump ${{ inputs.workspace }} version
if: steps.check.outputs.should-bump == 'true'
run: yarn workspace ${{ inputs.workspace }} version ${{ steps.level.outputs.level }}

- uses: EndBug/add-and-commit@v9
if: steps.check.outputs.should-bump == 'true'
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
message: 'chore: bump ${{ inputs.workspace }} version'
pull: '--rebase --autostash'
16 changes: 16 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Bump version in PR

on: [pull_request]

jobs:
bump-version-core:
uses: ./.github/workflows/bump-package.yml
with:
workspace: '@hawk.so/core'
path: packages/core

bump-version-javascript:
uses: ./.github/workflows/bump-package.yml
with:
workspace: '@hawk.so/javascript'
path: packages/javascript
7 changes: 5 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
Expand All @@ -18,14 +18,17 @@ jobs:
- run: yarn
- run: yarn lint-test
- run: yarn build:all
- run: yarn workspace @hawk.so/core npm publish --access=public
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow now always attempts to publish @hawk.so/core on every push to master. After the first successful publish, subsequent runs will fail if packages/core/package.json version hasn’t been bumped (npm rejects republishing the same version), which would block publishing @hawk.so/javascript as well.

Consider making the core publish step conditional/idempotent (e.g., skip if the version already exists on npm, or only run when packages/core changed / its version changed). Alternatively, publish via a tool/process that handles multi-package releases and versioning consistently.

Suggested change
- run: yarn workspace @hawk.so/core npm publish --access=public
- name: Check whether @hawk.so/core version is already published
id: core_publish_check
run: |
PACKAGE_NAME=$(node -p "require('./packages/core/package.json').name")
PACKAGE_VERSION=$(node -p "require('./packages/core/package.json').version")
if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version >/dev/null 2>&1; then
echo "should_publish=false" >> "$GITHUB_OUTPUT"
else
echo "should_publish=true" >> "$GITHUB_OUTPUT"
fi
- if: steps.core_publish_check.outputs.should_publish == 'true'
run: yarn workspace @hawk.so/core npm publish --access=public

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added version auto-bump on PR. Bump level determined by commit message.

env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn workspace @hawk.so/javascript npm publish --access=public
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
notify:
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Get package info
id: package
uses: codex-team/action-nodejs-package-info@v1
Expand Down
4 changes: 2 additions & 2 deletions packages/javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hawk.so/javascript",
"version": "3.2.22",
"version": "3.2.23",
"description": "JavaScript errors tracking for Hawk.so",
"files": [
"dist"
Expand Down Expand Up @@ -40,10 +40,10 @@
},
"homepage": "https://github.com/codex-team/hawk.javascript#readme",
"dependencies": {
"@hawk.so/core": "workspace:^",
"error-stack-parser": "^2.1.4"
},
"devDependencies": {
"@hawk.so/core": "workspace:^",
"@hawk.so/types": "0.5.8",
"@vitest/coverage-v8": "^4.0.18",
"jsdom": "^28.0.0",
Expand Down