-
Notifications
You must be signed in to change notification settings - Fork 5.9k
refactor(brew-bump): fix homebrew bump script #5025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
2f7a361
463ce25
f65d5ad
3a112f6
1aadd0d
8754406
aca716d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,10 +45,8 @@ jobs: | |
NPM_ENVIRONMENT: "production" | ||
|
||
homebrew: | ||
# The newest version of code-server needs to be available on npm when this runs | ||
# otherwise, it will 404 and won't open a PR to bump version on homebrew/homebrew-core | ||
needs: npm | ||
runs-on: macos-latest | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Ensure things are up to date | ||
# Suggested by homebrew maintainers | ||
|
@@ -60,16 +58,10 @@ jobs: | |
- name: Checkout code-server | ||
uses: actions/checkout@v3 | ||
|
||
- name: Checkout cdrci/homebrew-core | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: cdrci/homebrew-core | ||
path: homebrew-core | ||
|
||
- name: Configure git | ||
run: | | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
git config user.name cdrci | ||
git config user.email opensource@coder.com | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn't sure if I should use a real email or a fake one. Opted for a legit one in case something happened with this PR and someone needed to contact us 🤷🏼♂️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Smart 👍 |
||
|
||
- name: Bump code-server homebrew version | ||
env: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,6 @@ | |
set -euo pipefail | ||
|
||
main() { | ||
REPO="homebrew-core" | ||
GITHUB_USERNAME="cdrci" | ||
UPSTREAM_USERNAME_AND_REPO="Homebrew/$REPO" | ||
# Only sourcing this so we get access to $VERSION | ||
source ./ci/lib.sh | ||
source ./ci/steps/steps-lib.sh | ||
|
@@ -23,68 +20,6 @@ main() { | |
exit 1 | ||
fi | ||
|
||
# Make sure the git clone step is successful | ||
if ! directory_exists "$REPO"; then | ||
echo "git clone failed. Cannot find $REPO directory." | ||
ls -la | ||
exit 1 | ||
fi | ||
|
||
echo "Changing into $REPO directory" | ||
pushd "$REPO" && pwd | ||
|
||
echo "Adding $UPSTREAM_USERNAME_AND_REPO" | ||
git remote add upstream "https://github.com/$UPSTREAM_USERNAME_AND_REPO.git" | ||
|
||
# Make sure the git remote step is successful | ||
if ! git config remote.upstream.url > /dev/null; then | ||
echo "git remote add upstream failed." | ||
echo "Could not find upstream in list of remotes." | ||
git remote -v | ||
exit 1 | ||
fi | ||
|
||
# TODO@jsjoeio - can I somehow check that this succeeded? | ||
echo "Fetching upstream $UPSTREAM_USERNAME_AND_REPO commits" | ||
git fetch upstream master | ||
|
||
# TODO@jsjoeio - can I somehow check that this succeeded? | ||
echo "Merging in latest $UPSTREAM_USERNAME_AND_REPO changes branch master" | ||
git merge upstream/master | ||
|
||
# GIT_ASKPASS lets us use the password when pushing without revealing it in the process list | ||
# See: https://serverfault.com/a/912788 | ||
PATH_TO_GIT_ASKPASS="$HOME/git-askpass.sh" | ||
# Source: https://serverfault.com/a/912788 | ||
# shellcheck disable=SC2016,SC2028 | ||
echo 'echo $HOMEBREW_GITHUB_API_TOKEN' > "$PATH_TO_GIT_ASKPASS" | ||
|
||
# Make sure the git-askpass.sh file creation is successful | ||
if ! file_exists "$PATH_TO_GIT_ASKPASS"; then | ||
echo "git-askpass.sh not found in $HOME." | ||
ls -la "$HOME" | ||
exit 1 | ||
fi | ||
|
||
# Ensure it's executable since we just created it | ||
chmod +x "$PATH_TO_GIT_ASKPASS" | ||
|
||
# Make sure the git-askpass.sh file is executable | ||
if ! is_executable "$PATH_TO_GIT_ASKPASS"; then | ||
echo "$PATH_TO_GIT_ASKPASS is not executable." | ||
ls -la "$PATH_TO_GIT_ASKPASS" | ||
exit 1 | ||
fi | ||
|
||
# NOTE: we need to make sure our fork is up-to-date | ||
# otherwise, brew bump-formula-pr will use an | ||
# outdated base | ||
echo "Pushing changes to $GITHUB_USERNAME/$REPO fork on GitHub" | ||
# Export the variables so git sees them | ||
export HOMEBREW_GITHUB_API_TOKEN="$HOMEBREW_GITHUB_API_TOKEN" | ||
export GIT_ASKPASS="$PATH_TO_GIT_ASKPASS" | ||
git push "https://[email protected]/$GITHUB_USERNAME/$REPO.git" --all | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on this comment, using that setup homebrew action means we shouldn't have to keep a fork up-to-date and in testing things, it worked. And to confirm, you can see in the PR description that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, great news! I guess the issue we ran into was an edge case. |
||
# Find the docs for bump-formula-pr here | ||
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/dev-cmd/bump-formula-pr.rb#L18 | ||
local output | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Homebrew runs on Linux and Linux runners are more available (anecdotally) than macOS runners. Maybe it'll save some time.