This commit is an initial prototype based on the deployment workflow, using the Azure Code Signing service to sign Windows .exe and .msi files. These changes have been isolated as much as possible to not affect existing deployment workflows while also working around design issues with how GitHub CLI workflow works with GoReleaser and now with ACS support. The biggest smell was over whether to break from using GoReleaser or have GoReleaser control as much about the release process as it has been versus opening / signing / archiving the resulting GoReleaser artifacts; needless to say, the latter was chosen for expedience as well as leaning into officially supported solutions.
120 lines
2.6 KiB
Bash
Executable file
120 lines
2.6 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
print_help() {
|
|
cat <<EOF
|
|
To tag a new release:
|
|
script/release [--staging] <tag-name> [--platform {linux|macos|windows}] [--branch <branch>]
|
|
|
|
To build staging binaries from the current branch:
|
|
script/release --current [--platform {linux|macos|windows}]
|
|
|
|
To build binaries locally with goreleaser:
|
|
script/release --local --platform {linux|macos|windows}
|
|
EOF
|
|
}
|
|
|
|
if [ $# -eq 0 ]; then
|
|
print_help >&2
|
|
exit 1
|
|
fi
|
|
|
|
tag_name=""
|
|
is_local=""
|
|
do_push=""
|
|
platform=""
|
|
branch="trunk"
|
|
deploy_env="production"
|
|
goreleaser_config=".goreleaser.yml"
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
-h | --help )
|
|
print_help
|
|
exit 0
|
|
;;
|
|
-b | --branch )
|
|
branch="$2"
|
|
shift 2
|
|
;;
|
|
-c | --config )
|
|
goreleaser_config="$2"
|
|
shift 2
|
|
;;
|
|
-p | --platform )
|
|
platform="$2"
|
|
shift 2
|
|
;;
|
|
--local )
|
|
is_local=1
|
|
shift 1
|
|
;;
|
|
--staging )
|
|
deploy_env="staging"
|
|
shift 1
|
|
;;
|
|
--current )
|
|
deploy_env="staging"
|
|
tag_name="$(git describe --tags --abbrev=0)"
|
|
branch="$(git rev-parse --symbolic-full-name '@{upstream}' 2>/dev/null || git branch --show-current)"
|
|
branch="${branch#refs/remotes/*/}"
|
|
do_push=1
|
|
shift 1
|
|
;;
|
|
-* )
|
|
printf "unrecognized flag: %s\n" "$1" >&2
|
|
exit 1
|
|
;;
|
|
* )
|
|
tag_name="$1"
|
|
shift 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
announce() {
|
|
local tmpdir="${TMPDIR:-/tmp}"
|
|
echo "$*" | sed "s:${tmpdir%/}:\$TMPDIR:"
|
|
"$@"
|
|
}
|
|
|
|
trigger_deployment() {
|
|
announce gh workflow -R cli/cli run deployment.yml --ref "$branch" -f tag_name="$tag_name" -f environment="$deploy_env"
|
|
}
|
|
|
|
build_local() {
|
|
local config="$goreleaser_config"
|
|
case "$platform" in
|
|
linux )
|
|
sed '/#build:windows/,/^$/d; /#build:macos/,/^$/d' .goreleaser.yml >.goreleaser.generated.yml
|
|
config=".goreleaser.generated.yml"
|
|
;;
|
|
macos )
|
|
sed '/#build:windows/,/^$/d; /#build:linux/,/^$/d' .goreleaser.yml >.goreleaser.generated.yml
|
|
config=".goreleaser.generated.yml"
|
|
;;
|
|
windows )
|
|
sed '/#build:linux/,/^$/d; /#build:macos/,/^$/d' .goreleaser.yml >.goreleaser.generated.yml
|
|
config=".goreleaser.generated.yml"
|
|
;;
|
|
esac
|
|
[ -z "$tag_name" ] || export GORELEASER_CURRENT_TAG="$tag_name"
|
|
announce goreleaser release -f "$config" --clean --skip-validate --skip-publish --release-notes="$(mktemp)"
|
|
}
|
|
|
|
if [ -n "$is_local" ]; then
|
|
build_local
|
|
else
|
|
if [ -n "$do_push" ]; then
|
|
if ! git diff --quiet || ! git diff --cached --quiet; then
|
|
echo "refusing to continue due to uncomitted local changes" >&2
|
|
exit 1
|
|
fi
|
|
announce git push
|
|
fi
|
|
trigger_deployment
|
|
if [ "$deploy_env" = "production" ]; then
|
|
echo
|
|
echo "Go to Slack to manually approve this production deployment."
|
|
fi
|
|
fi
|