Skip to content

Commit

Permalink
Update workflow to use release branches
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkappa committed Jan 13, 2021
1 parent 8582ac9 commit ef80f4e
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions release
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,38 @@

# set -x

# Usage:
#
# release X.X.X
#
# Creates a new version of the package. This script creates a new release branch
# where it updates the version variable. It then creates a matching tag and
# pushes both to GitHub.

# The file holding a version variable.
VERSION_FILE=meta.go

function create_release_branch {
local version="$1"
git checkout -b "releases/${version}"
}

function update_version {
local version="$1"
sed -i.backup "s/var Version =.*/var Version = \"${version}\"/" meta.go
rm -rf meta.go.backup
sed -i.backup "s/var Version =.*/var Version = \"${version}\"/" "${VERSION_FILE}"
rm -rf "${VERSION_FILE}.backup"
}

function commit_changes {
local version="$1"
git add meta.go
git add "${VERSION_FILE}"
git commit -m "v${version}"
git tag -a "v${version}" -m "v${version}"
}

function push_changes {
local version="$1"
git push origin master
git push origin "releases/${version}"
git push origin "v${version}"
}

Expand All @@ -31,9 +47,15 @@ function main {
echo "version $version already exists"
exit 1
fi

local current_branch=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)

create_release_branch $version
update_version $version
commit_changes $version
push_changes $version

git checkout $current_branch
}

main "$@"

0 comments on commit ef80f4e

Please sign in to comment.