-
Notifications
You must be signed in to change notification settings - Fork 12
/
release.sh
34 lines (23 loc) · 888 Bytes
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
npm run build:all
npm version --no-git-tag-version patch
version=$(jq -r '.version' package.json)
git add --all
git commit -m "update version in package.json to $version"
echo "Current version: $version"
# Get the previus version Git commit
previousTag=$(git describe --tags --abbrev=0 HEAD^)
echo "Previous version: $previousTag"
# Get the commit messages and hashes since the last tag
commitData=$(git log --pretty=format:"%h %s (%an, %ad)" $previousTag..HEAD)
echo "commit history: $commitData"
# Format the changelog
changelog="# Release $version
$commitData"
# Write the changelog to a file
echo "$changelog" > CHANGELOG.md
# update README with new version
awk -v version="$version" '{gsub(/[0-9]+\.[0-9]+\.[0-9]+/, version)}1' README.md > README.md.tmp
mv README.md.tmp README.md
git add --all
git commit -m "$version" && git tag -a "v$version" -m "$version"