Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Vannsl/cc07eb260721a4e6aa2715e11359178e to your computer and use it in GitHub Desktop.
Save Vannsl/cc07eb260721a4e6aa2715e11359178e to your computer and use it in GitHub Desktop.
release.sh
#!/bin/bash
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# initialize develop and master branch names
devBranch=develop
masterBranch=master
# update develop branch
git pull origin $devBranch
# make sure you're in master branch
git checkout $masterBranch
git pull origin $masterBranch
# make sure master branch is up to date
git merge $devBranch --no-ff
git push
# initiliaze version names (with and without v)
# (make sure to have "version": "echo $npm_package_version" in your package.json scripts)
versionLabel=$(npm run version --silent)
prefixedVersionLabel=v$versionLabel
# initiliaze release branch
releaseBranch=release-$versionLabel
# create the release branch from the master branch
git checkout -b $releaseBranch $masterBranch
# run build process (feel free to change)
npm run build
# add files to publish (feel free to change)
git add .
# commit
git commit -m "create version $versionLabel"
# create tag
git tag -a $prefixedVersionLabel -m "version $versionLabel"
# push tags
git push --tags
# switch to branch master
git checkout $masterBranch
# delete branch
git branch -D $releaseBranch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment