Skip to content

Commit

Permalink
Prepare to release v0.3.2 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
jssblck authored Dec 14, 2024
1 parent c111231 commit d1c7931
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 41 deletions.
35 changes: 35 additions & 0 deletions .github/release_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Overview

Prepares to release the version specified in the title.
Once all checks pass, the release should be good to go.

## Release steps

```shell
# Choose a version. It should be valid semver.
# Also, choose a branch name. A good default is `prep/$VERSION`.
VERSION=<VERSION>
BRANCH="prep/$VERSION"

# Make a branch for release prep and check it out.
git checkout -b $BRANCH

# Have cargo-release create the release.
# This does several things:
# - Validates that the git index is clean
# - Updates version numbers in the crates
# - Generates the changelog using `git-cliff`
# - Creates a commit with the changes
# - Pushes the branch to the remote
cargo release --no-publish --no-tag --allow-branch=$BRANCH $VERSION

# Open a PR; once tests pass and reviewers approve, merge to main and come back here for the final step.
# NOTE: We are here; this PR was created by this step.
gh pr create --base main --body-file .github/release_template.md --title "Prepare to release $VERSION"

# Finally, run `cargo release` on the main branch.
# This doesn't create new commits; it just tags the commit and pushes the tag.
git checkout main
git pull
cargo release
```
8 changes: 6 additions & 2 deletions .github/workflows/check-dynamic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ jobs:
setup: echo "no setup"
build: cargo build
- host: macos-latest
setup: rustup target add aarch64-apple-darwin
build: cargo build --target aarch64-apple-darwin && cargo build --target x86_64-apple-darwin
setup: |
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
build: |
cargo build --target aarch64-apple-darwin
cargo build --target x86_64-apple-darwin
runs-on: ${{ matrix.settings.host }}
name: test / ${{ matrix.settings.host }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- uses: dtolnay/rust-toolchain@stable

- run: cargo fmt --all -- --check
- run: cargo clippy --all-features --all --tests -- -D clippy::all
- run: cargo clippy --all-features --all --tests -- -D clippy::correctness
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,35 @@

## [0.3.2](https://github.com/fossas/circe/releases/tag/0.3.2)

_Released: 2024-12-13_
_Released: 2024-12-14_

### 🐛 Bug Fixes

- *(circe)* Make viewable by `dist`
- Fix(tests):
rename `compute_relative` -> `compute_symlink_target`
fix tests
- *(tests)* Doctest import paths

### ✨ General

- Support `--layers squash-other`, add colors to clap
- Ensure crates are not published to crates.io
- Configure for `cargo release`
- Revert "chore(ci): split macOS test runners by architecture"

This reverts commit 5f0def95e2b20c40071de1e6b151f801eb0bc984.

### 📚 Documentation

- Add release process

### ⚙️ Miscellaneous Tasks

- Changelog fixup
- *(ci)* Fix clippy checks
- *(ci)* Split macOS test runners by architecture
- *(ci)* Fix macOS test runners

## [v0.3.1](https://github.com/fossas/circe/releases/tag/v0.3.1)

Expand Down
3 changes: 3 additions & 0 deletions bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ categories = ["command-line-utilities", "development-tools"]
default-run = "circe"
publish = false

[package.metadata.dist]
dist = true

[dependencies]
clap = { version = "4.5.23", features = ["color", "derive"] }
color-eyre = "0.6.3"
Expand Down
2 changes: 1 addition & 1 deletion cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ commit_parsers = [
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "(?i)^chore.*release.*", skip = true },
{ message = "^chore\\(deps.*\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
Expand Down
40 changes: 30 additions & 10 deletions docs/dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,34 @@ if this is not realistic at minimum every non-bugfix release **must** ensure dep
> [!TIP]
> Requires `cargo-release` and `git-cliff` to be installed.
Use `cargo release`:
Use `cargo release` to create a release.
Since we cannot push to `main` directly, perform the steps below:

```shell
# Choose a version. It should be valid semver.
# Also, choose a branch name. A good default is `prep/$VERSION`.
VERSION=<VERSION>
BRANCH="prep/$VERSION"

# Make a branch for release prep and check it out.
git checkout -b $BRANCH

# Have cargo-release create the release.
# This does several things:
# - Validates that the git index is clean
# - Updates version numbers in the crates
# - Generates the changelog using `git-cliff`
# - Creates a commit with the changes
# - Pushes the branch to the remote
cargo release --no-publish --no-tag --allow-branch=$BRANCH $VERSION

# Open a PR; once tests pass and reviewers approve, merge to main and come back here for the final step.
# NOTE: We are here; this PR was created by this step.
gh pr create --base main --body-file .github/release_template.md --title "Prepare to release $VERSION"

# Finally, run `cargo release` on the main branch.
# This doesn't create new commits; it just tags the commit and pushes the tag.
git checkout main
git pull
cargo release -x
```
cargo release <VERSION> # Review the planned actions
cargo release <VERSION> -x # Execute the planned actions
```

This performs several steps:
- Updates `version` fields in crates.
- Updates `CHANGELOG.md` with the new release (generated with `git cliff` from commit history).
- Creates a new tag.
- Pushes the new tag and updated `main` branch to the remote.
30 changes: 15 additions & 15 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Authentication {
/// Docker's platform string format (e.g. "linux/amd64").
///
/// ```
/// # use circe::Platform;
/// # use circe_lib::Platform;
/// # use std::str::FromStr;
/// let platform = Platform::from_str("linux/amd64").expect("parse platform");
/// assert_eq!(platform.to_string(), "linux/amd64");
Expand Down Expand Up @@ -173,7 +173,7 @@ impl FromStr for Platform {
.header("Expected:")
};
let examples_section = || {
vec!["linux/amd64/v7", "darwin/arm64"]
["linux/amd64/v7", "darwin/arm64"]
.join("\n")
.header("Examples:")
};
Expand Down Expand Up @@ -221,37 +221,37 @@ impl std::fmt::Display for Platform {

/// Create a [`Digest`] from a hex string at compile time.
/// ```
/// let digest = circe::digest!("sha256", "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// let digest = circe_lib::digest!("sha256", "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// assert_eq!(digest.algorithm, "sha256");
/// assert_eq!(digest.as_hex(), "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// ```
///
/// If algorithm is not provided, it defaults to [`Digest::SHA256`].
/// ```
/// let digest = circe::digest!("a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// let digest = circe_lib::digest!("a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// assert_eq!(digest.algorithm, "sha256");
/// assert_eq!(digest.as_hex(), "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// ```
///
/// This macro currently assumes that the hash is 32 bytes long.
/// Providing a value of a different length will result in a compile-time error.
/// ```compile_fail
/// let digest = circe::digest!("a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4deadbeef");
/// let digest = circe_lib::digest!("a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4deadbeef");
/// ```
///
/// You can work around this by providing the size of the hash as a third argument.
/// ```
/// let digest = circe::digest!(circe::Digest::SHA256, "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4deadbeef", 36);
/// let digest = circe_lib::digest!(circe_lib::Digest::SHA256, "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4deadbeef", 36);
/// assert_eq!(digest.algorithm, "sha256");
/// assert_eq!(digest.as_hex(), "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4deadbeef");
/// ```
#[macro_export]
macro_rules! digest {
($hex:expr) => {{
circe::digest!(circe::Digest::SHA256, $hex, 32)
circe_lib::digest!(circe_lib::Digest::SHA256, $hex, 32)
}};
($algorithm:expr, $hex:expr) => {{
circe::digest!($algorithm, $hex, 32)
circe_lib::digest!($algorithm, $hex, 32)
}};
($algorithm:expr, $hex:expr, $size:expr) => {{
const HASH: [u8; $size] = hex_magic::hex!($hex);
Expand All @@ -271,7 +271,7 @@ macro_rules! digest {
///
/// ```
/// # use std::str::FromStr;
/// let digest = circe::Digest::from_str("sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4").expect("parse digest");
/// let digest = circe_lib::Digest::from_str("sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4").expect("parse digest");
/// assert_eq!(digest.algorithm, "sha256");
/// assert_eq!(digest.as_hex(), "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// ```
Expand Down Expand Up @@ -336,7 +336,7 @@ impl From<&Digest> for Digest {
/// This can be a named tag or a SHA256 digest.
///
/// ```
/// # use circe::{Version, Digest};
/// # use circe_lib::{Version, Digest};
/// # use std::str::FromStr;
/// assert_eq!(Version::latest().to_string(), "latest");
/// assert_eq!(Version::tag("other").to_string(), "other");
Expand All @@ -357,7 +357,7 @@ impl Version {
/// Returns the tag for "latest".
///
/// ```
/// # use circe::Version;
/// # use circe_lib::Version;
/// assert_eq!(Version::latest().to_string(), "latest");
/// ```
pub fn latest() -> Self {
Expand All @@ -367,7 +367,7 @@ impl Version {
/// Create a tagged instance.
///
/// ```
/// # use circe::Version;
/// # use circe_lib::Version;
/// assert_eq!(Version::tag("latest").to_string(), "latest");
/// ```
pub fn tag(tag: &str) -> Self {
Expand All @@ -377,8 +377,8 @@ impl Version {
/// Create a digest instance.
///
/// ```
/// # use circe::Version;
/// let digest = circe::digest!("sha256", "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// # use circe_lib::Version;
/// let digest = circe_lib::digest!("sha256", "a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// let version = Version::digest(digest);
/// assert_eq!(version.to_string(), "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4");
/// ```
Expand All @@ -390,7 +390,7 @@ impl Version {
/// A parsed container image reference.
///
/// ```
/// # use circe::{Reference, Version};
/// # use circe_lib::{Reference, Version};
/// # use std::str::FromStr;
/// // Default to latest tag
/// let reference = Reference::from_str("docker.io/library/ubuntu").expect("parse reference");
Expand Down
22 changes: 11 additions & 11 deletions lib/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ async fn safe_symlink<R: AsyncRead + Unpin>(entry: &Entry<R>, dir: &Path) -> Res
let safe_link = dir.join(&link);
let safe_target = dir.join(strip_root(&target));

let rel_target = compute_relative(&safe_link, &safe_target)
let rel_target = compute_symlink_target(&safe_link, &safe_target)
.with_context(|| format!("compute relative path from {safe_link:?} to {safe_target:?}"))?;
tracing::info!(
?link,
Expand All @@ -451,7 +451,7 @@ async fn safe_symlink<R: AsyncRead + Unpin>(entry: &Entry<R>, dir: &Path) -> Res
})
}

fn compute_relative(src: &Path, dst: &Path) -> Result<PathBuf> {
fn compute_symlink_target(src: &Path, dst: &Path) -> Result<PathBuf> {
let common_prefix = src
.components()
.zip(dst.components())
Expand Down Expand Up @@ -676,22 +676,22 @@ mod tests {

#[test]
fn test_is_whiteout() {
assert_eq!(is_whiteout(Path::new("foo")), None);
assert_eq!(None, is_whiteout(Path::new("foo")));
assert_eq!(
Some(PathBuf::from("foo")),
is_whiteout(Path::new(".wh.foo")),
Some(PathBuf::from("foo"))
);
}

#[test_case(Path::new("/a/b/c"), Path::new("/a/b/d/e/f"), PathBuf::from("../d/e/f"); "one_level")]
#[test_case(Path::new("/usr/local/bin/ls"), Path::new("/bin/ls"), PathBuf::from("../../../../bin/ls"); "usr_local_bin_to_bin")]
#[test_case(Path::new("/usr/local/bin/ls"), Path::new("/usr/bin/ls"), PathBuf::from("../../../bin/ls"); "usr_local_bin_to_usr_bin")]
#[test_case(Path::new("/a/b/c"), Path::new("/a/b/d/e/f"), PathBuf::from("d/e/f"); "one_level")]
#[test_case(Path::new("/usr/local/bin/ls"), Path::new("/bin/ls"), PathBuf::from("../../../bin/ls"); "usr_local_bin_to_bin")]
#[test_case(Path::new("/usr/local/bin/ls"), Path::new("/usr/bin/ls"), PathBuf::from("../../bin/ls"); "usr_local_bin_to_usr_bin")]
#[test_case(Path::new("/usr/local/bin/ls"), Path::new("/usr/local/bin/ls"), PathBuf::from("."); "same_file")]
#[test_case(Path::new("/usr/local/bin/eza"), Path::new("/usr/local/bin/ls"), PathBuf::from("./ls"); "same_dir")]
#[test_case(Path::new("/usr/local/bin/eza"), Path::new("/usr/local/bin/ls"), PathBuf::from("ls"); "same_dir")]
#[tokio::test]
async fn compute_relative(src: &Path, dst: &Path, expected: PathBuf) -> Result<()> {
let relative = compute_relative(src, dst)?;
pretty_assertions::assert_eq!(relative, expected);
async fn compute_symlink_target(src: &Path, dst: &Path, expected: PathBuf) -> Result<()> {
let relative = compute_symlink_target(src, dst)?;
pretty_assertions::assert_eq!(expected, relative);
Ok(())
}
}
2 changes: 2 additions & 0 deletions release.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
sign-tag = true
sign-commit = true
pre-release-commit-message = "chore: Release {{version}}"
tag-message = "chore: Release {{version}}"

0 comments on commit d1c7931

Please sign in to comment.