github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/ci/cli-release/tasks/update-brew-formula.yml (about)

     1  ---
     2  platform: linux
     3  
     4  image_resource:
     5    type: docker-image
     6    source:
     7      repository: cfcli/cli-package
     8  
     9  inputs:
    10  - name: cli
    11  - name: homebrew-tap
    12  
    13  outputs:
    14  - name: update-brew-formula-output
    15  
    16  params:
    17    OUTPUT_PATH: update-brew-formula-output
    18  
    19  run:
    20    path: bash
    21    args:
    22    - -c
    23    - |
    24      set -ex
    25  
    26      VERSION=$(cat cli/BUILD_VERSION)
    27  
    28      mkdir cf-cli-osx-tarball cf-cli-linux-tarball
    29      curl -L "https://packages.cloudfoundry.org/stable?release=macosx64-binary&version=${VERSION}&source=github-rel" > cf-cli-osx-tarball/cf-cli_${VERSION}_osx.tgz
    30      curl -L "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=${VERSION}&source=github-rel" > cf-cli-linux-tarball/cf-cli_${VERSION}_linux64.tgz
    31  
    32  
    33  
    34      pushd cf-cli-osx-tarball
    35        CLI_OSX_SHA256=$(shasum -a 256 cf-cli_*_osx.tgz | cut -d ' ' -f 1)
    36      popd
    37  
    38      pushd cf-cli-linux-tarball
    39        CLI_LINUX_64_SHA256=$(shasum -a 256 cf-cli_*_linux64.tgz | cut -d ' ' -f 1)
    40      popd
    41  
    42      pushd homebrew-tap
    43        cat <<EOF > cf-cli.rb
    44      require 'formula'
    45  
    46      class CfCli < Formula
    47        homepage 'https://code.cloudfoundry.org/cli'
    48        version '${VERSION}'
    49  
    50        if OS.mac?
    51          head 'https://packages.cloudfoundry.org/edge?arch=macosx64&source=homebrew'
    52          url 'https://packages.cloudfoundry.org/homebrew/cf-${VERSION}.tgz'
    53          sha256 '${CLI_OSX_SHA256}'
    54        elsif OS.linux?
    55          head 'https://packages.cloudfoundry.org/edge?arch=linux64&source=homebrew'
    56          url 'https://packages.cloudfoundry.org/stable?release=linux64-binary&version=${VERSION}&source=homebrew'
    57          sha256 '${CLI_LINUX_64_SHA256}'
    58        end
    59  
    60        depends_on :arch => :x86_64
    61  
    62        def install
    63          bin.install 'cf'
    64          (bash_completion/"cf-cli").write <<-completion
    65      $(cat ../cli/ci/installers/completion/cf)
    66          completion
    67          doc.install 'LICENSE'
    68          doc.install 'NOTICE'
    69        end
    70  
    71        test do
    72          system "#{bin}/cf"
    73        end
    74      end
    75      EOF
    76  
    77      git add cf-cli.rb
    78      if ! [ -z "$(git status --porcelain)"];
    79      then
    80        git config --global user.email "cf-cli-eng@pivotal.io"
    81        git config --global user.name "Concourse CI"
    82        git commit -m "Release ${VERSION}"
    83      else
    84          echo "no new version to commit"
    85      fi
    86      popd
    87  
    88      cp -R homebrew-tap $OUTPUT_PATH