Skip to content

Commit 39a4127

Browse files
authored
Merge pull request #111 from pact-foundation/chore/tr_ruby/rel-20230605-3.2.2
chore(rel): use tr_ruby rel-20230605 plus deprecated bundler command …
2 parents 46fb587 + 56397b4 commit 39a4127

File tree

2 files changed

+100
-53
lines changed

2 files changed

+100
-53
lines changed

install.sh

+92-46
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,121 @@
1-
#!/bin/bash -e
2-
## Tested with https://www.shellcheck.net/
1+
#!/bin/sh -e
2+
## Tested with https://www.shellcheck.net/
33
# Usage: (install latest)
44
# $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | sh
55
# or
66
# $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh -O- | sh
77
#
8-
# Usage: (install fixed version) - pass tag=v<tag> eg tag=v1.92.0 or set as an env var
9-
# $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | tag=v1.92.0 sh
8+
# Usage: (install fixed version) - pass PACT_CLI_VERSION=v<PACT_CLI_VERSION> eg PACT_CLI_VERSION=v1.92.0 or set as an env var
9+
# $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | PACT_CLI_VERSION=v1.92.0 sh
1010
# or
11-
# $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh -O- | tag=v1.92.0 sh
11+
# $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh -O- | PACT_CLI_VERSION=v1.92.0 sh
1212
#
13+
if [ "$tag" ]; then
14+
echo "setting $tag as PACT_CLI_VERSION for legacy reasons"
15+
PACT_CLI_VERSION="$tag"
16+
fi
1317

14-
if [[ -z "$tag" ]]; then
15-
tag=$(basename "$(curl -fs -o/dev/null -w "%{redirect_url}" https://github.com/pact-foundation/pact-ruby-standalone/releases/latest)")
16-
echo "Thanks for downloading the latest release of pact-ruby-standalone $tag."
18+
if [ -z "$PACT_CLI_VERSION" ]; then
19+
PACT_CLI_VERSION=$(basename "$(curl -fs -o/dev/null -w "%{redirect_url}" https://github.com/pact-foundation/pact-ruby-standalone/releases/latest)")
20+
echo "Thanks for downloading the latest release of pact-ruby-standalone $PACT_CLI_VERSION."
1721
echo "-----"
1822
echo "Note:"
1923
echo "-----"
20-
echo "You can download a fixed version by setting the tag environment variable eg tag=v1.92.0"
24+
echo "You can download a fixed version by setting the PACT_CLI_VERSION environment variable eg PACT_CLI_VERSION=v1.92.0"
2125
echo "example:"
22-
echo "curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | tag=v1.92.0 sh"
26+
echo "curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | PACT_CLI_VERSION=v1.92.0 sh"
2327
else
24-
echo "Thanks for downloading pact-ruby-standalone $tag."
28+
echo "Thanks for downloading pact-ruby-standalone $PACT_CLI_VERSION."
2529
fi
2630

27-
TAG_WITHOUT_V=${tag#v}
28-
MAJOR_TAG=$(echo "$TAG_WITHOUT_V" | cut -d '.' -f 1)
31+
PACT_CLI_VERSION_WITHOUT_V=${PACT_CLI_VERSION#v}
32+
MAJOR_PACT_CLI_VERSION=$(echo "$PACT_CLI_VERSION_WITHOUT_V" | cut -d '.' -f 1)
2933

3034
case $(uname -sm) in
31-
'Linux x86_64')
32-
os='linux-x86_64'
33-
;;
34-
'Linux aarch64')
35-
if [[ "$MAJOR_TAG" -lt 2 ]]; then
36-
echo "Sorry, you'll need to install the pact-ruby-standalone manually."
37-
exit 1
38-
else
39-
os='linux-arm64'
40-
fi
41-
;;
42-
'Darwin arm64')
43-
if [[ "$MAJOR_TAG" -lt 2 ]]; then
44-
os='osx'
45-
else
46-
os='osx-arm64'
47-
fi
48-
;;
49-
'Darwin x86' | 'Darwin x86_64')
50-
if [[ "$MAJOR_TAG" -lt 2 ]]; then
51-
os='osx'
52-
else
53-
os='osx-x86_64'
54-
fi
55-
56-
;;
57-
*)
35+
'Linux x86_64')
36+
os='linux-x86_64'
37+
;;
38+
'Linux aarch64')
39+
if [ "$MAJOR_PACT_CLI_VERSION" -lt 2 ]; then
40+
echo "Sorry, you'll need to install the pact-ruby-standalone manually."
41+
exit 1
42+
else
43+
os='linux-arm64'
44+
fi
45+
;;
46+
'Darwin arm64')
47+
if [ "$MAJOR_PACT_CLI_VERSION" -lt 2 ]; then
48+
os='osx'
49+
else
50+
os='osx-arm64'
51+
fi
52+
;;
53+
'Darwin x86' | 'Darwin x86_64')
54+
if [ "$MAJOR_PACT_CLI_VERSION" -lt 2 ]; then
55+
os='osx'
56+
else
57+
os='osx-x86_64'
58+
fi
59+
;;
60+
"Windows"* | "MINGW64"*)
61+
if [ "$MAJOR_PACT_CLI_VERSION" -lt 2 ]; then
62+
os='win32'
63+
else
64+
os='windows-x86_64'
65+
fi
66+
;;
67+
*)
5868
echo "Sorry, you'll need to install the pact-ruby-standalone manually."
5969
exit 1
60-
;;
70+
;;
6171
esac
6272

73+
case $os in
74+
'windows'* | 'win32')
75+
filename="pact-${PACT_CLI_VERSION#v}-${os}.zip"
76+
;;
77+
'osx'* | 'linux'*)
78+
filename="pact-${PACT_CLI_VERSION#v}-${os}.tar.gz"
79+
;;
80+
esac
6381

64-
filename="pact-${tag#v}-${os}.tar.gz"
6582
echo "-------------"
6683
echo "Downloading:"
6784
echo "-------------"
68-
(curl -sLO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/"${tag}"/"${filename}" && echo downloaded "${filename}") || (echo "Sorry, you'll need to install the pact-ruby-standalone manually." && exit 1)
69-
(tar xzf "${filename}" && echo unarchived "${filename}") || (echo "Sorry, you'll need to unarchived the pact-ruby-standalone manually." && exit 1)
85+
(curl -sLO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/"${PACT_CLI_VERSION}"/"${filename}" && echo downloaded "${filename}") || (echo "Sorry, you'll need to install the pact-ruby-standalone manually." && exit 1)
86+
case $os in
87+
'windows'* | 'win32')
88+
(unzip "${filename}" && echo unarchived "${filename}") || (echo "Sorry, you'll need to unarchived the pact-ruby-standalone manually." && exit 1)
89+
;;
90+
'osx'* | 'linux'*)
91+
(tar xzf "${filename}" && echo unarchived "${filename}") || (echo "Sorry, you'll need to unarchived the pact-ruby-standalone manually." && exit 1)
92+
;;
93+
esac
7094
(rm "${filename}" && echo removed "${filename}") || (echo "Sorry, you'll need to remove the pact-ruby-standalone archive manually." && exit 1)
71-
echo "pact-ruby-standalone ${tag} installed to $(pwd)/pact"
95+
96+
echo "pact-ruby-standalone ${PACT_CLI_VERSION} installed to $(pwd)/pact"
7297
echo "-------------------"
7398
echo "available commands:"
7499
echo "-------------------"
75-
ls -1 "$(pwd)"/pact/bin
100+
PROJECT_NAME=pact-cli
101+
PACT_CLI_BIN_PATH=${PWD}/pact/bin/
102+
103+
ls -1 "$PACT_CLI_BIN_PATH"
104+
105+
106+
if [ "$GITHUB_ENV" ]; then
107+
echo "Added the following to your path to make ${PROJECT_NAME} available:"
108+
echo ""
109+
echo "PATH=$PACT_CLI_BIN_PATH:\${PATH}"
110+
echo "PATH=$PACT_CLI_BIN_PATH:${PATH}" >>"$GITHUB_ENV"
111+
elif [ "$CIRRUS_CI" ]; then
112+
echo "Added the following to your path to make ${PROJECT_NAME} available:"
113+
echo ""
114+
echo "PATH=$PACT_CLI_BIN_PATH:\${PATH}"
115+
echo "PATH=$PACT_CLI_BIN_PATH:${PATH}" >>"$CIRRUS_ENV"
116+
else
117+
echo "Add the following to your path to make ${PROJECT_NAME} available:"
118+
echo "--- Linux/MacOS/Windows Bash Users --------"
119+
echo ""
120+
echo " PATH=:$PACT_CLI_BIN_PATH:\${PATH}"
121+
fi

tasks/package.rake

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# For Bundler.with_clean_env
1+
# For Bundler.with_unbundled_env
22
require 'bundler/setup'
33

44
PACKAGE_NAME = "pact"
55
VERSION = File.read('VERSION').strip
6-
TRAVELING_RUBY_VERSION = "20230508-3.2.2"
6+
TRAVELING_RUBY_VERSION = "20230605-3.2.2"
7+
TRAVELING_RUBY_PKG_DATE = TRAVELING_RUBY_VERSION.split("-").first
78
PLUGIN_CLI_VERSION = "0.1.0"
89

910
desc "Package pact-ruby-standalone for OSX, Linux x86_64 and windows x86_64"
@@ -53,16 +54,16 @@ namespace :package do
5354
sh "cp packaging/Gemfile packaging/Gemfile.lock build/tmp/"
5455
sh "mkdir -p build/tmp/lib/pact/mock_service"
5556
# sh "cp lib/pact/mock_service/version.rb build/tmp/lib/pact/mock_service/version.rb"
56-
Bundler.with_clean_env do
57-
sh "cd build/tmp && env BUNDLE_IGNORE_CONFIG=1 bundle lock --add-platform x64-mingw32 && env BUNDLE_IGNORE_CONFIG=1 BUNDLE_DEPLOYMENT=true bundle install --path ../vendor"
57+
Bundler.with_unbundled_env do
58+
sh "cd build/tmp && env bundle lock --add-platform x64-mingw32 && bundle config set --local path '../vendor' && env BUNDLE_DEPLOYMENT=true bundle install"
5859
generate_readme
5960
end
6061
sh "rm -rf build/tmp"
6162
sh "rm -rf build/vendor/*/*/cache/*"
6263
end
6364

6465
task :generate_readme do
65-
Bundler.with_clean_env do
66+
Bundler.with_unbundled_env do
6667
sh "mkdir -p build/tmp"
6768
sh "cp packaging/Gemfile packaging/Gemfile.lock build/tmp/"
6869
sh "cd build/tmp && env BUNDLE_IGNORE_CONFIG=1 bundle install --path ../vendor --without development"
@@ -215,14 +216,14 @@ end
215216
def generate_readme
216217
template = File.absolute_path("packaging/README.md.template")
217218
script = File.absolute_path("packaging/generate_readme_contents.rb")
218-
Bundler.with_clean_env do
219+
Bundler.with_unbundled_env do
219220
sh "cd build/tmp && env VERSION=#{VERSION} bundle exec ruby #{script} #{template} > ../README.md"
220221
end
221222
end
222223

223224
def download_runtime(version, target)
224225
sh "cd build && curl -L -O --fail " +
225-
"https://github.com/YOU54F/traveling-ruby/releases/download/rel-20230508/traveling-ruby-#{version}-#{target}.tar.gz"
226+
"https://github.com/YOU54F/traveling-ruby/releases/download/rel-#{TRAVELING_RUBY_PKG_DATE}/traveling-ruby-#{version}-#{target}.tar.gz"
226227
end
227228

228229
def install_plugin_cli(package_dir, package_target)

0 commit comments

Comments
 (0)