Skip to content

Commit 1e143e5

Browse files
committed
add release workflow
1 parent 5b2a41d commit 1e143e5

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: oven-sh/setup-bun@v2
15+
16+
- run: bun install
17+
18+
- run: bun run typecheck
19+
20+
- run: bun run build
21+
22+
- run: npm publish --access public
23+
env:
24+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

scripts/release.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
set -e
3+
4+
BUMP_TYPE="${1:-patch}"
5+
6+
if [[ ! "$BUMP_TYPE" =~ ^(patch|minor|major)$ ]]; then
7+
echo "usage: ./scripts/release.sh [patch|minor|major]"
8+
exit 1
9+
fi
10+
11+
CURRENT_VERSION=$(jq -r .version package.json)
12+
echo "current version: $CURRENT_VERSION"
13+
14+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
15+
case "$BUMP_TYPE" in
16+
major) NEW_VERSION="$((MAJOR + 1)).0.0" ;;
17+
minor) NEW_VERSION="$MAJOR.$((MINOR + 1)).0" ;;
18+
patch) NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" ;;
19+
esac
20+
21+
echo "new version: $NEW_VERSION"
22+
23+
jq ".version = \"$NEW_VERSION\"" package.json > package.json.tmp && mv package.json.tmp package.json
24+
25+
git add package.json
26+
git commit -m "v$NEW_VERSION"
27+
git tag "v$NEW_VERSION"
28+
29+
echo ""
30+
echo "created commit and tag v$NEW_VERSION"
31+
echo "run 'git push && git push --tags' to trigger release"

0 commit comments

Comments
 (0)