#!/bin/sh # # Bump the canonical Coral version. # # Usage: ./scripts/bump-version.sh # # Rewrites in lock-step: # - reef.toml (canonical; read by scripts/make-release.sh and CI) # - src/main.reef (the fn version() runtime constant) # # Does NOT auto-commit or tag. Review with `hg diff`, then commit and tag # by hand (see the printed instructions). # # Modeled on zyginit/scripts/bump-version.sh. # set -e # This script uses GNU sed extensions (-i without backup suffix, 0,/addr/ # first-match range). Bumps are cut on a Linux dev host, not on Hammerhead; # fail fast if invoked elsewhere so the breakage isn't a cryptic sed error. case "$(uname -s)" in Linux) ;; *) echo "error: bump-version.sh requires GNU sed (Linux dev host)" >&2 echo " detected: $(uname -s)" >&2 exit 1 ;; esac if [ $# -ne 1 ]; then echo "usage: $0 " >&2 exit 1 fi NEW="$1" # Validate semver shape (no pre-release suffix). echo "$NEW" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || { echo "error: '$NEW' is not in MAJOR.MINOR.PATCH form" >&2 exit 1 } SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) ROOT=$(dirname "$SCRIPT_DIR") cd "$ROOT" CURRENT=$(grep '^version' reef.toml | head -1 | sed 's/.*"\([^"]*\)".*/\1/') if [ -z "$CURRENT" ]; then echo "error: could not read current version from reef.toml" >&2 exit 1 fi if [ "$CURRENT" = "$NEW" ]; then echo "error: version is already $NEW" >&2 exit 1 fi echo "coral: bumping $CURRENT -> $NEW" # 1. reef.toml — rewrite the first 'version = "..."' (the [package] table). # $NEW is safe inside the substitution: the semver regex above guarantees # digits + dots only — no '/' or '&' to misinterpret. echo " rewriting reef.toml" sed -i "0,/^version = \"[^\"]*\"/s//version = \"$NEW\"/" reef.toml # 2. src/main.reef — rewrite the return inside `fn version()` only, so no # other string-returning function is touched. echo " rewriting src/main.reef (fn version)" sed -i "/^fn version()/,/^end version/ s/return \"[^\"]*\"/return \"$NEW\"/" src/main.reef # Sanity check: both sources now agree on $NEW. TOML_V=$(grep '^version' reef.toml | head -1 | sed 's/.*"\([^"]*\)".*/\1/') MAIN_V=$(sed -n '/^fn version()/,/^end version/ s/.*return "\([^"]*\)".*/\1/p' src/main.reef | head -1) if [ "$TOML_V" != "$NEW" ] || [ "$MAIN_V" != "$NEW" ]; then echo "error: post-bump mismatch (reef.toml='$TOML_V', main.reef='$MAIN_V', expected '$NEW')" >&2 exit 1 fi echo echo "summary of changes:" hg diff --stat reef.toml src/main.reef || true echo echo "review with 'hg diff', then commit and tag:" echo " hg ci -m 'Bump version to $NEW'" echo " hg tag v$NEW" #!/bin/bash # # Create a source release tarball for Coral # # Usage: ./scripts/make-release.sh [version] # set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CORAL_DIR="$(dirname "$SCRIPT_DIR")" cd "$CORAL_DIR" # Get version from reef.toml or argument if [[ -n "$1" ]]; then VERSION="$1" else VERSION=$(grep '^version' reef.toml | head -1 | sed 's/.*"\([^"]*\)".*/\1/') fi if [[ -z "$VERSION" ]]; then echo "Error: Could not determine version" exit 1 fi RELEASE_NAME="coral-${VERSION}-source" RELEASE_DIR="releases" TARBALL="${RELEASE_DIR}/${RELEASE_NAME}.tar.xz" echo "Creating release: $RELEASE_NAME" # Create releases directory mkdir -p "$RELEASE_DIR" # Create tarball excluding build artifacts and git tar --exclude='build/*' \ --exclude='.git' \ --exclude='releases' \ --exclude='*.o' \ --exclude='*.a' \ --exclude='docs/superpowers' \ --exclude='.DS_Store' \ --exclude='*.swp' \ --exclude='*~' \ --transform "s,^,${RELEASE_NAME}/," \ -cJf "$TARBALL" \ reef.toml README.md src/ docs/ test/ echo "Created: $TARBALL" ls -la "$TARBALL" # Checksums are computed and published automatically by Isurus CI (SHA-256/512/MD5).