Skip to content

Commit 883c293

Browse files
authored
ci: release script (#182)
Signed-off-by: David Wosk <dwosk@us.ibm.com>
1 parent 36ea33d commit 883c293

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

.github/workflows/publish.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- 'v*.*.*'
77

88
permissions:
9-
contents: read
9+
contents: write
1010
id-token: write
1111

1212
jobs:
@@ -23,3 +23,7 @@ jobs:
2323
- run: npm run build
2424
- run: npm run build:module
2525
- run: npm publish --provenance --access public
26+
- name: Create GitHub Release
27+
env:
28+
GH_TOKEN: ${{ github.token }}
29+
run: gh release create ${{ github.ref_name }} --title "${{ github.ref_name }}" --generate-notes

docs/DEVELOPMENT.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,17 @@ $ npm run test
3636
```shell
3737
$ npm run docs
3838
```
39+
40+
### Releasing
41+
42+
Releases are handled automatically via GitHub Actions. The process works as follows:
43+
44+
1. **Version bumping is automatic** - When you merge a PR to `main`, the `version.yml` workflow analyzes your commit message and bumps the version:
45+
- `feat: ...` → minor bump (0.4.3 → 0.5.0)
46+
- `fix: ...` or other → patch bump (0.4.3 → 0.4.4)
47+
- `breaking change: ...` → major bump (0.4.3 → 1.0.0)
48+
49+
2. **To publish a release**, run the release script after merging:
50+
```shell
51+
$ ./scripts/release.sh
52+
```

scripts/release.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# Get the version from package.json
6+
VERSION=$(node -p "require('./package.json').version")
7+
TAG="v$VERSION"
8+
9+
# Check if we're on main branch
10+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
11+
if [ "$BRANCH" != "main" ]; then
12+
echo "Error: You must be on the main branch to release. Currently on: $BRANCH"
13+
exit 1
14+
fi
15+
16+
# Check for uncommitted changes
17+
if [ -n "$(git status --porcelain)" ]; then
18+
echo "Error: You have uncommitted changes. Please commit or stash them first."
19+
exit 1
20+
fi
21+
22+
# Pull latest changes
23+
echo "Pulling latest changes from main..."
24+
git pull origin main
25+
26+
# Re-read version after pull (in case version.yml updated it)
27+
VERSION=$(node -p "require('./package.json').version")
28+
TAG="v$VERSION"
29+
30+
# Check if tag already exists
31+
if git rev-parse "$TAG" >/dev/null 2>&1; then
32+
echo "Error: Tag $TAG already exists."
33+
exit 1
34+
fi
35+
36+
echo "Creating release for version $VERSION..."
37+
38+
# Create and push the tag
39+
git tag "$TAG"
40+
git push origin "$TAG"
41+
42+
echo ""
43+
echo "Release $TAG triggered successfully!"
44+
echo ""
45+
echo "Follow the publish workflow here:"
46+
echo "https://github.com/IBM/aspera-sdk-js/actions/workflows/publish.yml"

0 commit comments

Comments
 (0)