mirror of
https://github.com/we-promise/sure.git
synced 2026-05-08 13:14:58 +00:00
Move versioning from Rails initializer to .sure-version file (#1587)
* Extract version to .sure-version file and add Sentry release tracking Move the hardcoded version string to a `.sure-version` file at the repo root so it can be read by both the Rails version initializer and other tooling. Configure `config.release` in the Sentry initializer to tag errors with the app version. https://claude.ai/code/session_01KfUgF42B3exoU2vpErqJyW * Use .sure-version as single source of truth in Helm CI workflows Update chart-ci, chart-release, and publish workflows to read the app version from .sure-version instead of regex-parsing version.rb. The pre-release bump job now writes directly to .sure-version and stages it for commit. https://claude.ai/code/session_01KfUgF42B3exoU2vpErqJyW * Guard empty .sure-version fallback * fix: sync Helm chart version with .sure-version * Moving on to `v0.7.1-alpha.*` with this * Defensive rescue * Getting fancy with versions now --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: SureBot <sure-bot@we-promise.com> Co-authored-by: sure-admin <sure-admin@splashblot.com>
This commit is contained in:
12
.github/workflows/chart-ci.yml
vendored
12
.github/workflows/chart-ci.yml
vendored
@@ -4,14 +4,14 @@ on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'charts/**'
|
||||
- 'config/initializers/version.rb'
|
||||
- '.sure-version'
|
||||
- '.github/workflows/chart-ci.yml'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'charts/**'
|
||||
- 'config/initializers/version.rb'
|
||||
- '.sure-version'
|
||||
- '.github/workflows/chart-ci.yml'
|
||||
|
||||
jobs:
|
||||
@@ -27,15 +27,15 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
RAILS_VERSION=$(grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?' config/initializers/version.rb | head -n 1 || true)
|
||||
RAILS_VERSION=$(cat .sure-version | tr -d '[:space:]')
|
||||
if [ -z "$RAILS_VERSION" ]; then
|
||||
echo "::error::Could not extract a version string from config/initializers/version.rb — ensure it contains a quoted semver like VERSION = \"1.2.3\""
|
||||
echo "::error::Could not read version from .sure-version"
|
||||
exit 1
|
||||
fi
|
||||
CHART_VERSION=$(sed -n 's/^version: //p' charts/sure/Chart.yaml | head -n 1)
|
||||
APP_VERSION=$(sed -n 's/^appVersion: "\{0,1\}\([^"]*\)"\{0,1\}/\1/p' charts/sure/Chart.yaml | head -n 1)
|
||||
|
||||
echo "Rails version (version.rb): $RAILS_VERSION"
|
||||
echo "App version (.sure-version): $RAILS_VERSION"
|
||||
echo "Helm chart version (Chart.yaml): $CHART_VERSION"
|
||||
echo "Helm appVersion (Chart.yaml): $APP_VERSION"
|
||||
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
|
||||
if [ "$ERRORS" -gt 0 ]; then
|
||||
echo ""
|
||||
echo "To fix: ensure version in config/initializers/version.rb matches"
|
||||
echo "To fix: ensure version in .sure-version matches"
|
||||
echo "both 'version' and 'appVersion' in charts/sure/Chart.yaml"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
10
.github/workflows/chart-release.yml
vendored
10
.github/workflows/chart-release.yml
vendored
@@ -28,20 +28,20 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# Read the canonical version from the Rails app (single source of truth)
|
||||
APP_SEMVER=$(grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?' config/initializers/version.rb | head -n 1 || true)
|
||||
# Read the canonical version from .sure-version (single source of truth)
|
||||
APP_SEMVER=$(cat .sure-version | tr -d '[:space:]')
|
||||
if [ -z "$APP_SEMVER" ]; then
|
||||
echo "::error::Could not extract version from config/initializers/version.rb"
|
||||
echo "::error::Could not read version from .sure-version"
|
||||
exit 1
|
||||
fi
|
||||
echo "App version from version.rb: $APP_SEMVER"
|
||||
echo "App version from .sure-version: $APP_SEMVER"
|
||||
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
# Use the app version as the chart version (monorepo: versions stay in sync)
|
||||
TAG_NAME="chart-v${APP_SEMVER}"
|
||||
|
||||
if git rev-parse "refs/tags/${TAG_NAME}" >/dev/null 2>&1; then
|
||||
echo "::error::Tag ${TAG_NAME} already exists. Bump the version in config/initializers/version.rb and charts/sure/Chart.yaml first."
|
||||
echo "::error::Tag ${TAG_NAME} already exists. Bump the version in .sure-version and charts/sure/Chart.yaml first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
12
.github/workflows/publish.yml
vendored
12
.github/workflows/publish.yml
vendored
@@ -428,7 +428,7 @@ jobs:
|
||||
|
||||
- name: Bump pre-release version
|
||||
run: |
|
||||
VERSION_FILE="config/initializers/version.rb"
|
||||
VERSION_FILE=".sure-version"
|
||||
CHART_FILE="charts/sure/Chart.yaml"
|
||||
|
||||
# Ensure version file exists
|
||||
@@ -444,7 +444,7 @@ jobs:
|
||||
fi
|
||||
|
||||
# Extract current version
|
||||
CURRENT_VERSION=$(grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+-(alpha|beta|rc)\.[0-9]+' "$VERSION_FILE")
|
||||
CURRENT_VERSION=$(cat "$VERSION_FILE" | tr -d '[:space:]')
|
||||
if [ -z "$CURRENT_VERSION" ]; then
|
||||
echo "ERROR: Could not extract version from $VERSION_FILE"
|
||||
exit 1
|
||||
@@ -475,11 +475,11 @@ jobs:
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
# Update the version file
|
||||
sed -i "s/\"$CURRENT_VERSION\"/\"$NEW_VERSION\"/" "$VERSION_FILE"
|
||||
echo "$NEW_VERSION" > "$VERSION_FILE"
|
||||
|
||||
# Verify the change
|
||||
echo "Updated version.rb:"
|
||||
grep "semver" "$VERSION_FILE"
|
||||
echo "Updated .sure-version:"
|
||||
cat "$VERSION_FILE"
|
||||
|
||||
# Update Helm chart version and appVersion
|
||||
sed -i -E "s/^version: .*/version: ${NEW_VERSION}/" "$CHART_FILE"
|
||||
@@ -496,7 +496,7 @@ jobs:
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git add config/initializers/version.rb
|
||||
git add .sure-version
|
||||
git add charts/sure/Chart.yaml
|
||||
|
||||
# Check if there are changes to commit
|
||||
|
||||
Reference in New Issue
Block a user