2
2
set -euo pipefail
3
3
4
4
main () {
5
- cd " $( dirname " $0 " ) /../.."
5
+ REPO=" homebrew-core"
6
+ GITHUB_USERNAME=" cdrci"
7
+ UPSTREAM_USERNAME_AND_REPO=" Homebrew/$REPO "
6
8
# Only sourcing this so we get access to $VERSION
7
- source ./ci/ lib.sh
8
- source ./ci/steps/ steps-lib.sh
9
+ source ./lib.sh
10
+ source ./steps-lib.sh
9
11
10
12
echo " Checking environment variables"
11
13
@@ -22,17 +24,17 @@ main() {
22
24
fi
23
25
24
26
# Make sure the git clone step is successful
25
- if ! directory_exists " homebrew-core " ; then
26
- echo " git clone failed. Cannot find homebrew-core directory."
27
+ if ! directory_exists " $REPO " ; then
28
+ echo " git clone failed. Cannot find $REPO directory."
27
29
ls -la
28
30
exit 1
29
31
fi
30
32
31
- echo " Changing into homebrew-core directory"
32
- pushd homebrew-core && pwd
33
+ echo " Changing into $REPO directory"
34
+ pushd " $REPO " && pwd
33
35
34
- echo " Adding Homebrew/homebrew-core "
35
- git remote add upstream https://github.com/Homebrew/homebrew-core .git
36
+ echo " Adding $UPSTREAM_USERNAME_AND_REPO "
37
+ git remote add upstream " https://github.com/$UPSTREAM_USERNAME_AND_REPO .git"
36
38
37
39
# Make sure the git remote step is successful
38
40
if ! git config remote.upstream.url > /dev/null; then
@@ -43,21 +45,19 @@ main() {
43
45
fi
44
46
45
47
# TODO@jsjoeio - can I somehow check that this succeeded?
46
- echo " Fetching upstream Homebrew/hombrew-core commits"
47
- git fetch upstream
48
+ echo " Fetching upstream $UPSTREAM_USERNAME_AND_REPO commits"
49
+ git fetch upstream master
48
50
49
51
# TODO@jsjoeio - can I somehow check that this succeeded?
50
- echo " Merging in latest Homebrew/homebrew-core changes"
52
+ echo " Merging in latest $UPSTREAM_USERNAME_AND_REPO changes branch master "
51
53
git merge upstream/master
52
54
53
- echo " Pushing changes to coderci/homebrew-core fork on GitHub"
54
-
55
55
# GIT_ASKPASS lets us use the password when pushing without revealing it in the process list
56
56
# See: https://serverfault.com/a/912788
57
57
PATH_TO_GIT_ASKPASS=" $HOME /git-askpass.sh"
58
58
# Source: https://serverfault.com/a/912788
59
59
# shellcheck disable=SC2016,SC2028
60
- echo ' echo $HOMEBREW_GITHUB_API_TOKEN' > " $PATH_TO_ASKPASS "
60
+ echo ' echo $HOMEBREW_GITHUB_API_TOKEN' > " $PATH_TO_GIT_ASKPASS "
61
61
62
62
# Make sure the git-askpass.sh file creation is successful
63
63
if ! file_exists " $PATH_TO_GIT_ASKPASS " ; then
@@ -76,30 +76,27 @@ main() {
76
76
exit 1
77
77
fi
78
78
79
+ # NOTE: we need to make sure our fork is up-to-date
80
+ # otherwise, brew bump-formula-pr will use an
81
+ # outdated base
82
+ echo " Pushing changes to $GITHUB_USERNAME /$REPO fork on GitHub"
79
83
# Export the variables so git sees them
80
84
export HOMEBREW_GITHUB_API_TOKEN=" $HOMEBREW_GITHUB_API_TOKEN "
81
- export GIT_ASKPASS=" $PATH_TO_ASKPASS "
82
- git push https://coder-oss @github.com/coder-oss/homebrew-core .git --all
85
+ export GIT_ASKPASS=" $PATH_TO_GIT_ASKPASS "
86
+ git push " https://$GITHUB_USERNAME @github.com/$GITHUB_USERNAME / $REPO .git" --all
83
87
84
88
# Find the docs for bump-formula-pr here
85
89
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/dev-cmd/bump-formula-pr.rb#L18
86
- local output
87
- if ! output=$( brew bump-formula-pr --version=" ${VERSION} " code-server --no-browse --no-audit 2>&1 ) ; then
88
- if [[ $output == * " Duplicate PRs should not be opened" * ]]; then
89
- echo " $VERSION is already submitted"
90
- else
91
- echo " $output "
92
- exit 1
93
- fi
94
- fi
90
+ # local output
91
+ brew bump-formula-pr --version=" ${VERSION} " code-server --no-browse --no-audit
95
92
96
93
# Clean up and remove homebrew-core
97
94
popd
98
- rm -rf homebrew-core
95
+ rm -rf " $REPO "
99
96
100
- # Make sure homebrew-core is removed
101
- if directory_exists " homebrew-core " ; then
102
- echo " rm -rf homebrew-core failed."
97
+ # Make sure $REPO is removed
98
+ if directory_exists " $REPO " ; then
99
+ echo " rm -rf $REPO failed."
103
100
ls -la
104
101
fi
105
102
}
0 commit comments