Skip to content

Commit 114357b

Browse files
paketo-botjoshzarrabi
authored andcommitted
Update github-config to d86b31c
1 parent 047adcd commit 114357b

1 file changed

Lines changed: 17 additions & 82 deletions

File tree

scripts/package.sh

Lines changed: 17 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ readonly ROOT_DIR="$(cd "$(dirname "${0}")/.." && pwd)"
88
readonly BIN_DIR="${ROOT_DIR}/.bin"
99
readonly BUILD_DIR="${ROOT_DIR}/build"
1010

11+
# shellcheck source=.util/tools.sh
12+
source "${ROOT_DIR}/scripts/.util/tools.sh"
13+
14+
# shellcheck source=.util/print.sh
15+
source "${ROOT_DIR}/scripts/.util/print.sh"
16+
1117
function main {
1218
local version
1319

@@ -24,50 +30,24 @@ function main {
2430
;;
2531

2632
*)
27-
echo "unknown argument \"${1}\""
28-
exit 1
33+
util::print::error "unknown argument \"${1}\""
2934
esac
3035
done
3136

32-
if [[ "${version}" == "" ]]; then
33-
echo "--version is required"
34-
exit 1
37+
if [[ "${version:-}" == "" ]]; then
38+
util::print::error "--version is required"
3539
fi
3640

37-
os::check
3841
repo::prepare
3942

40-
tools::jam::install
41-
tools::yj::install
42-
tools::pack::install
43+
util::tools::pack::install --directory "${BIN_DIR}"
4344

4445
buildpack::archive "${version}"
45-
buildpackage::toml::write
4646
buildpackage::create
4747
}
4848

49-
function os::check() {
50-
local os
51-
52-
case "$(uname)" in
53-
"Darwin")
54-
os="macos"
55-
;;
56-
57-
"Linux")
58-
os="linux"
59-
;;
60-
61-
*)
62-
echo "Unknown OS \"$(uname)\""
63-
exit 1
64-
esac
65-
66-
readonly OS="${os}"
67-
}
68-
6949
function repo::prepare() {
70-
echo "-> Preparing repo..."
50+
util::print::title "Preparing repo..."
7151

7252
rm -rf "${BUILD_DIR}"
7353

@@ -77,72 +57,27 @@ function repo::prepare() {
7757
export PATH="${BIN_DIR}:${PATH}"
7858
}
7959

80-
function tools::jam::install() {
81-
echo "-> Installing v0.0.14 jam..."
82-
83-
local os
84-
os="${OS}"
85-
if [[ "${os}" == "macos" ]]; then
86-
os="darwin"
87-
fi
88-
89-
curl "https://github.com/paketo-buildpacks/packit/releases/download/v0.0.14/jam-${os}" \
90-
--silent \
91-
--location \
92-
--output "${BIN_DIR}/jam"
93-
chmod +x "${BIN_DIR}/jam"
94-
}
95-
96-
function tools::yj::install() {
97-
echo "-> Installing v4.0.0 yj..."
98-
99-
curl "https://github.com/sclevine/yj/releases/download/v4.0.0/yj-${OS}" \
100-
--silent \
101-
--location \
102-
--output "${BIN_DIR}/yj"
103-
chmod +x "${BIN_DIR}/yj"
104-
}
105-
106-
function tools::pack::install() {
107-
echo "-> Installing v0.10.0 pack..."
108-
109-
curl "https://github.com/buildpacks/pack/releases/download/v0.10.0/pack-v0.10.0-${OS}.tgz" \
110-
--silent \
111-
--location \
112-
--output /tmp/pack.tgz
113-
tar xzf /tmp/pack.tgz -C "${BIN_DIR}"
114-
chmod +x "${BIN_DIR}/pack"
115-
rm /tmp/pack.tgz
116-
}
117-
11860
function buildpack::archive() {
11961
local version
12062
version="${1}"
12163

122-
echo "-> Packaging family buildpack into ${BUILD_DIR}/buildpack.tgz..."
64+
util::print::title "Packaging buildpack into ${BUILD_DIR}/buildpack.tgz..."
65+
66+
util::tools::jam::install --directory "${BIN_DIR}"
12367

12468
jam pack \
12569
--buildpack "${ROOT_DIR}/buildpack.toml" \
12670
--version "${version}" \
71+
--offline \
12772
--output "${BUILD_DIR}/buildpack.tgz"
12873
}
12974

130-
function buildpackage::toml::write() {
131-
echo "-> Generating package config in ${BUILD_DIR}/package.toml..."
132-
133-
yj -tj < "${ROOT_DIR}/buildpack.toml" \
134-
| jq -r '.metadata.dependencies[] | select(.id != "lifecycle") | {uri: .uri }' \
135-
| jq -s --arg uri "${BUILD_DIR}/buildpack.tgz" '. | {buildpack: {uri: $uri}, dependencies: .}' \
136-
| yj -jt \
137-
> "${BUILD_DIR}/package.toml"
138-
}
139-
14075
function buildpackage::create() {
141-
echo "-> Packaging buildpack..."
76+
util::print::title "Packaging buildpack..."
14277

14378
pack \
14479
package-buildpack "${BUILD_DIR}/buildpackage.cnb" \
145-
--package-config "${BUILD_DIR}/package.toml" \
80+
--package-config "${ROOT_DIR}/package.toml" \
14681
--format file
14782
}
14883

0 commit comments

Comments
 (0)