Skip to content

Commit

Permalink
Move to buildpack API 0.10 (#773)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax committed Feb 12, 2024
1 parent ff8203b commit 033f612
Show file tree
Hide file tree
Showing 30 changed files with 232 additions and 346 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Now targets [Buildpack API 0.10](https://github.com/buildpacks/spec/releases/tag/buildpack%2Fv0.10). Buildpacks need to upgrade the `api` key to `0.10` in their `buildpack.toml`. ([#773](https://github.com/heroku/libcnb.rs/pull/773))
- Improved the consistency of cross-compilation assistance provided across all supported `target_triple` and host OS/architecture combinations. [#769](https://github.com/heroku/libcnb.rs/pull/769)
- Added cross-compilation assistance for `aarch64-unknown-linux-musl` (on macOS and ARM64 Linux) and `x86_64-unknown-linux-musl` (on ARM64 Linux). [#769](https://github.com/heroku/libcnb.rs/pull/769)
- Raised Minimum Supported Rust Version (MSRV) to `1.76`. ([#774](https://github.com/heroku/libcnb.rs/pull/774))
Expand All @@ -22,6 +23,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `libherokubuildpack`:
- `MappedWrite::unwrap` for getting the wrapped `Write` back out. ([#765](https://github.com/heroku/libcnb.rs/pull/765))

### Removed

- Types, errors, macros and functions related to stacks. The concept of stacks has been removed from the CNB spec. Use `Target` instead. ([#773](https://github.com/heroku/libcnb.rs/pull/773))

## [0.17.0] - 2023-12-06

### Added
Expand Down
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
It is an opinionated implementation adding language constructs and convenience methods for working
with the spec. It values strong adherence to the spec and data formats.

It currently targets version `0.9` of the CNB [Buildpack API specification](https://github.com/buildpacks/spec/blob/buildpack/0.9/buildpack.md).
It currently targets version `0.10` of the CNB [Buildpack API specification](https://github.com/buildpacks/spec/blob/buildpack/0.10/buildpack.md).

## Quick Start Guide

Expand Down Expand Up @@ -78,15 +78,12 @@ Since we're writing a Cloud Native Buildpack, we also need a `buildpack.toml`. U
file named `buildpack.toml` in the root of your project, right next to `Cargo.toml`.

```toml
api = "0.9"
api = "0.10"

[buildpack]
id = "libcnb-examples/my-buildpack"
version = "0.1.0"
name = "My Buildpack"

[[stacks]]
id = "*"
```

That's all we need! We can now move on to finally write some buildpack code!
Expand Down Expand Up @@ -132,7 +129,7 @@ impl Buildpack for HelloWorldBuildpack {
type Error = GenericError;
// This method will be called when the CNB lifecycle executes the detect phase (`bin/detect`).
// Use the `DetectContext` to access CNB data such as the stack this buildpack is currently
// Use the `DetectContext` to access CNB data such as the operating system this buildpack is currently
// executed on, the app directory and similar things. When using libcnb.rs, you never have
// to read environment variables or read/write files to disk to interact with the CNB lifecycle.
//
Expand All @@ -148,7 +145,7 @@ impl Buildpack for HelloWorldBuildpack {
// build phase (`bin/build`).
fn build(&self, context: BuildContext<Self>) -> libcnb::Result<BuildResult, Self::Error> {
println!("Hello World!");
println!("Build runs on stack {}!", context.stack_id);
println!("The build is running on: {} ({})!", context.target.os, context.target.arch);
BuildResultBuilder::new()
.launch(
Expand Down Expand Up @@ -218,7 +215,7 @@ libcnb-examples/my-buildpack 0.1.0
===> RESTORING
===> BUILDING
Hello World!
Build runs on stack heroku-22!
The build is running on: linux (amd64)!
===> EXPORTING
Adding layer 'buildpacksio/lifecycle:launch.sbom'
Adding 1/1 app layer(s)
Expand All @@ -230,7 +227,7 @@ Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'web'
Saving my-image...
*** Images (aa4695184718):
*** Images (85b067fc926a):
my-image
Successfully built image my-image
```
Expand Down
5 changes: 1 addition & 4 deletions examples/basics/buildpack.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
api = "0.9"
api = "0.10"

[buildpack]
id = "libcnb-examples/basics"
version = "0.1.0"
name = "Example libcnb buildpack: basics"

[[stacks]]
id = "*"
6 changes: 5 additions & 1 deletion examples/basics/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ impl Buildpack for BasicBuildpack {
}

fn build(&self, context: BuildContext<Self>) -> libcnb::Result<BuildResult, Self::Error> {
println!("Build runs on stack {}!", context.stack_id);
println!(
"The build is running on {} ({})!",
context.target.os, context.target.arch
);

BuildResultBuilder::new().build()
}
}
Expand Down
5 changes: 1 addition & 4 deletions examples/execd/buildpack.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
api = "0.9"
api = "0.10"

[buildpack]
id = "libcnb-examples/execd"
version = "0.1.0"
name = "Example libcnb buildpack: execd"

[[stacks]]
id = "*"
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ api = "0.8"
[buildpack]
id = "multiple-buildpacks/not-libcnb"
version = "0.0.0"

[[stacks]]
id = "some-stack"
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ api = "0.8"
[buildpack]
id = "multiple-buildpacks/one"
version = "0.0.0"

[[stacks]]
id = "some-stack"
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ api = "0.8"
[buildpack]
id = "multiple-buildpacks/two"
version = "0.0.0"

[[stacks]]
id = "some-stack"
5 changes: 1 addition & 4 deletions libcnb-cargo/tests/fixtures/single_buildpack/buildpack.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
api = "0.8"
api = "0.10"

[buildpack]
id = "single-buildpack"
version = "0.0.0"

[[stacks]]
id = "some-stack"
Loading

0 comments on commit 033f612

Please sign in to comment.