Skip to content
Open
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
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ jobs:
- name: Lint/Format js code
run: npm run lint

test_shell:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Lint shell scripts
uses: ludeeus/action-shellcheck@2.0.0
with:
scandir: "./scripts"
check_together: "yes"
additional_files: "cut-version"

- name: Test shell scripts
run: |
FORCE_COLOR=true ./vendor/scripts/bash_unit ./scripts/*.test.sh

test:
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down
138 changes: 0 additions & 138 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -389,141 +389,3 @@ jobs:
--field ref="refs/heads/${BRANCH_NAME}" \
--field sha="${SHA}"
fi

bump-pre_release-version:
name: Bump Pre-release Version
if: startsWith(github.ref, 'refs/tags/v') && (contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc'))
needs: [merge]
runs-on: ubuntu-latest
timeout-minutes: 10

permissions:
contents: write

steps:
- name: Determine source branch for tag
id: source_branch
run: |
# Fetch all branches to find which one contains this tag's commit
git init --quiet
git remote add origin "https://github.com/${{ github.repository }}.git"
git fetch origin --quiet

# Find branches containing the tagged commit
BRANCHES=$(git branch -r --contains ${{ github.sha }} | grep -v HEAD | sed 's/origin\///' | xargs)
echo "Branches containing commit: $BRANCHES"

# Prefer non-main branches (release branches) over main
SOURCE_BRANCH="main"
for branch in $BRANCHES; do
if [ "$branch" != "main" ] && [ "$branch" != "master" ]; then
SOURCE_BRANCH="$branch"
break
fi
done

echo "Selected source branch: $SOURCE_BRANCH"
echo "branch=$SOURCE_BRANCH" >> $GITHUB_OUTPUT

- name: Check out source branch
uses: actions/checkout@v4.2.0
with:
ref: ${{ steps.source_branch.outputs.branch }}
token: ${{ secrets.GH_PAT }}

- name: Bump pre-release version
run: |
VERSION_FILE=".sure-version"
CHART_FILE="charts/sure/Chart.yaml"

# Ensure version file exists
if [ ! -f "$VERSION_FILE" ]; then
echo "ERROR: Version file not found: $VERSION_FILE"
exit 1
fi

# Ensure chart file exists
if [ ! -f "$CHART_FILE" ]; then
echo "ERROR: Chart file not found: $CHART_FILE"
exit 1
fi

# Extract current version
CURRENT_VERSION=$(cat "$VERSION_FILE" | tr -d '[:space:]')
if [ -z "$CURRENT_VERSION" ]; then
echo "ERROR: Could not extract version from $VERSION_FILE"
exit 1
fi
echo "Current version: $CURRENT_VERSION"

# Extract the pre-release tag and number, then increment it
PRE_RELEASE_TAG=$(echo "$CURRENT_VERSION" | grep -oP '(alpha|beta|rc)')
if [ -z "$PRE_RELEASE_TAG" ]; then
echo "ERROR: Could not extract pre-release tag from $CURRENT_VERSION"
exit 1
fi

PRE_RELEASE_NUM=$(echo "$CURRENT_VERSION" | grep -oP '(alpha|beta|rc)\.\K[0-9]+')
if [ -z "$PRE_RELEASE_NUM" ]; then
echo "ERROR: Could not extract pre-release number from $CURRENT_VERSION"
exit 1
fi
NEW_PRE_RELEASE_NUM=$((PRE_RELEASE_NUM + 1))

# Create new version string
BASE_VERSION=$(echo "$CURRENT_VERSION" | grep -oP '^[0-9]+\.[0-9]+\.[0-9]+')
if [ -z "$BASE_VERSION" ]; then
echo "ERROR: Could not extract base version from $CURRENT_VERSION"
exit 1
fi
NEW_VERSION="${BASE_VERSION}-${PRE_RELEASE_TAG}.${NEW_PRE_RELEASE_NUM}"
echo "New version: $NEW_VERSION"

# Update the version file
echo "$NEW_VERSION" > "$VERSION_FILE"

# Verify the change
echo "Updated .sure-version:"
cat "$VERSION_FILE"

# Update Helm chart version and appVersion
sed -i -E "s/^version: .*/version: ${NEW_VERSION}/" "$CHART_FILE"
sed -i -E "s/^appVersion: .*/appVersion: \"${NEW_VERSION}\"/" "$CHART_FILE"

# Verify the change
echo "Updated Chart.yaml:"
grep -E "^(version|appVersion):" "$CHART_FILE"

- name: Commit and push version bump
env:
SOURCE_BRANCH: ${{ steps.source_branch.outputs.branch }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git add .sure-version
git add charts/sure/Chart.yaml

# Check if there are changes to commit
if git diff --cached --quiet; then
echo "No changes to commit - version may have already been bumped"
exit 0
fi

git commit -m "Bump version to next iteration after ${{ github.ref_name }} release"

echo "Pushing to branch: $SOURCE_BRANCH"

# Push with retry logic
attempts=0
until git push origin HEAD:$SOURCE_BRANCH; do
attempts=$((attempts + 1))
if [[ $attempts -ge 4 ]]; then
echo "ERROR: Failed to push after 4 attempts." >&2
exit 1
fi
delay=$((2 ** attempts))
echo "Push failed (attempt $attempts). Retrying in ${delay} seconds..."
sleep ${delay}
git pull --rebase origin $SOURCE_BRANCH
done
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ tasks.json
.taskmaster/reports/
.taskmaster/state.json
*.mcp.json
scripts/
scripts/*
!scripts/cut-version
!scripts/cut-version.test.sh
.cursor/mcp.json
.taskmasterconfig
.windsurfrules
Expand Down
63 changes: 63 additions & 0 deletions VERSIONING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Versioning

This document describes how versioning is done for Sure.

The versioning scheme described here is valid only from version `0.8.0` onward.
Earlier versions may have followed different rules and should not be interpreted
through this document.

## Scheme

Sure uses `X.Y.Z` versions with optional prerelease suffixes:

- Stable release: `X.Y.Z`
- Alpha release: `X.Y.Z-alpha.N`
- Beta release: `X.Y.Z-beta.N`
- Release candidate: `X.Y.Z-rc.N`

The canonical version is stored in `.sure-version`. The Helm chart version in
`charts/sure/Chart.yaml` must match it in both `version` and `appVersion`.

## Version Progression

The `scripts/cut-version` script applies these rules:

- Point release, default: `X.Y.Z` becomes `X.(Y+1).0`.
- Fix release, `--fix`: `X.Y.Z` becomes `X.Y.(Z+1)`.
- Alpha release, `--alpha`:
- `X.Y.Z` becomes `X.(Y+1).0-alpha.1`.
- `X.Y.Z-alpha.N` becomes `X.Y.Z-alpha.(N+1)`.
- Beta and RC versions cannot be converted back to alpha.
- Beta release, `--beta`:
- `X.Y.Z` becomes `X.(Y+1).0-beta.1`.
- `X.Y.Z-alpha.N` becomes `X.Y.Z-beta.1`.
- `X.Y.Z-beta.N` becomes `X.Y.Z-beta.(N+1)`.
- RC versions cannot be converted back to beta.
- Release candidate, `--rc`:
- `X.Y.Z` becomes `X.(Y+1).0-rc.1`.
- `X.Y.Z-alpha.N` or `X.Y.Z-beta.N` becomes `X.Y.Z-rc.1`.
- `X.Y.Z-rc.N` becomes `X.Y.Z-rc.(N+1)`.

## Release Process

Use `scripts/cut-version` to cut a version. The script:

1. Validates `.sure-version`.
2. Computes the next version from the selected release type.
3. Tags the current version as `v<CURRENT_VERSION>`.
4. Pushes that tag.
5. Updates `.sure-version` and `charts/sure/Chart.yaml` to the next version.
6. Commits the version bump.
7. Pushes the current branch.

Useful flags:

- `--alpha`, `--beta`, `--rc`, `--fix`: choose the release type. At most one may
be provided. With none provided, the script cuts a point release.
- `--dry-run`: print what would happen without changing files, tags, commits, or
pushes.
- `--allow-dirty`: allow running with a dirty worktree.
- `--no-tag`: skip tag creation and tag push.
- `--no-commit`: skip committing the version bump.
- `--no-push`: skip pushing tags and branches.
- `--verbose` or `-v`: enable debug logging.
Loading
Loading