Skip to content

Commit 2aa8d7b

Browse files
committed
Updating github-config
1 parent 81aca91 commit 2aa8d7b

3 files changed

Lines changed: 90 additions & 24 deletions

File tree

scripts/.util/tools.sh

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,21 @@ function util::tools::path::export() {
1717
}
1818

1919
function util::tools::jam::install() {
20-
local dir
20+
local dir token
21+
token=""
22+
2123
while [[ "${#}" != 0 ]]; do
2224
case "${1}" in
2325
--directory)
2426
dir="${2}"
2527
shift 2
2628
;;
2729

30+
--token)
31+
token="${2}"
32+
shift 2
33+
;;
34+
2835
*)
2936
util::print::error "unknown argument \"${1}\""
3037
esac
@@ -49,30 +56,49 @@ function util::tools::jam::install() {
4956
util::tools::path::export "${dir}"
5057

5158
if [[ ! -f "${dir}/jam" ]]; then
52-
local version
59+
local version curl_args
60+
5361
version="$(jq -r .jam "$(dirname "${BASH_SOURCE[0]}")/tools.json")"
5462

63+
curl_args=(
64+
"--fail"
65+
"--silent"
66+
"--location"
67+
"--output" "${dir}/jam"
68+
)
69+
70+
if [[ "${token}" != "" ]]; then
71+
curl_args+=("--header" "Authorization: Token ${token}")
72+
fi
73+
74+
5575
util::print::title "Installing jam ${version}"
76+
5677
curl "https://github.com/paketo-buildpacks/jam/releases/download/${version}/jam-${os}" \
57-
--fail \
58-
--silent \
59-
--location \
60-
--output "${dir}/jam"
78+
"${curl_args[@]}"
79+
6180
chmod +x "${dir}/jam"
6281
else
6382
util::print::info "Using $("${dir}"/jam version)"
6483
fi
6584
}
6685

6786
function util::tools::pack::install() {
68-
local dir
87+
local dir token
88+
token=""
89+
6990
while [[ "${#}" != 0 ]]; do
7091
case "${1}" in
7192
--directory)
7293
dir="${2}"
7394
shift 2
7495
;;
7596

97+
--token)
98+
token="${2}"
99+
shift 2
100+
;;
101+
76102
*)
77103
util::print::error "unknown argument \"${1}\""
78104
esac
@@ -97,18 +123,31 @@ function util::tools::pack::install() {
97123
esac
98124

99125
if [[ ! -f "${dir}/pack" ]]; then
100-
local version
126+
local version curl_args
127+
101128
version="$(jq -r .pack "$(dirname "${BASH_SOURCE[0]}")/tools.json")"
102129

130+
tmp_location="/tmp/pack.tgz"
131+
curl_args=(
132+
"--fail"
133+
"--silent"
134+
"--location"
135+
"--output" "${tmp_location}"
136+
)
137+
138+
if [[ "${token}" != "" ]]; then
139+
curl_args+=("--header" "Authorization: Token ${token}")
140+
fi
141+
103142
util::print::title "Installing pack ${version}"
143+
104144
curl "https://github.com/buildpacks/pack/releases/download/${version}/pack-${version}-${os}.tgz" \
105-
--fail \
106-
--silent \
107-
--location \
108-
--output /tmp/pack.tgz
109-
tar xzf /tmp/pack.tgz -C "${dir}"
145+
"${curl_args[@]}"
146+
147+
tar xzf "${tmp_location}" -C "${dir}"
110148
chmod +x "${dir}/pack"
111-
rm /tmp/pack.tgz
149+
150+
rm "${tmp_location}"
112151
else
113152
util::print::info "Using pack $("${dir}"/pack version)"
114153
fi

scripts/integration.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function main() {
5353
util::print::warn "** WARNING No Integration tests **"
5454
fi
5555

56-
tools::install
56+
tools::install "${GIT_TOKEN:-}"
5757

5858
if [ ${#builderArray[@]} -eq 0 ]; then
5959
util::print::title "No builders provided. Finding builders in integration.json..."
@@ -97,11 +97,16 @@ USAGE
9797
}
9898

9999
function tools::install() {
100+
local token
101+
token="${1}"
102+
100103
util::tools::pack::install \
101-
--directory "${BUILDPACKDIR}/.bin"
104+
--directory "${BUILDPACKDIR}/.bin" \
105+
--token "${token}"
102106

103107
util::tools::jam::install \
104-
--directory "${BUILDPACKDIR}/.bin"
108+
--directory "${BUILDPACKDIR}/.bin" \
109+
--token "${token}"
105110

106111
util::tools::create-package::install \
107112
--directory "${BUILDPACKDIR}/.bin"

scripts/package.sh

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ source "${ROOT_DIR}/scripts/.util/tools.sh"
1414
source "${ROOT_DIR}/scripts/.util/print.sh"
1515

1616
function main {
17-
local version output
17+
local version output token
18+
token=""
1819

1920
while [[ "${#}" != 0 ]]; do
2021
case "${1}" in
@@ -28,6 +29,11 @@ function main {
2829
shift 2
2930
;;
3031

32+
--token|-t)
33+
token="${2}"
34+
shift 2
35+
;;
36+
3137
--help|-h)
3238
shift 1
3339
usage
@@ -55,6 +61,9 @@ function main {
5561
fi
5662

5763
repo::prepare
64+
65+
tools::install "${token}"
66+
5867
buildpack::archive "${version}"
5968
buildpackage::create "${output}"
6069
}
@@ -69,6 +78,7 @@ OPTIONS
6978
--help -h prints the command usage
7079
--version <version> -v <version> specifies the version number to use when packaging the buildpack
7180
--output <output> -o <output> location to output the packaged buildpackage artifact (default: ${ROOT_DIR}/build/buildpackage.cnb)
81+
--token <token> Token used to download assets from GitHub (e.g. jam, pack, etc) (optional)
7282
USAGE
7383
}
7484

@@ -83,23 +93,37 @@ function repo::prepare() {
8393
export PATH="${BIN_DIR}:${PATH}"
8494
}
8595

96+
function tools::install() {
97+
local token
98+
token="${1}"
99+
100+
util::tools::pack::install \
101+
--directory "${BIN_DIR}" \
102+
--token "${token}"
103+
104+
if [[ -f "${ROOT_DIR}/.libbuildpack" ]]; then
105+
util::tools::packager::install \
106+
--directory "${BIN_DIR}"
107+
else
108+
util::tools::jam::install \
109+
--directory "${BIN_DIR}" \
110+
--token "${token}"
111+
fi
112+
}
113+
86114
function buildpack::archive() {
87115
local version
88116
version="${1}"
89117

90118
util::print::title "Packaging buildpack into ${BUILD_DIR}/buildpack.tgz..."
91119

92120
if [[ -f "${ROOT_DIR}/.libbuildpack" ]]; then
93-
util::tools::packager::install --directory "${BIN_DIR}"
94-
95121
packager \
96122
--uncached \
97123
--archive \
98124
--version "${version}" \
99125
"${BUILD_DIR}/buildpack"
100126
else
101-
util::tools::jam::install --directory "${BIN_DIR}"
102-
103127
jam pack \
104128
--buildpack "${ROOT_DIR}/buildpack.toml" \
105129
--version "${version}" \
@@ -113,8 +137,6 @@ function buildpackage::create() {
113137

114138
util::print::title "Packaging buildpack..."
115139

116-
util::tools::pack::install --directory "${BIN_DIR}"
117-
118140
pack \
119141
buildpack package "${output}" \
120142
--path "${BUILD_DIR}/buildpack.tgz" \

0 commit comments

Comments
 (0)