Add multi-module release launcher example
This commit is contained in:
48
examples/multi-module/release.sh
Executable file
48
examples/multi-module/release.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
usage() {
|
||||
echo "usage: release.sh SELECTOR VERSION" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
[ "$#" -eq 2 ] || usage
|
||||
selector=$1
|
||||
version=$2
|
||||
script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
|
||||
repository_dir=$(git -C "$script_dir" rev-parse --show-toplevel)
|
||||
|
||||
bootstrap_dir=$(mktemp -d "$(dirname "$repository_dir")/.releasekit-bootstrap.XXXXXX")
|
||||
selection_file=$bootstrap_dir/module-selection.tsv
|
||||
trap 'rm -rf "$bootstrap_dir"' EXIT
|
||||
"$script_dir/select-module.sh" selector "$selector" > "$selection_file"
|
||||
|
||||
tab=$(printf '\t')
|
||||
IFS="$tab" read -r selected_selector tag_pattern module_dir profile_path < "$selection_file"
|
||||
module_path=$repository_dir
|
||||
if [ "$module_dir" != . ]; then
|
||||
module_path=$repository_dir/$module_dir
|
||||
fi
|
||||
|
||||
cp "$module_path/go.mod" "$bootstrap_dir/releasekit.mod"
|
||||
if [ -f "$module_path/go.sum" ]; then
|
||||
cp "$module_path/go.sum" "$bootstrap_dir/releasekit.sum"
|
||||
else
|
||||
: > "$bootstrap_dir/releasekit.sum"
|
||||
fi
|
||||
|
||||
releasekit_module=gitea.maximumdirect.net/eric/ReleaseKit
|
||||
(
|
||||
cd "$module_path"
|
||||
export GOWORK=off
|
||||
export GOTOOLCHAIN=local
|
||||
go list -mod=mod -modfile="$bootstrap_dir/releasekit.mod" -m "$releasekit_module"
|
||||
go build -mod=mod -modfile="$bootstrap_dir/releasekit.mod" \
|
||||
-o "$bootstrap_dir/releasekit" "$releasekit_module/cmd/releasekit"
|
||||
)
|
||||
|
||||
"$bootstrap_dir/releasekit" publish \
|
||||
--repo "$repository_dir" \
|
||||
--config "$profile_path" \
|
||||
--expected-module "$module_dir" \
|
||||
"$version"
|
||||
Reference in New Issue
Block a user