|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +if [[ pitr != $(whoami) ]] |
| 6 | +then |
| 7 | + echo "!!! This script takes a lot of assumptions based on @pitr-ch's environment." |
| 8 | + echo "!!! Use it at your own risk." |
| 9 | +fi |
| 10 | + |
| 11 | + |
| 12 | +version=$(ruby -r concurrent/version -e 'puts Concurrent::VERSION') |
| 13 | +edge_version=$(ruby -r concurrent/version -e 'puts Concurrent::EDGE_VERSION') |
| 14 | +(echo ${version} | grep pre) && prerelease='true' || prerelease='false' |
| 15 | + |
| 16 | +echo "concurrent-ruby: $version" |
| 17 | +echo "concurrent-ruby-edge: $edge_version" |
| 18 | +echo "prerelease: $prerelease" |
| 19 | + |
| 20 | +set -x |
| 21 | + |
| 22 | +mriVersion="2.3.1" |
| 23 | +jrubyVersion="jruby-9.1.5.0" |
| 24 | + |
| 25 | +if [[ "$@" =~ 'build' || $@ =~ 'all' ]] |
| 26 | +then |
| 27 | + echo Building |
| 28 | + |
| 29 | + export RBENV_VERSION=$mriVersion |
| 30 | + docker-machine status | grep Running || docker-machine start |
| 31 | + eval $(docker-machine env --shell sh default) |
| 32 | + rbenv version |
| 33 | + bundle install |
| 34 | + bundle exec rake clean |
| 35 | + bundle exec rake build |
| 36 | + docker-machine stop |
| 37 | + |
| 38 | + export RBENV_VERSION=$jrubyVersion |
| 39 | + rbenv version |
| 40 | + rm Gemfile.lock || true |
| 41 | + bundle install |
| 42 | + bundle exec rake clean |
| 43 | + bundle exec rake build |
| 44 | +fi |
| 45 | + |
| 46 | +if [[ "$@" =~ "test" || $@ =~ 'all' ]] |
| 47 | +then |
| 48 | + cd .. |
| 49 | + # TODO (pitr-ch 17-Dec-2016): dry: duplicates rake task |
| 50 | + rspec_options='--color --backtrace --seed 1 --format documentation --tag ~unfinished --tag ~notravis --tag ~buggy' |
| 51 | + |
| 52 | + # Install and test MRI version |
| 53 | + export RBENV_VERSION=$mriVersion |
| 54 | + gem install concurrent-ruby/pkg/concurrent-ruby-${version}.gem |
| 55 | + gem install concurrent-ruby/pkg/concurrent-ruby-edge-${edge_version}.gem |
| 56 | + gem install concurrent-ruby/pkg/concurrent-ruby-ext-${version}.gem |
| 57 | + ruby -r concurrent-edge -I concurrent-ruby/spec -r spec_helper -S rspec concurrent-ruby/spec ${rspec_options} |
| 58 | + gem uninstall concurrent-ruby-ext --version ${version} |
| 59 | + gem uninstall concurrent-ruby-edge --version ${edge_version} |
| 60 | + gem uninstall concurrent-ruby --version ${version} |
| 61 | + |
| 62 | + |
| 63 | + # Install and test JRuby version |
| 64 | + export RBENV_VERSION=$jrubyVersion |
| 65 | + gem push concurrent-ruby/pkg/concurrent-ruby-${version}-java.gem |
| 66 | + gem install concurrent-ruby/pkg/concurrent-ruby-edge-${edge_version}.gem |
| 67 | + ruby -r concurrent-edge -S rspec concurrent-ruby/spec ${rspec_options} |
| 68 | + gem uninstall concurrent-ruby-edge --version ${edge_version} |
| 69 | + gem uninstall concurrent-ruby --version ${version} |
| 70 | + |
| 71 | + cd concurrent-ruby |
| 72 | + |
| 73 | + # TODO (pitr-ch 17-Dec-2016): test windows build |
| 74 | +fi |
| 75 | + |
| 76 | +if [[ "$@" =~ "push" || $@ =~ 'all' ]] |
| 77 | +then |
| 78 | + echo Pushing |
| 79 | + |
| 80 | + # Test that we are on pushed commit |
| 81 | + git fetch |
| 82 | + test -z "$(git log --oneline master..upstream/master)" |
| 83 | + test -z "$(git log --oneline upstream/master..master)" |
| 84 | + |
| 85 | + # Tags |
| 86 | + git tag "v${version}" |
| 87 | + git tag "v${edge_version}" |
| 88 | + git push --tags |
| 89 | + |
| 90 | + # TODO (pitr-ch 16-Dec-2016): Release |
| 91 | + # https://developer.github.com/v3/repos/releases/#create-a-release |
| 92 | + # token=$(cat .githubtoken) |
| 93 | + #curl -X POST \ |
| 94 | + # -H "Authorization: token ${token}" \ |
| 95 | + # -H "Content-Type: application/json" \ |
| 96 | + # -H "Cache-Control: no-cache" \ |
| 97 | + # -d "{ |
| 98 | + # \"tag_name\": \"v0.1\", |
| 99 | + # \"target_commitish\": \"master\", |
| 100 | + # \"name\": \"v0.1\", |
| 101 | + # \"body\": \"Description of the release\", |
| 102 | + # \"draft\": true, |
| 103 | + # \"prerelease\": ${prerelease} |
| 104 | + # }" \ |
| 105 | + # "https://api.github.com/repos/pitr-ch/concurrent-ruby/releases" |
| 106 | + |
| 107 | + # Push to rubygems |
| 108 | + gem push pkg/concurrent-ruby-1.0.3.gem |
| 109 | + gem push pkg/concurrent-ruby-1.0.3-java.gem |
| 110 | + gem push pkg/concurrent-ruby-edge-0.2.3.gem |
| 111 | + gem push pkg/concurrent-ruby-ext-1.0.3.gem |
| 112 | + gem push pkg/concurrent-ruby-ext-1.0.3-x64-mingw32.gem |
| 113 | + gem push pkg/concurrent-ruby-ext-1.0.3-x86-mingw32.gem |
| 114 | + |
| 115 | + # TODO (pitr-ch 17-Dec-2016): send email |
| 116 | +fi |
| 117 | + |
| 118 | + |
| 119 | + |
0 commit comments