Skip to content

Commit

Permalink
Automatically update Homebrew package when new versions are released (#…
Browse files Browse the repository at this point in the history
…3083)

Closes #2841
  • Loading branch information
Daniel15 committed Apr 13, 2017
1 parent fecbc0a commit a3226f4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
19 changes: 19 additions & 0 deletions jenkins_jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,22 @@ job('yarn-chocolatey') {
mailer 'yarn@dan.cx'
}
}

job('yarn-homebrew') {
description 'Ensures the Homebrew package for Yarn is up-to-date'
label 'linuxbrew'
scm {
github 'yarnpkg/yarn', 'master'
}
triggers {
yarnStableVersionChange delegate
}
steps {
shell './scripts/update-homebrew.sh'
}
publishers {
gitHubIssueNotifier {
}
mailer 'yarn@dan.cx'
}
}
26 changes: 26 additions & 0 deletions scripts/update-homebrew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Pushes the latest Yarn version to Homebrew

set -ex

version=`curl --fail https://yarnpkg.com/latest-version`

# Ensure Linuxbrew is on the PATH
PATH=$PATH:$HOME/.linuxbrew/bin/
# Ensure homebrew-core is pointing to Homebrew rather than Linuxbrew
pushd ~/.linuxbrew/Library/Taps/homebrew/homebrew-core
#git remote set-url origin https://github.com/Daniel15/homebrew-core # for testing
git remote set-url origin https://github.com/homebrew/homebrew-core
# Remove any existing branch (eg. if the previous attempt failed)
git branch -D yarn-$version || true
popd

# Grab latest Yarn release so we can hash it
url=https://yarnpkg.com/downloads/$version/yarn-v$version.tar.gz
tempfile=`mktemp -t 'yarn-release-XXXXXXXX.tar.gz'`
curl --fail -L -o $tempfile $url
hash=`sha256sum $tempfile | head -c 64`

# Update the formula!
# "BROWSER=/bin/true" is a hack around https://github.com/Homebrew/brew/issues/2468
BROWSER=/bin/true brew bump-formula-pr --strict yarn --url=$url --sha256=$hash --message="This PR was automatically created via a script. Contact @Daniel15 with any questions."

0 comments on commit a3226f4

Please sign in to comment.