|
2 | 2 | eval "$GLUE_BOOTSTRAP" |
3 | 3 | bootstrap || exit |
4 | 4 |
|
5 | | -# |
6 | | -# glue useAction(util-release-pre.sh) |
7 | | -util.get_action 'util-release-pre.sh' |
8 | | -source "$REPLY" 'notDry' |
9 | | -newVersion="$REPLY" |
10 | | - |
11 | | -# Bash version bump |
12 | | -( |
13 | | - find . -ignore_readdir_race -regex '\./pkg/.*\.\(sh\|bash\)' -print0 \ |
14 | | - | xargs -r0 \ |
15 | | - sed -i -e "s|\(PROGRAM_VERSION=\"\).*\(\"\)|\1${newVersion}\2|g" || : |
16 | | -) || exit |
17 | | - |
18 | | -# glue useAction(util-release-post.sh) |
19 | | -util.get_action 'util-release-post.sh' |
20 | | -source "$REPLY" 'notDry' "$newVersion" |
21 | | - |
22 | | -# glue useAction(result-pacman-package.sh) |
23 | | -util.get_action 'result-pacman-package.sh' |
24 | | -source "$REPLY" |
25 | | - |
26 | | -unset newVersion |
| 5 | +unset task |
| 6 | +task() { |
| 7 | + declare -g RELEASE_STATUS=dry |
| 8 | + for arg; do |
| 9 | + case "$arg" in |
| 10 | + --wet) |
| 11 | + # shellcheck disable=SC2034 |
| 12 | + RELEASE_STATUS=wet |
| 13 | + esac |
| 14 | + done |
| 15 | + |
| 16 | + ensure.cmd 'git' |
| 17 | + ensure.cmd 'gh' |
| 18 | + ensure.file 'glue-auto.toml' |
| 19 | + |
| 20 | + if is.dry_release; then |
| 21 | + log.info "Running pre-release process in dry mode" |
| 22 | + else |
| 23 | + ensure.confirm_wet_release |
| 24 | + fi |
| 25 | + |
| 26 | + # Perform build |
| 27 | + # TODO: perform build on commit hook etc. |
| 28 | + util.get_command 'Bash.build.sh' |
| 29 | + source "$REPLY" |
| 30 | + |
| 31 | + # Ensure tests pass |
| 32 | + util.get_command 'Bash.test.sh' |
| 33 | + source "$REPLY" |
| 34 | + |
| 35 | + # Build docs |
| 36 | + util.get_command 'Bash.docs.sh' |
| 37 | + source "$REPLY" |
| 38 | + |
| 39 | + ensure.git_working_tree_clean |
| 40 | + ensure.git_common_history |
| 41 | + |
| 42 | + local newVersion= |
| 43 | + if is.dry_release; then |
| 44 | + toml.get_key 'version' 'glue-auto.toml' |
| 45 | + newVersion="$REPLY" |
| 46 | + |
| 47 | + ensure.nonZero 'newVersion' "$newVersion" |
| 48 | + else |
| 49 | + toml.get_key 'version' 'glue-auto.toml' |
| 50 | + util.prompt_new_version "$REPLY" |
| 51 | + newVersion="$REPLY" |
| 52 | + |
| 53 | + ensure.nonZero 'newVersion' "$newVersion" |
| 54 | + ensure.version_is_only_major_minor_patch "$newVersion" |
| 55 | + ensure.git_version_tag_validity "$newVersion" |
| 56 | + fi |
| 57 | + |
| 58 | + util.general_version_bump "$newVersion" |
| 59 | + |
| 60 | + ensure.git_working_tree_dirty |
| 61 | + |
| 62 | + if is.dry_release; then |
| 63 | + log.info "Skipping Git taging and artifact release" |
| 64 | + else |
| 65 | + git add -A |
| 66 | + git commit -m "chore(release): v$newVersion" |
| 67 | + git tag -a "v$newVersion" -m "Release $newVersion" HEAD |
| 68 | + git push --follow-tags origin HEAD |
| 69 | + |
| 70 | + local -a args=() |
| 71 | + if [ -f CHANGELOG.md ]; then |
| 72 | + args+=("-F" "CHANGELOG.md") |
| 73 | + elif [ -f changelog.md ]; then |
| 74 | + args+=("-F" "changelog.md") |
| 75 | + else |
| 76 | + # '-F' is required for non-interactivity |
| 77 | + args+=("-F" "") |
| 78 | + log.warn 'CHANGELOG.md file not found. Creating empty notes file for release' |
| 79 | + fi |
| 80 | + |
| 81 | + # Remote Release |
| 82 | + gh release create "v$newVersion" --target main --title "v$newVersion" "${args[@]}" |
| 83 | + fi |
| 84 | + |
| 85 | + # glue useAction(result-pacman-package.sh) |
| 86 | + util.get_action 'result-pacman-package.sh' |
| 87 | + source "$REPLY" |
| 88 | +} |
| 89 | + |
| 90 | +task "$@" |
| 91 | +unset task |
| 92 | + |
27 | 93 | unbootstrap |
0 commit comments