Skip to content

Commit

Permalink
Check duplication and update existing PR (#9)
Browse files Browse the repository at this point in the history
* Check duplication

* Update PR if exists
  • Loading branch information
at-wat authored Jan 4, 2020
1 parent 9a4fc1f commit 3ac7c17
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ then
INPUT_VERSION=$(echo ${INPUT_ISSUE_TITLE} | sed -e 's/^Release \(.*\)$/\1/')
fi

# Check duplication
if ! git ls-remote --exit-code origin ${version}
then
echo "Release already exists. Nothing to do." >&2
exit 0
fi

update=false
if ! git ls-remote --exit-code origin release-${version}
then
echo "Release candidate branch already exists. Updating." >&2
update=true
fi

# Setup
echo -e "machine github.com\nlogin ${INPUT_GITHUB_TOKEN}" > ~/.netrc
Expand All @@ -27,11 +40,24 @@ git config user.email ${INPUT_GIT_EMAIL}
# Fetch all history to generate changelog
git fetch --tags --prune --unshallow

git checkout -b release-${INPUT_VERSION}

# Update CHANGELOG
catkin_generate_changelog -y

if update
then
# Store updated CHANGELOGs
git stash

# Update release candidate branch
git checkout release-${INPUT_VERSION}
git merge --no-edit ${GITHUB_REF}

# Overwrite CHANGELOGs
git checkout stash@{0} $(find . -name CHANGELOG.rst)
else
git checkout -b release-${INPUT_VERSION}
fi

# Fix RST format
sed '/^Forthcoming/,/[0-9]\+\.[0-9]\+\.[0-9]\+/{/^ /d}' \
-i $(find . -name CHANGELOG.rst)
Expand Down

0 comments on commit 3ac7c17

Please sign in to comment.