Skip to content
Merged
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
38 changes: 37 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ jobs:
runs-on: ubuntu-latest

permissions:
contents: read
contents: write
id-token: write

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

- uses: oven-sh/setup-bun@v2

Expand All @@ -24,8 +26,42 @@ jobs:

- run: bun install --frozen-lockfile

- name: Determine version bump
id: bump
run: |
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
COMMITS=$(git log --format="%s" --no-merges)
else
COMMITS=$(git log "${LAST_TAG}..HEAD" --format="%s" --no-merges)
fi

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

echo "type=$BUMP" >> "$GITHUB_OUTPUT"
echo "Bump type: $BUMP"

- name: Bump version
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
npm version ${{ steps.bump.outputs.type }} --no-git-tag-version
VERSION=$(node -p "require('./package.json').version")
git add package.json
git commit -m "chore: release v${VERSION}"
git tag "v${VERSION}"

- name: Build
run: bun run build

- name: Publish
run: npm publish --access public

- name: Push version bump
run: git push --follow-tags
Loading