diff --git a/.github/workflows/chart-ci.yml b/.github/workflows/chart-ci.yml index d5ce7c532..4c3c85bbb 100644 --- a/.github/workflows/chart-ci.yml +++ b/.github/workflows/chart-ci.yml @@ -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 diff --git a/.github/workflows/chart-release.yml b/.github/workflows/chart-release.yml index 23fac9b88..a3efc238b 100644 --- a/.github/workflows/chart-release.yml +++ b/.github/workflows/chart-release.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 12473d176..77a723d06 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 diff --git a/.sure-version b/.sure-version new file mode 100644 index 000000000..852784236 --- /dev/null +++ b/.sure-version @@ -0,0 +1 @@ +0.7.1-alpha.1 diff --git a/charts/sure/Chart.yaml b/charts/sure/Chart.yaml index 6d15afdb0..513c057c8 100644 --- a/charts/sure/Chart.yaml +++ b/charts/sure/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: sure description: Official Helm chart for deploying the Sure Rails app (web + Sidekiq) on Kubernetes with optional HA PostgreSQL (CloudNativePG) and Redis. type: application -version: 0.7.0-alpha.8 -appVersion: "0.7.0-alpha.8" +version: 0.7.1-alpha.1 +appVersion: "0.7.1-alpha.1" kubeVersion: ">=1.25.0-0" diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 5d27918cd..8e31567d4 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -20,6 +20,7 @@ if ENV["SENTRY_DSN"].present? # We recommend adjusting this value in production. config.profiles_sample_rate = 0.25 + config.release = Rails.root.join(".sure-version").read.strip rescue nil config.profiler_class = Sentry::Vernier::Profiler end end diff --git a/config/initializers/version.rb b/config/initializers/version.rb index f036f4c8c..3511dd434 100644 --- a/config/initializers/version.rb +++ b/config/initializers/version.rb @@ -16,7 +16,10 @@ module Sure private def semver - "0.7.0-alpha.8" + stripped_content = Rails.root.join(".sure-version").read.strip + stripped_content.presence || "n/a: #{commit_sha}" + rescue Errno::ENOENT + "n/a: #{commit_sha || 'unknown'}" end end end