Skip to content

Commit

Permalink
Use @valu/npm-tools in release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
esamattis committed Nov 18, 2022
1 parent 14e4a2a commit ab62791
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 134 deletions.
28 changes: 1 addition & 27 deletions prerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,4 @@

set -eu


if [ "${1:-}" != "" ]; then
cd "packages/$1"
fi

pkg="$(basename $(pwd))"

if [ "$(git rev-parse --show-toplevel)" = "$(pwd)" ]; then
echo "prerelease.sh must be run from the packge dir"
fi

if [ ! -f package.json ]; then
echo
echo "No package.json at $(pwd)"
echo
exit 1
fi


if [ "$(git status . --porcelain)" != "" ]; then
echo
echo "Dirty git. Commit changes"
echo
exit 1
fi

git push -f origin HEAD:release/$pkg/prerelease
exec "$(git rev-parse --show-toplevel)/packages/npm-tools/scripts/valu-npm-prerelease"
108 changes: 1 addition & 107 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,4 @@

set -eu

changelog=true

if [ "${1:-}" != "" ]; then
cd "packages/$1"
fi

pkg="$(basename $(pwd))"

if [ "$(git rev-parse --show-toplevel)" = "$(pwd)" ]; then
echo "release.sh must be run from the packge dir"
fi

if [ ! -f package.json ]; then
echo
echo "No package.json at $(pwd)"
echo
exit 1
fi


if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo
echo "Not on the master branch"
echo
exit 2
fi

if [ "$(git status . --porcelain)" != "" ]; then
echo
echo "Dirty git. Commit changes"
echo
exit 1
fi


git fetch origin

if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/master)" ]; then
echo
echo "Repository not up to date. Do your git push/pull/rebase dance"
echo
exit 1
fi

npm test

current_version="$(jq -r .version package.json)"

echo "Current version is: $current_version"

read -p "New version> " new_version

if [ "$new_version" = "" ]; then
echo "Bad version"
exit 1
fi

if $changelog; then
prev_tag="$(git describe --abbrev=0 --match "$pkg/v*" || true)"

tmp_changelog=changelog_entry.md

echo "## v$new_version" > "$tmp_changelog"
echo >> "$tmp_changelog"
date +'%Y-%m-%d' >> "$tmp_changelog"
echo >> "$tmp_changelog"
git log --format='- %s [%h](https://github.com/valu-digital/npm-packages/commit/%h) - %an' HEAD...$prev_tag . >> "$tmp_changelog"
echo >> "$tmp_changelog"

if [ -f CHANGELOG.md ]; then
cat CHANGELOG.md >> $tmp_changelog
fi

mv $tmp_changelog CHANGELOG.md

while true; do
echo
echo
echo "----------------------------------------------------------------------"
git diff
echo "----------------------------------------------------------------------"
echo
echo
echo "👆 The CHANGELOG.md file was updated automatically."
echo
echo "Type 'e' to edit in vscode and 'c' to commit and continue"
read -p "> " changelog_mode

if [ "$changelog_mode" = "e" ]; then
code CHANGELOG.md
fi

if [ "$changelog_mode" = "c" ]; then
break
fi
done

if [ "$(git status . --porcelain)" != "" ]; then
git add CHANGELOG.md
git commit -m "Update changelog for $pkg v$new_version"
git push origin master:master
fi
fi


git push origin master:master
git push -f origin master:release/$pkg/$new_version
exec "$(git rev-parse --show-toplevel)/packages/npm-tools/scripts/valu-npm-release"

0 comments on commit ab62791

Please sign in to comment.