code-server/ci/steps/brew-bump.sh

38 lines
1001 B
Bash
Raw Permalink Normal View History

2021-04-01 05:55:43 +08:00
#!/usr/bin/env bash
set -euo pipefail
main() {
# Only sourcing this so we get access to $VERSION
source ./ci/lib.sh
source ./ci/steps/steps-lib.sh
echo "Checking environment variables"
# We need VERSION to bump the brew formula
if ! is_env_var_set "VERSION"; then
echo "VERSION is not set"
exit 1
fi
# We need HOMEBREW_GITHUB_API_TOKEN to push up commits
if ! is_env_var_set "HOMEBREW_GITHUB_API_TOKEN"; then
echo "HOMEBREW_GITHUB_API_TOKEN is not set"
exit 1
fi
2021-04-01 05:55:43 +08:00
# Find the docs for bump-formula-pr here
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/dev-cmd/bump-formula-pr.rb#L18
2021-07-17 06:02:18 +08:00
local output
if ! output=$(brew bump-formula-pr --version="${VERSION}" code-server --no-browse --no-audit --message="PR opened by @${GITHUB_ACTOR}" 2>&1); then
2021-07-17 06:02:18 +08:00
if [[ $output == *"Duplicate PRs should not be opened"* ]]; then
echo "$VERSION is already submitted"
exit 0
2021-07-17 06:02:18 +08:00
else
echo "$output"
exit 1
fi
fi
2021-04-01 05:55:43 +08:00
}
main "$@"