Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
141 additions
and
67 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
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 was deleted.
Oops, something went wrong.
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,68 @@ | ||
#!/bin/bash -eu | ||
|
||
[ "$#" -ne "2" ] && echo "usage: $0 <new version> <release branch name>" && exit 1 | ||
|
||
# stop on first error | ||
set -eu | ||
|
||
# configure git | ||
git config --global user.email "travis@travis-ci.org" | ||
git config --global user.name "Travis CI" | ||
|
||
# setup origin | ||
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" | ||
|
||
# verify same commit as branch | ||
HEAD=$(git rev-parse --verify HEAD) | ||
export GITHUB_BRANCH=$(git ls-remote -q --refs | grep $HEAD | awk '{print $2}' | sed -e 's/^refs\/heads\///') | ||
|
||
C=$(echo $GITHUB_BRANCH | wc -w) | ||
if [ "$C" -ne "1" ]; then echo "Tag cannot be resolved to branch name" && exit 1; fi | ||
|
||
# make sure no stale stuff before checkout | ||
git reset --hard | ||
|
||
# checkout release branch | ||
echo "checkout $2" | ||
git fetch origin > /dev/null 2>&1 | ||
git checkout -B $2 origin/$2 | ||
|
||
# merge develop into release | ||
git merge --no-ff -X ours origin/$GITHUB_BRANCH | ||
|
||
# set version and add all changed POMs and add them to the merge commit | ||
echo "changing version to $1" | ||
mvn org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=$1 -Dtycho.mode=maven | ||
|
||
# Install github_changelog_generator | ||
gem install github_changelog_generator | ||
|
||
# Generate and add CHANGELOG.md | ||
echo "Generating CHANGELOG" | ||
github_changelog_generator -t ${GITHUB_TOKEN} --since-tag 0.12.0.201101081422 | ||
git add CHANGELOG.md | ||
|
||
# commit changes to branch (will be pushed after release) | ||
git commit -a --amend --message "Release $1 [skip ci]" > /dev/null 2>&1 | ||
|
||
# Get latest (soon to be previous) release | ||
previous_release_tag=$(curl -s \ | ||
https://${GITHUB_TOKEN}@api.github.com/repos/${TRAVIS_REPO_SLUG}/releases/latest | \ | ||
jq -r .tag_name) | ||
|
||
# Create release notes | ||
github_changelog_generator -t ${GITHUB_TOKEN} --output /tmp/CHANGELOG-$1.md --since-tag ${previous_release_tag} | ||
export RELEASE_CHANGELOG=$(< /tmp/CHANGELOG-$1.md) | ||
|
||
# move tag to release branch | ||
git tag -a -f $TRAVIS_TAG -m "Release $TRAVIS_TAG" | ||
|
||
# checkout original branch | ||
echo "checkout $GITHUB_BRANCH" | ||
git checkout -B $GITHUB_BRANCH | ||
|
||
# merge back release branch to develop | ||
git merge $2 | ||
|
||
# reset options | ||
set +eu |
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,51 @@ | ||
#!/bin/bash -eu | ||
|
||
[ "$#" -ne "1" ] && echo "usage: $0 <release branch name>" && exit 1 | ||
|
||
# move tag and push release branches | ||
git push https://${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git :refs/tags/$TRAVIS_TAG | ||
git push --quiet --atomic --tags https://${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git $1 | ||
|
||
# Overwrite CHANGELOG.md with JSON data for GitHub API | ||
jq -n \ | ||
--arg body "$RELEASE_CHANGELOG" \ | ||
--arg name "Release $TRAVIS_TAG" \ | ||
--arg tag_name "$TRAVIS_TAG" \ | ||
--arg target_commitish "$1" \ | ||
'{ | ||
body: $body, | ||
name: $name, | ||
tag_name: $tag_name, | ||
target_commitish: $target_commitish, | ||
draft: false, | ||
prerelease: false | ||
}' > /tmp/release.json | ||
|
||
# Create release in github | ||
echo "Create release $TRAVIS_TAG for repo: $TRAVIS_REPO_SLUG, branch: $GITHUB_BRANCH" | ||
upload_url=$(curl -s -H "Authorization: token $GITHUB_TOKEN" --data @/tmp/release.json "https://api.github.com/repos/${TRAVIS_REPO_SLUG}/releases" \ | ||
| jq -r '.upload_url') | ||
|
||
# upload p2 site to release | ||
upload_url="${upload_url%\{*}" | ||
|
||
FILES=./com.basistech.m2e.code.quality.site/target/com.basistech.m2e.code.quality.site-*.zip | ||
for f in $FILES | ||
do | ||
echo "uploading $f to $upload_url" | ||
curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Content-Type: application/zip" \ | ||
--data-binary @"$f" \ | ||
"$upload_url?name=$(basename $f)&label=P2%20Repository" | ||
done | ||
|
||
# increment version | ||
NEW_VERSION=$(echo $TRAVIS_TAG | awk 'BEGIN { FS="." } { $3++; } { printf "%d.%d.%d\n", $1, $2, $3 }')-SNAPSHOT | ||
echo "changing version to $NEW_VERSION" | ||
mvn org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=$NEW_VERSION -Dtycho.mode=maven | ||
|
||
# commit the updated version | ||
git commit -a --message "Next version: $NEW_VERSION" > /dev/null 2>&1 | ||
|
||
# push updated and development branche | ||
git push --quiet https://${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git $GITHUB_BRANCH |
This file was deleted.
Oops, something went wrong.