This is part of a library that wants to release builded files (eg
dist/*) when published to npm and bower. However, I don't want to commit those builded files for obvious reasons. Bower uses tags, and so I need tag to hold a version that contains builded files.
I didn't think twice, and that's what I came up with:
#!/bin/bash [[ '' == $1 ]] && echo "Please provide patch, minor, major argument" && exit 1 # build dist files gulp # use npm to get the next semver (ie npm version patch increments patch number) # --no-git-tag-version is to avoid any git interactions newver=$(npm --no-git-tag-version version $1) # dist files are ignored, adding them with the updated package.json git add -f dist package.json # commit and tag the new version with dist files git commit -m $newver git tag $newver # publish on npm npm publish # reset the latest commit git reset --hard HEAD~1 # issue the npm command again so that package.json gets updated newver=$(npm --no-git-tag-version version $1) # only add the package.json, dist files are gone git add package.json # commit and push tags git commit -m $newver git push --tags git push
I'm wondering if this would be considered as a bad-practice, if there is something I could improve, or if someone has a better idea on how to do this. It's working great, but is having a tag that refers to an overridden commit a good idea?