|
root / scripts
scripts Plain Text 139 lines 3.8 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh
#
# Bump the canonical Coral version.
#
# Usage: ./scripts/bump-version.sh <new-version>
#
# 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 <new-version>" >&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).