Skip to content

Commit 3f8b1f6

Browse files
committed
Updating github-config
1 parent 8dc0a3b commit 3f8b1f6

2 files changed

Lines changed: 37 additions & 14 deletions

File tree

scripts/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function run::build() {
5858

5959
names=("detect")
6060

61-
if [ -f "extension.toml" ]; then
61+
if [ -f "${BUILDPACKDIR}/extension.toml" ]; then
6262
names+=("generate")
6363
else
6464
names+=("build")

scripts/package.sh

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,25 @@ function main {
6464

6565
tools::install "${token}"
6666

67-
buildpack::archive "${version}"
68-
buildpackage::create "${output}"
67+
buildpack_type=buildpack
68+
if [ -f "${ROOT_DIR}/extension.toml" ]; then
69+
buildpack_type=extension
70+
fi
71+
72+
buildpack::archive "${version}" "${buildpack_type}"
73+
buildpackage::create "${output}" "${buildpack_type}"
6974
}
7075

7176
function usage() {
7277
cat <<-USAGE
7378
package.sh --version <version> [OPTIONS]
7479
75-
Packages the buildpack into a buildpackage .cnb file.
80+
Packages a buildpack or an extension into a buildpackage .cnb file.
7681
7782
OPTIONS
7883
--help -h prints the command usage
79-
--version <version> -v <version> specifies the version number to use when packaging the buildpack
80-
--output <output> -o <output> location to output the packaged buildpackage artifact (default: ${ROOT_DIR}/build/buildpackage.cnb)
84+
--version <version> -v <version> specifies the version number to use when packaging a buildpack or an extension
85+
--output <output> -o <output> location to output the packaged buildpackage or extension artifact (default: ${ROOT_DIR}/build/buildpackage.cnb)
8186
--token <token> Token used to download assets from GitHub (e.g. jam, pack, etc) (optional)
8287
USAGE
8388
}
@@ -114,8 +119,9 @@ function tools::install() {
114119
function buildpack::archive() {
115120
local version
116121
version="${1}"
122+
buildpack_type="${2}"
117123

118-
util::print::title "Packaging buildpack into ${BUILD_DIR}/buildpack.tgz..."
124+
util::print::title "Packaging ${buildpack_type} into ${BUILD_DIR}/buildpack.tgz..."
119125

120126
if [[ -f "${ROOT_DIR}/.libbuildpack" ]]; then
121127
packager \
@@ -125,7 +131,7 @@ function buildpack::archive() {
125131
"${BUILD_DIR}/buildpack"
126132
else
127133
jam pack \
128-
--buildpack "${ROOT_DIR}/buildpack.toml" \
134+
"--${buildpack_type}" "${ROOT_DIR}/${buildpack_type}.toml"\
129135
--version "${version}" \
130136
--output "${BUILD_DIR}/buildpack.tgz"
131137
fi
@@ -134,13 +140,30 @@ function buildpack::archive() {
134140
function buildpackage::create() {
135141
local output
136142
output="${1}"
143+
buildpack_type="${2}"
144+
145+
util::print::title "Packaging ${buildpack_type}... ${output}"
137146

138-
util::print::title "Packaging buildpack..."
147+
if [ "$buildpack_type" == "extension" ]; then
148+
cwd=$(pwd)
149+
cd ${BUILD_DIR}
150+
mkdir cnbdir
151+
cd cnbdir
152+
cp ../buildpack.tgz .
153+
tar -xvf buildpack.tgz
154+
rm buildpack.tgz
139155

140-
pack \
141-
buildpack package "${output}" \
142-
--path "${BUILD_DIR}/buildpack.tgz" \
143-
--format file
156+
pack \
157+
extension package "${output}" \
158+
--format file
159+
160+
cd $cwd
161+
else
162+
pack \
163+
buildpack package "${output}" \
164+
--path "${BUILD_DIR}/buildpack.tgz" \
165+
--format file
166+
fi
144167
}
145168

146-
main "${@:-}"
169+
main "${@:-}"

0 commit comments

Comments
 (0)