Skip to content

Commit

Permalink
Make update_changelog.mjs script
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Sep 10, 2024
1 parent 489c582 commit b394f40
Show file tree
Hide file tree
Showing 4 changed files with 683 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
"lint:tests": "eslint tests/**/*.js --ignore-pattern '/tests/performance/bundle*'",
"list": "node scripts/list-npm-scripts.mjs",
"prepublishOnly": "npm run build:all",
"releases:changelog": "./scripts/update_changelog.mjs",
"releases:demo": "./scripts/update_gh-pages_demo",
"releases:dev": "./scripts/make-dev-releases",
"releases:doc": "./scripts/update_gh-pages_doc",
Expand Down
71 changes: 67 additions & 4 deletions scripts/make-dev-releases
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,19 @@ fi

current_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
date=$(date "+%Y%m%d")
dev_branch="release/v${version}-dev.${date}${incr}"
canal_branch="release/v${version}-canal.${date}${incr}"
dev_version="${version}-dev.${date}${incr}"
canal_version="${version}-canal.${date}${incr}"
dev_branch="release/v${dev_version}"
canal_branch="release/v${canal_version}"

if [ -n "$(git status --porcelain doc)" ]; then
echo "ERROR: Please commit your modifications to \"${current_branch}\" first"
exit 1
fi

echo "This script will create the dev versions: $dev_version and $canal_version"

echo "checking that the branches do not already exist locally or remotely..."
if ! [ -z $(git branch --list "$dev_branch") ]; then
err "Branch name "$dev_branch" already exists locally. Please delete it first."
fi
Expand All @@ -78,14 +88,67 @@ if ! [ -z $(git ls-remote --heads [email protected]:canalplus/rx-player.git "refs/h
err "Branch name "$canal_branch" already exists remotely. Please delete it first."
fi

if npm view rx-player@$version-dev.${date}${incr} >/dev/null 2>&1; then
echo "checking that the versions are not already published on npm..."
if npm view rx-player@$dev_version >/dev/null 2>&1; then
err "Version already published to npm: $version-dev.${date}${incr}"
fi

if npm view rx-player@$version-canal.${date}${incr} >/dev/null 2>&1; then
if npm view rx-player@$canal_version >/dev/null 2>&1; then
err "Version already published to npm: $version-canal.${date}${incr}"
fi

# Make dev Changelog
npm run releases:changelog -- $dev_version -d

$EDITOR CHANGELOG.md

if [ -n "$(git status --porcelain CHANGELOG.md)" ]; then
echo "-- Current CHANGELOG.md Status: --"
echo ""
git status CHANGELOG.md

while :; do
echo ""
echo "We will push this CHANGELOG.md update to ${current_branch}."
read -p "do you want to continue [y/d/s/a/c/t/h] (h for help) ? " -n1 REPLY
echo ""

if [[ $REPLY =~ ^[Hh](elp)?$ ]]; then
echo ""
echo ""
echo "+- help -------------------------------------------------+"
echo "| y: commit and continue |"
echo "| d: see diff |"
echo "| s: see status |"
echo "| a: abort script from here |"
echo "| c: skip CHANGELOG.md update and go to the next step |"
echo "| h: see this help |"
echo "+--------------------------------------------------------+"
elif [[ $REPLY =~ ^[Yy](es)?$ ]]; then
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md for v$dev_version"
git push [email protected]:canalplus/rx-player.git $current_branch
break
elif [[ $REPLY =~ ^[Dd](iff)?$ ]]; then
git diff CHANGELOG.md || true # ignore when return 1
elif [[ $REPLY =~ ^[Ss](tatus)?$ ]]; then
git status CHANGELOG.md
elif [[ $REPLY =~ ^[Aa](bort)?$ ]]; then
echo "exiting"
exit 0
elif [[ $REPLY =~ ^[Cc](heckout)?$ ]]; then
git checkout CHANGELOG.md
else
echo "invalid input"
fi
done
fi

if [ -n "$(git status --porcelain doc)" ]; then
echo "ERROR: Unexpected diff in \"${current_branch}\""
exit 1
fi

git checkout -b ${dev_branch}
./scripts/update-version $version-dev.${date}${incr}
git add --all
Expand Down
57 changes: 57 additions & 0 deletions scripts/make-official-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ if [ -n "$(git status --porcelain)" ]; then
err "Please commit your modifications first"
fi

echo "Checking current branch is synchronized with remote..."
check_branch_synchronized_with_remote

if [ $# -eq 0 ]; then
Expand All @@ -97,6 +98,9 @@ else
version=$1
fi

emphasized_log "This script will create the official version: $version"

echo "checking that the branche does not already exist locally or remotely..."
if ! [ -z $(git branch --list "release/v$version") ]; then
err "Branch name "release/v$version" already exists locally. Please delete it first."
fi
Expand All @@ -105,6 +109,7 @@ if ! [ -z $(git ls-remote --heads [email protected]:canalplus/rx-player.git "refs/h
err "Branch name "release/v$version" already exists remotely. Please delete it first."
fi

echo "checking that the version are not already published on npm..."
if npm view rx-player@$version >/dev/null 2>&1; then
err "Version already published to npm: $version"
fi
Expand All @@ -129,6 +134,58 @@ if [ -n "$(git status --porcelain)" ]; then
err "Error after doing rebases: updated files"
fi

# Make Changelog
npm run releases:changelog -- $version

$EDITOR CHANGELOG.md

if [ -n "$(git status --porcelain CHANGELOG.md)" ]; then
echo "-- Current CHANGELOG.md Status: --"
echo ""
git status CHANGELOG.md

while :; do
echo ""
echo "We will push this CHANGELOG.md update to $base_branch."
read -p "do you want to continue [y/d/s/a/c/t/h] (h for help) ? " -n1 REPLY
echo ""

if [[ $REPLY =~ ^[Hh](elp)?$ ]]; then
echo ""
echo ""
echo "+- help -------------------------------------------------+"
echo "| y: commit and continue |"
echo "| d: see diff |"
echo "| s: see status |"
echo "| a: abort script from here |"
echo "| c: skip CHANGELOG.md update and go to the next step |"
echo "| h: see this help |"
echo "+--------------------------------------------------------+"
elif [[ $REPLY =~ ^[Yy](es)?$ ]]; then
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md for v$version"
git push [email protected]:canalplus/rx-player.git $base_branch
break
elif [[ $REPLY =~ ^[Dd](iff)?$ ]]; then
git diff CHANGELOG.md || true # ignore when return 1
elif [[ $REPLY =~ ^[Ss](tatus)?$ ]]; then
git status CHANGELOG.md
elif [[ $REPLY =~ ^[Aa](bort)?$ ]]; then
echo "exiting"
exit 0
elif [[ $REPLY =~ ^[Cc](heckout)?$ ]]; then
git checkout CHANGELOG.md
else
echo "invalid input"
fi
done
fi

if [ -n "$(git status --porcelain doc)" ]; then
echo "ERROR: Unexpected diff in \"$base_branch\""
exit 1
fi

emphasized_log "Creating \"release/v$version\" branch..."
git checkout -b "release/v$version"

Expand Down
Loading

0 comments on commit b394f40

Please sign in to comment.