2021-03-31 23:55:43 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
main() {
|
|
|
|
# Only sourcing this so we get access to $VERSION
|
|
|
|
source ./ci/lib.sh
|
2021-09-24 01:08:28 +02:00
|
|
|
source ./ci/steps/steps-lib.sh
|
|
|
|
|
|
|
|
echo "Checking environment variables"
|
|
|
|
|
|
|
|
# We need VERSION to bump the brew formula
|
2022-01-12 23:51:11 +01:00
|
|
|
if ! is_env_var_set "VERSION"; then
|
2021-09-24 01:08:28 +02:00
|
|
|
echo "VERSION is not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# We need HOMEBREW_GITHUB_API_TOKEN to push up commits
|
2022-01-12 23:51:11 +01:00
|
|
|
if ! is_env_var_set "HOMEBREW_GITHUB_API_TOKEN"; then
|
2021-09-24 01:08:28 +02:00
|
|
|
echo "HOMEBREW_GITHUB_API_TOKEN is not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-05-21 23:56:01 +02:00
|
|
|
|
2021-03-31 23:55:43 +02: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 00:02:18 +02:00
|
|
|
local output
|
2022-07-15 18:24:33 +02:00
|
|
|
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 00:02:18 +02:00
|
|
|
if [[ $output == *"Duplicate PRs should not be opened"* ]]; then
|
|
|
|
echo "$VERSION is already submitted"
|
2022-03-22 00:57:36 +01:00
|
|
|
exit 0
|
2021-07-17 00:02:18 +02:00
|
|
|
else
|
|
|
|
echo "$output"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2021-03-31 23:55:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|