-
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
base: docs/core-readme
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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' | ||
| 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 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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' | ||||||||||||||||||||||||||||||
|
|
@@ -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 | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| - 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 |
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.
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.
seems like over engineered. Just always bump patch version. Others will be bumped manually by developer.