Skip to content

Commit

Permalink
Add gitattributes and release.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
yinfuyuan committed Dec 22, 2020
1 parent 18f415b commit 7bacb8a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
* text=auto

*.md diff=markdown
*.php diff=php

/.github export-ignore
/bin export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
phpunit.xml export-ignore
psalm.xml export-ignore
52 changes: 52 additions & 0 deletions bin/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

set -e

# Make sure the release tag is provided.
if (( "$#" != 1 ))
then
echo "Tag has to be provided."

exit 1
fi

RELEASE_BRANCH="master"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
VERSION=$1

# Make sure current branch and release branch match.
if [[ "$RELEASE_BRANCH" != "$CURRENT_BRANCH" ]]
then
echo "Release branch ($RELEASE_BRANCH) does not match the current active branch ($CURRENT_BRANCH)."

exit 1
fi

# Make sure the working directory is clear.
if [[ ! -z "$(git status --porcelain)" ]]
then
echo "Your working directory is dirty. Did you forget to commit your changes?"

exit 1
fi

# Make sure latest changes are fetched first.
git fetch origin

# Make sure that release branch is in sync with origin.
if [[ $(git rev-parse HEAD) != $(git rev-parse origin/$RELEASE_BRANCH) ]]
then
echo "Your branch is out of date with its upstream. Did you forget to pull or push any changes before releasing?"

exit 1
fi

# Always prepend with "v"
if [[ $VERSION != v* ]]
then
VERSION="v$VERSION"
fi

# Tag PHPEnum
git tag $VERSION
git push origin --tags

0 comments on commit 7bacb8a

Please sign in to comment.