Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deployments/workloads/workload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
runtimeClassName: wasmtime-spin
containers:
- name: spin-hello
image: ghcr.io/spinframework/containerd-shim-spin/examples/spin-rust-hello:v0.20.0
image: ghcr.io/spinframework/containerd-shim-spin/examples/spin-rust-hello:latest
command: ["/"]
resources: # limit the resources to 128Mi of memory and 100m of CPU
limits:
Expand Down
37 changes: 18 additions & 19 deletions release.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ To cut a new release of the `containerd-shim-spin`, you will need to do the
following:

1. Confirm that [CI is
green](https://github.com/spinkube/containerd-shim-spin/actions) for the
commit selected to be tagged and released.
green](https://github.com/spinframework/containerd-shim-spin/actions) for the commit selected to be
tagged and released.

1. Change all references of the version number in package

* [Cargo.toml](./Cargo.toml),
* [quickstart](./containerd-shim-spin/quickstart.md),
* [README](./README.md),
* [deployments](./deployments/),
* [images](./images/).
* [CHANGELOG.md](./CHANGELOG.md) the Unreleased section should be updated with the new version number and the date of the release. Update the links to new version tag in the footer of CHANGELOG.md

Run `cargo build
--release` to make sure lockfiles reflect Cargo.toml updates. Add a new
column to the [README shim and Spin version
map](./README.md#shim-and-spin-version-map) that lists the version of the
Spin dependencies for the release.

1. Change all references of the version number in repository using the [`version.sh`](./scripts/version.sh) script, which
updates all Cargo manifests and README documentation to use a bumped version. Specify a major,
minor, or patch version update using the `-m`, `-n`, `-p` flags, respectively.
```sh
# Update minor version (1.2.3 -> 1.3.0)
scripts/version.sh -n
```

1. Update [CHANGELOG.md](./CHANGELOG.md). The Unreleased section should be updated with the new
version number and the date of the release. Update the links to new version tag in the footer of
CHANGELOG.md.

1. Add a new column to the [README shim and Spin version map](./README.md#shim-and-spin-version-map)
that lists the version of the Spin dependencies for the release.

1. Create a pull request with these changes and merge once approved.

1. Checkout the commit with the version bump from above.
Expand All @@ -35,12 +34,12 @@ following:
# Create a GPG-signed and annotated tag
git tag -s -m "Containerd Shim Spin v0.15.0" v0.15.0

# Push the tag to the remote corresponding to spinkube/containerd-shim-spin (here 'origin')
# Push the tag to the remote corresponding to spinframework/containerd-shim-spin (here 'origin')
git push origin v0.15.0
```

1. Pushing the tag upstream will trigger the [release
action](https://github.com/spinkube/containerd-shim-spin/actions/workflows/release.yaml).
action](https://github.com/spinframework/containerd-shim-spin/actions/workflows/release.yaml).
- The release build will create binary releases of the shim and upload these
assets to a new GitHub release for the pushed tag. Release notes are
auto-generated but edit as needed especially around breaking changes or
Expand Down
111 changes: 111 additions & 0 deletions scripts/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash

OTHER_FILES=${MD_FILES_TO_UPDATE:-"containerd-shim-spin/quickstart.md, images/spin-dapr/README.md, deployments/k3d/README.md"}

get_version()
{
pkg_version=$(cargo pkgid --package containerd-shim-spin-v2)
version=$(echo $pkg_version | sed -E 's/.*@([0-9]+\.[0-9]+\.[0-9]+.*?)$/\1/')

echo $version
}

new_version()
{
OLD_VERSION=$1

# Extract core version (major.minor.patch) and any suffixes
core_version=$(echo "$OLD_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*$/\1/')
suffix=$(echo "$OLD_VERSION" | sed -E 's/^[0-9]+\.[0-9]+\.[0-9]+(.*)$/\1/')

if [ "$SAME" != "1" ]; then
if [ "$MAJOR" == "1" ]; then
NEW_VERSION="$( echo "$core_version" | awk -F '.' '{print $1 + 1}' ).0.0"
elif [ "$MINOR" == "1" ]; then
NEW_VERSION="$( echo "$core_version" | awk -F '.' '{print $1}' ).$( echo "$core_version" | awk -F '.' '{print $2 + 1}' ).0"
elif [ "$PATCH" == "1" ]; then
NEW_VERSION="$( echo "$core_version" | awk -F '.' '{print $1}' ).$( echo "$core_version" | awk -F '.' '{print $2}' ).$( echo "$core_version" | awk -F '.' '{print $3 + 1}' )"
fi
# For version bumps, typically strip pre-release/build metadata unless you want to preserve it
# Uncomment the next line if you want to preserve suffixes on version bumps:
# NEW_VERSION="$NEW_VERSION$suffix"
else
NEW_VERSION=$OLD_VERSION
fi
echo "$NEW_VERSION"
}

update_file_version()
{
FILE=$1
LINE_PATTERN=$2
NEW_LINE=$3

echo "Update $FILE [$LINE_PATTERN] => [$NEW_LINE]"
sed -i s/"$LINE_PATTERN"/"$NEW_LINE"/g $FILE
return $?
}


BASEDIR=$(dirname "$0")

SAME=0
MAJOR=0
MINOR=0
PATCH=1


while getopts mnphs option
do
case "${option}" in
m) MAJOR=1;;
n) MINOR=1;;
p) PATCH=1;;
s) SAME=1;;
h)
echo "Increments versions depending on the semver option chosen"
echo "Usage: version.sh [-u] [-c]"
echo " -s updates all files to reflect the current base Cargo.toml version"
echo " -m increments major version and sets minor and patch to 0"
echo " -n increments minor version and sets patch to 0"
echo " -p increments patch version"
exit 0
;;
*)
echo "Invalid option: -$OPTARG" >&2
echo "Usage: version.sh [-s] [-m] [-n] [-p] [-h]"
exit 1
;;
esac
done

OLD_VERSION=$(get_version)
NEW_VERSION=$(new_version $OLD_VERSION)

echo "Updating to version: $NEW_VERSION"
TOML_VERSION_PATTERN="^version = .*"
TOML_VERSION_LINE="version = \"$NEW_VERSION\""

# 1) Update base Cargo.toml and workspace lockfile
update_file_version "$BASEDIR/Cargo.toml" "$TOML_VERSION_PATTERN" "$TOML_VERSION_LINE"
if [ "$?" -eq "1" ]; then exit 1; fi
cargo update

# 2) Update test images and lockfiles
for file in $(find $BASEDIR/images -name Cargo.toml); do
update_file_version "$file" "$TOML_VERSION_PATTERN" "$TOML_VERSION_LINE"
if [ "$?" -eq "1" ]; then exit 1; fi
dir=$(dirname $file)
if [[ $dir != /* ]]; then
dir=$BASEDIR/$dir
fi
cargo update --manifest-path $dir/Cargo.toml
done

# 3) Update all requested markdown file versions to $NEW_VERSION
for file in $(echo $OTHER_FILES | tr ',' ' '); do
update_file_version "$BASEDIR/$file" $OLD_VERSION $NEW_VERSION
if [ "$?" -eq "1" ]; then exit 1; fi
done

exit 0
Loading