-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tim-s-ccs/add-release-scripts
Add the release scripts
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# Check if there are unexpected changes. Changes to CHANGELOG.md and the | ||
# package.json file are expected as part of the normal release process. | ||
changes="$(git status --porcelain -- ':!CHANGELOG.md' ':!package/package.json')" | ||
if [[ -n $changes ]]; then | ||
echo "β Unexpected changes in your working directory:" | ||
echo "$changes" | ||
exit 1 | ||
fi | ||
|
||
echo "Starting to build release..." | ||
echo " " | ||
echo "This will:" | ||
echo "- run the test suite" | ||
echo "- build CCS Frontend into the 'dist/' directory" | ||
echo "- commit all changes and push the branch to remote" | ||
echo " " | ||
|
||
read -r -p "Do you want to continue? [y/N] " continue_prompt | ||
|
||
if [[ $continue_prompt != 'y' ]]; then | ||
echo "Cancelling build, if this was a mistake, try again and use 'y' to continue." | ||
exit 0 | ||
fi | ||
|
||
npm run build | ||
|
||
ALL_PACKAGE_VERSION=$(node -p "require('./package.json').version") | ||
TAG="v$ALL_PACKAGE_VERSION" | ||
CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
if [ $(git tag -l "$TAG") ]; then | ||
echo "β οΈ Git tag $TAG already exists. Check you have updated the version in package/package.json correctly." | ||
exit 1; | ||
else | ||
git add . | ||
git commit -m "Release $TAG" | ||
# set upstream so that we can push the branch up | ||
git push --set-upstream origin $CURRENT_BRANCH_NAME | ||
git push | ||
echo "π All done. Ready to create a pull request. Once approved, run npm run publish-release" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo "Starting a release..." | ||
echo " " | ||
echo "This will:" | ||
echo "- check that you're logged in to npm as the correct user" | ||
echo "- publish the package if it has not been published already" | ||
echo "- check that there is not already a tag published" | ||
echo "- create a new tag" | ||
echo "- push the tag to remote origin" | ||
echo "- create a zip file of the 'dist/' directory locally" | ||
echo " " | ||
|
||
read -r -p "Do you want to continue? [y/N] " continue_prompt | ||
|
||
if [[ $continue_prompt != 'y' ]]; then | ||
echo "Cancelling release, if this was a mistake, try again and use 'y' to continue." | ||
exit 0 | ||
fi | ||
|
||
# echo "Checking that you can publish to npm..." | ||
|
||
# at some point we should create a team and check if user exists in a team | ||
# ! npm team ls developers | grep -q $NPM_USER | ||
|
||
NPM_USER=$(npm whoami) | ||
if ! [ "tim-s-ccs" == "$NPM_USER" ]; then | ||
echo "β οΈ FAILURE: You are not logged in with the correct user." | ||
exit 1 | ||
fi | ||
|
||
echo "π¦ Publishing package..." | ||
|
||
# Try publishing | ||
cd package | ||
npm publish | ||
echo "π Package published!" | ||
cd .. | ||
|
||
# Extract tag version from ./package/package.json | ||
ALL_PACKAGE_VERSION=$(node -p "require('./package.json').version") | ||
TAG="v$ALL_PACKAGE_VERSION" | ||
|
||
if [ $(git tag -l "$TAG") ]; then | ||
echo "β οΈ Tag $TAG already exists" | ||
exit 1 | ||
else | ||
echo "π Tagging repo using tag version: $TAG ..." | ||
git tag $TAG -m "CCS Frontend release $TAG" | ||
git push --tags | ||
echo "π Tag $TAG created and pushed to remote." | ||
|
||
echo "π Creating a release artifact..." | ||
git archive -o ./release-$TAG.zip HEAD:dist | ||
echo "π Artifact created. Now create a release on GitHub and attach this." | ||
fi |