-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: travis commits the snapshot updates (#142)
* build: travis commits the snapshot updates * build: add echos * build: remove echo * build: Upgrade to next snapshot (Build ) * build: update script * revert pom change
- Loading branch information
1 parent
62b2f96
commit 9e1329c
Showing
4 changed files
with
91 additions
and
3 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.iml | ||
.idea | ||
.DS_Store | ||
target | ||
target | ||
pom.xml.versionsBackup |
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
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
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,84 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd `dirname $0`/.. | ||
|
||
setup_git() { | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Travis CI" | ||
} | ||
|
||
update_version() { | ||
|
||
exampleProperty="graphql-kotlin.version" | ||
|
||
# Push the new tag with `-SNAPSHOT` as the current version | ||
mvn --settings .travis/settings.xml org.codehaus.mojo:versions-maven-plugin:2.7:set -DnewVersion="${TRAVIS_TAG}-SNAPSHOT" | ||
|
||
# Increment the patch version | ||
mvn --settings .travis/settings.xml org.codehaus.mojo:versions-maven-plugin:2.7:set -DnextSnapshot=true | ||
|
||
# Pull the value from the pom | ||
NEW_VERSION=$(mvn --settings .travis/settings.xml help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
|
||
# Update the example version | ||
cd example/ | ||
mvn --settings ../.travis/settings.xml org.codehaus.mojo:versions-maven-plugin:2.7:set-property -Dproperty=${exampleProperty} -DnewVersion=${NEW_VERSION} | ||
cd ../ | ||
} | ||
|
||
commit_files() { | ||
|
||
# Use the version as the branch name | ||
git checkout -b ${NEW_VERSION} | ||
|
||
# Stage the modified files | ||
git add pom.xml example/pom.xml | ||
|
||
# Create a new commit with a custom build message and Travis build number for reference | ||
git commit -m "travis: Upgrade to next snapshot (Build $TRAVIS_BUILD_NUMBER)" | ||
} | ||
|
||
upload_files() { | ||
|
||
tokenLink="https://${GITHUB_TOKEN}@github.com/ExpediaDotCom/graphql-kotlin.git" | ||
|
||
# Add new "origin" with access token in the git URL for authentication | ||
git remote add token-origin ${tokenLink} > /dev/null 2>&1 | ||
|
||
# Push changes to the new branch | ||
git push --quiet --set-upstream token-origin ${NEW_VERSION} | ||
|
||
# Remove the origin to hide the token | ||
git remote rm token-origin > /dev/null 2>&1 | ||
} | ||
|
||
if [[ -z "$TRAVIS_TAG" ]] | ||
then | ||
echo "ERROR! Please set TRAVIS_TAG environment variable" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$GITHUB_TOKEN" ]] | ||
then | ||
echo "ERROR! Please set GITHUB_TOKEN environment variable" | ||
exit 1 | ||
fi | ||
|
||
NEW_VERSION="" | ||
|
||
setup_git | ||
|
||
update_version | ||
|
||
commit_files | ||
|
||
# Attempt to push to git only if "git commit" succeeded | ||
if [[ $? -eq 0 ]]; then | ||
echo "Uploading to GitHub" | ||
upload_files | ||
else | ||
echo "Nothing to do" | ||
fi | ||
|
||
|
||
|