Skip to content

Instantly share code, notes, and snippets.

@JeffreyMFarley
Last active October 13, 2017 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffreyMFarley/d8d736abbe100222e87df2b78a8c7ef4 to your computer and use it in GitHub Desktop.
Save JeffreyMFarley/d8d736abbe100222e87df2b78a8c7ef4 to your computer and use it in GitHub Desktop.
pu.sh (infinite loop version)
#!/bin/sh
setup_git() {
# Set the user name and email to match the API token holder
# This will make sure the git commits will have the correct photo
# and the user gets the credit for a checkin
git config --global user.email "foo@users.noreply.github.com"
git config --global user.name "foo"
git config --global push.default matching
# Get the credentials from a file
git config credential.helper "store --file=.git/credentials"
# This associates the API Key with the account
echo "https://${GITHUB_API_KEY}:@github.com" > .git/credentials
}
make_version() {
# Make sure that the workspace is clean
# It could be "dirty" if
# 1. package-lock.json is not aligned with package.json
# 2. npm install is run
git checkout -- .
# Echo the status to the log so that we can see it is OK
git status
# Run the deploy build and increment the package versions
# %s is the placeholder for the created tag
npm version patch -m "chore: release version %s"
}
upload_files() {
# This make sure the current work area is pushed to the tip of the current branch
git push origin HEAD:$TRAVIS_BRANCH
# This pushes the new tag
git push --tags
}
setup_git
make_version
upload_files
@JeffreyMFarley
Copy link
Author

To avoid an infinite loop, line 31 should look like:

npm version patch -m "chore: release version %s [skip ci]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment