-
Notifications
You must be signed in to change notification settings - Fork 4
Add @hawk.so/core to npm publish #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Reversean
wants to merge
3
commits into
docs/core-readme
Choose a base branch
from
ci/core-publish
base: docs/core-readme
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+111
−4
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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/coreon every push tomaster. After the first successful publish, subsequent runs will fail ifpackages/core/package.jsonversion hasn’t been bumped (npm rejects republishing the same version), which would block publishing@hawk.so/javascriptas well.Consider making the core publish step conditional/idempotent (e.g., skip if the version already exists on npm, or only run when
packages/corechanged / its version changed). Alternatively, publish via a tool/process that handles multi-package releases and versioning consistently.There was a problem hiding this comment.
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.