Skip to content

Instantly share code, notes, and snippets.

@fieldju
Last active June 4, 2018 20:56
Show Gist options
  • Save fieldju/cd08e23309397f23e1d807a7beac93a9 to your computer and use it in GitHub Desktop.
Save fieldju/cd08e23309397f23e1d807a7beac93a9 to your computer and use it in GitHub Desktop.
#!/bin/bash
########################################################################################################
# Script for re-releasing tagged measured releases under the new name measured-core
# and deprecating the measured release.
########################################################################################################
function publish {
tag=$1
npm publish --tag measured-legacy || echo "Failed to publish measured-core v${tag}"
}
function deprecate {
tag=$1
echo "Attempting to deprecate measured v${tag}"
msg="This package has been renamed to measured-core, all versions of measured have been re-released under measured-core, please update your package and consider updating to the newest version. See https://github.com/yaorg/node-measured for latest updates."
npm deprecate measured@${tag} "${msg}" || echo "Failed to deprecate measured@${tag}"
}
for tag in $( git tag ); do
echo "Processing tag: '${tag}'"
git reset --hard head
git checkout ${tag}
name=$(cat package.json | jq --raw-output '.name')
version=$(cat package.json | jq --raw-output '.version')
if [ "${name}" = "measured" ]; then
echo "Processing measured version ${version}"
sed -i -e 's/"name": "measured",/"name": "measured-core",/g' package.json
sed -i -e 's/"homepage": "https:\/\/github.com\/felixge\/node-measured",/"homepage": "https:\/\/yaorg.github.io\/node-measured",/g' package.json
sed -i -e 's/"url": "git:\/\/github.com\/felixge\/node-measured.git"/"url": "git:\/\/github.com\/yaorg\/node-measured.git"/g' package.json
read -p "Publish measured-core@${tag} and deprecate measured@${tag}? " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
publish ${version}
deprecate ${version}
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment