Improve bump script with positional arguments (#957)

Get rid of the messy `bump*.sh` scripts variants with a single one with
positional arguments (all optional):

- -v: the new version number (default: current)
- -b: the new build number (default: current + 1)
- -s: the initial build for the CHANGELOG diff (default: latest tag)
- -na: do not update the API (default: do update it)
- -nl: do not update the CHANGELOG (default: present editor)
- -d: dry run

Fixes #948
This commit is contained in:
Davide 2024-11-27 17:08:00 +01:00 committed by GitHub
parent 8f778faa5d
commit 2de5aad093
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 70 additions and 27 deletions

View File

@ -1,5 +0,0 @@
#!/bin/sh
if [ ! -z $1 ]; then
BUILD="build:$1"
fi
bundle exec fastlane bump $BUILD only:true

View File

@ -1,5 +0,0 @@
#!/bin/sh
if [ ! -z $1 ]; then
SINCE="since:$1"
fi
bundle exec fastlane bump $SINCE

View File

@ -1,10 +0,0 @@
#!/bin/sh
if [ -z $1 ]; then
echo "Version number required"
exit 1
fi
if [ ! -z $2 ]; then
BUILD="build:$2"
fi
VERSION="version:$1"
bundle exec fastlane bump $VERSION $BUILD

View File

@ -1,5 +1,67 @@
#!/bin/sh #!/bin/bash
if [ ! -z $1 ]; then # https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
BUILD="build:$1"
POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-v)
OPT_VERSION="version:$2"
shift # past argument
shift # past value
;;
-b)
OPT_BUILD="build:$2"
shift # past argument
shift # past value
;;
-s)
OPT_SINCE="since:$2"
shift # past argument
shift # past value
;;
-na)
OPT_NO_API=1
shift # past argument
;;
-nl)
OPT_NO_LOG="no_log:true"
shift # past argument
;;
-d)
OPT_DRY_RUN=1
shift # past argument
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
CMD_API=$(dirname "$0")/update-bundled-api.sh
CMD_FASTLANE="bundle exec fastlane bump $OPT_VERSION $OPT_BUILD $OPT_SINCE $OPT_NO_LOG"
if [[ -n $OPT_DRY_RUN ]]; then
echo "VERSION = $OPT_VERSION"
echo "BUILD = $OPT_BUILD"
echo "SINCE = $OPT_SINCE"
echo "NO_API = $OPT_NO_API"
echo "NO_LOG = $OPT_NO_LOG"
if [[ -z $OPT_NO_API ]]; then
echo "$CMD_API"
fi
echo "$CMD_FASTLANE"
exit 0
fi fi
bundle exec fastlane bump $BUILD
if [[ -z $OPT_NO_API ]]; then
eval "$CMD_API"
fi
eval "$CMD_FASTLANE"

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
DESTINATION="Passepartout/Library/Sources/APILibrary/API" DESTINATION="Passepartout/Library/Sources/CommonAPI/API"
API_VERSION="v5" API_VERSION="v5"
mkdir tmp mkdir tmp

View File

@ -18,13 +18,14 @@ fastlane_require "fileutils"
Dotenv.load ".env.secret" Dotenv.load ".env.secret"
setup_ci if ENV["CI"] setup_ci if ENV["CI"]
api = "Passepartout/Library/Sources/CommonAPI/API"
logname = "CHANGELOG.txt" logname = "CHANGELOG.txt"
build_path = "build" build_path = "build"
derived_data_path = "build/derived_data" derived_data_path = "build/derived_data"
desc "Bump version" desc "Bump version"
lane :bump do |options| lane :bump do |options|
unless options[:only] unless options[:no_log]
if options[:since] if options[:since]
between = [options[:since], "HEAD"] between = [options[:since], "HEAD"]
else else
@ -55,7 +56,7 @@ lane :bump do |options|
end end
commit_version_bump( commit_version_bump(
message: "Bump version", message: "Bump version",
include: [logname] include: [api, logname]
) )
add_git_tag( add_git_tag(
includes_lane: false, includes_lane: false,