Skip to content

Commit

Permalink
Update Homebrew recipe when deploying.
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
brixen committed Dec 25, 2015
1 parent f470f46 commit fde04fc
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
50 changes: 49 additions & 1 deletion scripts/deploy.sh
Expand Up @@ -83,6 +83,8 @@ function rbx_deploy_homebrew_binary {

rbx_upload_files "$(rbx_binary_bucket)" "$(rbx_release_name)" \
"$(rbx_release_name)" "/homebrew/"

rbx_deploy_homebrew_release
fi
}

Expand Down Expand Up @@ -153,7 +155,7 @@ function rbx_deploy_github_release {
}

function rbx_deploy_website_release {
local os_name releases updates version url response
local os_name releases updates version url response sha

os_name=$1
releases="releases.yml"
Expand All @@ -180,6 +182,52 @@ EOF
fi
}

function rbx_deploy_homebrew_release {
local release file url response sha

release=$(rbx_release_name)
file="rubinius.rb"
url="https://api.github.com/repos/rubinius/homebrew-apps/contents/$file"
response=$(curl $url)

cat > "$file" <<EOF
require 'formula'
class Rubinius < Formula
homepage 'http://rubinius.com/'
url 'https://rubinius-binaries-rubinius-com.s3.amazonaws.com/homebrew/$release'
sha1 '$(cat "$release.sha1")'
depends_on 'libyaml'
depends_on :arch => :x86_64
depends_on MinimumMacOSRequirement => :mountain_lion
keg_only "Conflicts with MRI (Matz's Ruby Implementation)."
def install
bin.install Dir["bin/*"]
lib.install Dir["lib/*"]
include.install Dir["include/*"]
man1.install Dir["man/man1/*"]
end
test do
assert_equal 'rbx', \`"#{bin}/rbx" -e "puts RUBY_ENGINE"\`.chomp
end
end
EOF

sha=$(echo "$response" | "$__dir__/json.sh" -b | \
egrep '\["sha"\][[:space:]]\"[^"]+\"' | egrep -o '\"[[:xdigit:]]+\"')

let i=${#sha}

rbx_github_update_file "$file" "${sha:1:$i-2}" "Version $(rbx_revision_version)" "$url"

rm "$file"
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
if [[ -z $1 ]]; then
"$0" release github travis homebrew website
Expand Down
10 changes: 4 additions & 6 deletions scripts/github.sh
Expand Up @@ -3,16 +3,14 @@ __dir__="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=scripts/digest.sh
source "$__dir__/digest.sh"

function rbx_github_release_url {
echo "https://api.github.com/repos/rubinius/rubinius/releases"
}

function rbx_github_release {
local version date request response upload_url
local version date request response release_url upload_url

version=$1
date=$2

release_url="https://api.github.com/repos/rubinius/rubinius/releases"

request=$(printf '{
"tag_name": "v%s",
"target_commitish": "master",
Expand All @@ -23,7 +21,7 @@ function rbx_github_release {
}' "$version" "$version" "$version" "$date")

response=$(curl --data "$request" \
"$(rbx_github_release_url)?access_token=$GITHUB_OAUTH_TOKEN")
"$release_url?access_token=$GITHUB_OAUTH_TOKEN")

if [ $? -ne 0 ]; then
return
Expand Down

0 comments on commit fde04fc

Please sign in to comment.