Skip to content

Commit e2be9dc

Browse files
committed
Updating github-config
1 parent 6636cc7 commit e2be9dc

2 files changed

Lines changed: 33 additions & 10 deletions

File tree

scripts/package.sh

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ function tools::install() {
111111
util::tools::pack::install \
112112
--directory "${BIN_DIR}" \
113113
--token "${token}"
114+
115+
util::tools::yj::install \
116+
--directory "${BIN_DIR}" \
117+
--token "${token}"
114118
}
115119

116120
function buildpack::archive() {
@@ -131,7 +135,7 @@ function buildpack::release::archive() {
131135

132136
util::print::title "Packaging buildpack into ${BUILD_DIR}/buildpack-release-artifact.tgz..."
133137

134-
tmp_dir=$(mktemp -d -p $ROOT_DIR)
138+
tmp_dir=$(mktemp -d -p $BUILD_DIR)
135139

136140
cat <<'README_EOF' > $tmp_dir/README.md
137141
# Composite buildpack release artifact
@@ -143,7 +147,7 @@ It contains the following files:
143147
* `buildpack.toml` - this is needed because it contains the buildpacks and ordering information for the composite buildpack
144148
* `package.toml` - this is needed because it contains the dependencies (and URIs) that let pack know where to find the buildpacks referenced in `buildpack.toml`.
145149
* `package.toml` can contain targets (platforms) for multi-arch support
146-
* `build/buildpack.tgz` - this is needed because it contains the actual buildpack referenced in `package.toml`
150+
* `build/buildpack.tgz` - this is added because it is referenced in `package.toml` by some buildpacks
147151
148152
## package locally
149153
@@ -173,36 +177,54 @@ README_EOF
173177
# add the buildpack.toml from the tgz file because it has the version populated
174178
tar -xzf ${BUILD_DIR}/buildpack.tgz -C $tmp_dir/ buildpack.toml
175179

176-
tar -cvzf ${BUILD_DIR}/buildpack-release-artifact.tgz -C $tmp_dir $(ls $tmp_dir)
180+
tar -czf ${BUILD_DIR}/buildpack-release-artifact.tgz -C $tmp_dir $(ls $tmp_dir)
177181
rm -rf $tmp_dir
178182
}
179183

180184
function buildpackage::create() {
181-
local output flags
185+
local output flags release_archive_path tmp_dir
182186
output="${1}"
183187
flags=("${@:2}")
188+
release_archive_path="${BUILD_DIR}/buildpack-release-artifact.tgz"
184189

185190
util::print::title "Packaging buildpack..."
186191

192+
util::print::info "Extracting release archive..."
193+
tmp_dir=$(mktemp -d -p $BUILD_DIR)
194+
tar -xvf $release_archive_path -C $tmp_dir
195+
196+
current_dir=$(pwd)
197+
cd $tmp_dir
198+
187199
args=(
188-
--config "${ROOT_DIR}/package.toml"
200+
--config package.toml
189201
--format file
190202
)
191203

192-
193204
args+=("${flags[@]}")
194205

206+
# Use the local architecture to support running locally and in CI, which will be linux/amd64 by default.
207+
arch=$(util::tools::arch)
208+
209+
# If package.toml has no targets we must specify one on the command line, otherwise pack will complain.
210+
# This is here for backward compatibility but eventually all package.toml files should have targets defined.
211+
if cat package.toml | yj -tj | jq -r .targets | grep -q null; then
212+
echo "package.toml has no targets so --target linux/${arch} will be passed to pack"
213+
args+=("--target linux/${arch}")
214+
fi
215+
216+
set -x
195217
pack \
196218
buildpack package "${output}" \
197219
${args[@]}
198220

199-
# Use the local architecture to support running locally and in CI, which will be linux/amd64 by default.
200-
arch=$(util::tools::arch)
201-
202221
if [[ -e "${BUILD_DIR}/buildpackage-linux-${arch}.cnb" ]]; then
203222
echo "Copying linux-${arch} buildpackage to buildpackage.cnb"
204223
cp "${BUILD_DIR}/buildpackage-linux-${arch}.cnb" "${BUILD_DIR}/buildpackage.cnb"
205224
fi
225+
226+
cd $current_dir
227+
rm -rf $tmp_dir
206228
}
207229

208230
main "${@:-}"

scripts/publish.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function buildpack::publish() {
116116

117117
util::print::info "Publishing buildpack to ${image_ref}"
118118

119+
current_dir=$(pwd)
119120
cd $tmp_dir
120121

121122
# If package.toml has no targets we must specify one on the command line, otherwise pack will complain.
@@ -135,7 +136,7 @@ function buildpack::publish() {
135136
--publish \
136137
${targets}
137138

138-
cd $ROOT_DIR
139+
cd $current_dir
139140
rm -rf $tmp_dir
140141
}
141142

0 commit comments

Comments
 (0)