Skip to content

Commit

Permalink
Merge pull request #167 from tegonal/bc/dont-source-prepare-next
Browse files Browse the repository at this point in the history
don't source prepareNextDevCycle inside function
  • Loading branch information
robstoll authored Mar 13, 2024
2 parents 3a63615 + b858899 commit f94f925
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ It is based on some conventions (see src/releasing/release-files.sh for more det
- expects a version in format vX.Y.Z(-RC...)
- requires you to have a /scripts folder in your project root which contains:
- before-pr.sh which provides a parameterless function `beforePr` and can be sourced (add `${__SOURCED__:+return}` before executing `beforePr`)
- prepare-next-dev-cycle.sh which provides function `prepareNextDevCycle` with parameters `-v` for version
and `-p` for additionalPattern (see source for more detail). Also, this file needs to be sourceable.
- expects that a function `prepareNextDevCycle` with parameters `-v` for version
and `-p` for additionalPattern (see source for more detail) is defined.
Typically, you will use [Prepare Files next dev cycle](#prepare-files-next-dev-cycle) inside which deals with things
like update to SNAPSHOT version in header files etc.
- there is a public key defined at .gt/signing-key.public.asc which will be used
Expand Down Expand Up @@ -938,8 +938,6 @@ Help:
```text
Parameters:
-v The version to release in the format vX.Y.Z(-RC...)
-b|--branch (optional) The expected branch which is currently checked out -- default: main
--project-dir (optional) The projects directory -- default: .
-p|--pattern (optional) pattern which is used in a perl command (separator /) to search & replace additional occurrences. It should define two match groups and the replace operation looks as follows: \${1}$version\${2}
-nv|--next-version (optional) the version to use for prepare-next-dev-cycle -- default: is next minor based on version
Expand All @@ -966,14 +964,14 @@ dir_of_tegonal_scripts="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/nu
source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts"
# 1. git commit all changes and create a tag for v0.1.0
# 2. call scripts/prepare-next-dev-cycle.sh with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# 2. call prepareNextDevCycle with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# 3. git commit all changes as prepare v0.2.0 dev cycle
# 4. push tag and commits
"$dir_of_tegonal_scripts/releasing/release-tag-prepare-next-push.sh" -v v0.1.0
# 1. searches for additional occurrences where the version should be replaced via the specified pattern
# 2. git commit all changes and create a tag for v0.1.0
# 3. call scripts/prepare-next-dev-cycle.sh with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# 3. call prepareNextDevCycle with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# 4. git commit all changes as prepare v0.2.0 dev cycle
# 4. push tag and commits
"$dir_of_tegonal_scripts/releasing/release-tag-prepare-next-push.sh" \
Expand Down
1 change: 1 addition & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if ! [[ -v dir_of_tegonal_scripts ]]; then
fi
sourceOnce "$dir_of_tegonal_scripts/releasing/release-files.sh"
sourceOnce "$dir_of_tegonal_scripts/utility/checks.sh"
sourceOnce "$scriptsDir/prepare-next-dev-cycle.sh"

function release() {
if ! checkCommandExists "shellspec" "please install https://github.com/shellspec/shellspec#installation"; then
Expand Down
2 changes: 0 additions & 2 deletions src/releasing/release-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ function releaseFiles() {
if [[ $prepareOnly != true ]]; then
releaseTagPrepareNextAndPush \
"$versionParamPatternLong" "$version" \
"$branchParamPatternLong" "$branch" \
"$projectsRootDirParamPatternLong" "$projectsRootDir" \
"$additionalPatternParamPatternLong" "$additionalPattern" \
"$nextVersionParamPatternLong" "$nextVersion"
else
Expand Down
4 changes: 2 additions & 2 deletions src/releasing/release-tag-prepare-next-push.doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ dir_of_tegonal_scripts="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/nu
source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts"

# 1. git commit all changes and create a tag for v0.1.0
# 2. call scripts/prepare-next-dev-cycle.sh with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# 2. call prepareNextDevCycle with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# 3. git commit all changes as prepare v0.2.0 dev cycle
# 4. push tag and commits
"$dir_of_tegonal_scripts/releasing/release-tag-prepare-next-push.sh" -v v0.1.0

# 1. searches for additional occurrences where the version should be replaced via the specified pattern
# 2. git commit all changes and create a tag for v0.1.0
# 3. call scripts/prepare-next-dev-cycle.sh with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# 3. call prepareNextDevCycle with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# 4. git commit all changes as prepare v0.2.0 dev cycle
# 4. push tag and commits
"$dir_of_tegonal_scripts/releasing/release-tag-prepare-next-push.sh" \
Expand Down
18 changes: 5 additions & 13 deletions src/releasing/release-tag-prepare-next-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
# source "$dir_of_tegonal_scripts/setup.sh" "$dir_of_tegonal_scripts"
#
# # 1. git commit all changes and create a tag for v0.1.0
# # 2. call scripts/prepare-next-dev-cycle.sh with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# # 2. call prepareNextDevCycle with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# # 3. git commit all changes as prepare v0.2.0 dev cycle
# # 4. push tag and commits
# "$dir_of_tegonal_scripts/releasing/release-tag-prepare-next-push.sh" -v v0.1.0
#
# # 1. searches for additional occurrences where the version should be replaced via the specified pattern
# # 2. git commit all changes and create a tag for v0.1.0
# # 3. call scripts/prepare-next-dev-cycle.sh with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# # 3. call prepareNextDevCycle with nextVersion deduced from the specified version (in this case 0.2.0-SNAPSHOT)
# # 4. git commit all changes as prepare v0.2.0 dev cycle
# # 4. push tag and commits
# "$dir_of_tegonal_scripts/releasing/release-tag-prepare-next-push.sh" \
Expand Down Expand Up @@ -76,12 +76,10 @@ sourceOnce "$dir_of_tegonal_scripts/releasing/update-version-common-steps.sh"
function releaseTagPrepareNextAndPush() {
source "$dir_of_tegonal_scripts/releasing/common-constants.source.sh" || die "could not source common-constants.source.sh"

local version branch projectsRootDir additionalPattern nextVersion
local version additionalPattern nextVersion
# shellcheck disable=SC2034 # is passed by name to parseArguments
local -ra params=(
version "$versionParamPattern" "$versionParamDocu"
branch "$branchParamPattern" "$branchParamDocu"
projectsRootDir "$projectsRootDirParamPattern" "$projectsRootDirParamDocu"
additionalPattern "$additionalPatternParamPattern" "$additionalPatternParamDocu"
nextVersion "$nextVersionParamPattern" "$nextVersionParamDocu"
)
Expand All @@ -90,23 +88,17 @@ function releaseTagPrepareNextAndPush() {

# deduces nextVersion based on version if not already set (and if version set)
source "$dir_of_tegonal_scripts/releasing/deduce-next-version.source.sh"
if ! [[ -v branch ]]; then branch="main"; fi
if ! [[ -v projectsRootDir ]]; then projectsRootDir=$(realpath "."); fi
if ! [[ -v additionalPattern ]]; then additionalPattern="^$"; fi
exitIfNotAllArgumentsSet params "" "$TEGONAL_SCRIPTS_VERSION"

git add . || return $?
git commit -m "$version" || return $?
git tag "$version" || return $?

local -r projectsScriptsDir="$projectsRootDir/scripts"

# shellcheck disable=SC2310 # we are aware of that || will disable set -e for sourceOnce
sourceOnce "$projectsScriptsDir/prepare-next-dev-cycle.sh" || die "could not source prepare-next-dev-cycle.sh"
prepareNextDevCycle -v "$nextVersion" -p "$additionalPattern" || die "could not prepare next dev cycle for version %s" "$nextVersion"

git push origin "$version" || die "could not push tag to origin"
git push || die "could not push commits on %s to origin" "$branch"
git push origin "$version" || die "could not push tag %s to origin" "$version"
git push || die "could not push commits"
}

${__SOURCED__:+return}
Expand Down

0 comments on commit f94f925

Please sign in to comment.