chore: Refactor release scripts to create branch and tags

This commit is contained in:
Vikash Kothary 2022-01-16 22:23:51 +00:00
parent 62c6e1a5a1
commit 30fb932127
5 changed files with 72 additions and 40 deletions

View File

@ -36,8 +36,7 @@ init:
@${POETRY} install
.PHONY: release #: Create new Git release and tags.
release:
@${BASH} scripts/release.sh
release: release-branch release-tags
.PHONY: open
open:

View File

@ -1,23 +0,0 @@
#!/bin/bash
# file: prepare-release.sh
# description: Prepare a release branch from develop to master.
## TODO: get package version from pyproject.toml
CURRENT_VERSION=2.2.0
## TODO: get new package version e.g. minor, major, bugfix
LATEST_VERSION=2.3.0
## TODO: ensure you're on the develop branch else fail
## Create release branch
git checkout -b "release/${LATEST_VERSION}" develop
## TODO: bump package version in pyproject.toml
## TODO: commit changes to pyproject.toml
## TODO: generate new CHANGELOG entry from commits
## TODO: commit changes to CHANGELOG
## Push branch and tags
git push origin "release/${LATEST_VERSION}"
## TODO: create PR for review

39
scripts/release-branch.sh Normal file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# file: release-branch.sh
# description: Prepare a release branch from develop to master.
## Build release context as environment variables.
GIT_BRANCH=$(git symbolic-ref --short HEAD)
## TODO: get package version from pyproject.toml
CURRENT_VERSION=v2.2.0
## TODO: get new package version e.g. minor, major, bugfix
NEW_VERSION=v2.3.0
## TODO: ensure you're on the develop branch else fail
if [[ "${GIT_BRANCH}" != "develop" ]]; then
echo 'Please switch to to the develop branch to create a release branch.'
exit 0
fi
## Create release branch
git checkout -b "release/${NEW_VERSION}" develop
## TODO: bump package version in pyproject.toml
## TODO: commit changes to pyproject.toml
## TODO: generate new CHANGELOG entry from commits
## TODO: commit changes to CHANGELOG
## Return to develop
git checkout develop
if [[ -z "${CI}" ]]; then
echo "Please confirm the release branch is correct."
read -p "Press enter to continue"
echo
fi
## Push branch and tags
git push origin "release/${NEW_VERSION}"
## TODO: create PR for review

32
scripts/release-tags.sh Normal file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
# file: release-tags.sh
# description: Automatic consistent release tags following the SemVer convension.
# set -x
# trap read debug
## Build release context as environment variables.
GIT_BRANCH=$(git symbolic-ref --short HEAD)
## TODO: ensure this is the main branch
if [[ "${GIT_BRANCH}" != "main" ]]; then
echo 'Please switch to the main branch to create release tags.'
exit 0
fi
## TODO: get package version from pyproject.toml
CURRENT_VERSION=2.3.0
## Create GitHub Release
git tag -a ${CURRENT_VERSION} -m "v${CURRENT_VERSION}"
if [[ -z "${CI}" ]]; then
echo "Please confirm the release tag is correct."
read -p "Press enter to continue"
echo
fi
git push --tags
## TODO: publish to PyPI.

View File

@ -1,15 +0,0 @@
#!/bin/bash
# file: release.sh
# description: Tag master branch and release to PyPI.
## TODO: ensure this is the master branch
## TODO: get package version from pyproject.toml
CURRENT_VERSION=2.3.0
## Create GitHub Release
git tag -a -m "${CURRENT_VERSION}"
git push --tags
## TODO: publish to PyPI.