Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Adopt CalVer release tagging with SemVer compatibility alias (#4539)

Sure Admin (bot)3ce2afd73b95
diff --git a/.github/workflows/chart-ci.yml b/.github/workflows/chart-ci.yml
index a80af679ff..251410d2e9 100644
--- a/.github/workflows/chart-ci.yml
+++ b/.github/workflows/chart-ci.yml
@@ -5,64 +5,15 @@ on:
pull_request:
paths:
- 'charts/**'
- - '.sure-version'
- '.github/workflows/chart-ci.yml'
push:
branches:
- main
paths:
- 'charts/**'
- - '.sure-version'
- '.github/workflows/chart-ci.yml'
jobs:
- version-sync:
- name: Verify Helm ↔ Rails version sync
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- with:
- persist-credentials: false
-
- - name: Check version alignment
- shell: bash
- run: |
- set -euo pipefail
-
- RAILS_VERSION=$(cat .sure-version | tr -d '[:space:]')
- if [ -z "$RAILS_VERSION" ]; then
- 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 "App version (.sure-version): $RAILS_VERSION"
- echo "Helm chart version (Chart.yaml): $CHART_VERSION"
- echo "Helm appVersion (Chart.yaml): $APP_VERSION"
-
- ERRORS=0
-
- if [ "$RAILS_VERSION" != "$CHART_VERSION" ]; then
- echo "::error::Chart version ($CHART_VERSION) does not match Rails version ($RAILS_VERSION)"
- ERRORS=$((ERRORS + 1))
- fi
-
- if [ "$RAILS_VERSION" != "$APP_VERSION" ]; then
- echo "::error::Chart appVersion ($APP_VERSION) does not match Rails version ($RAILS_VERSION)"
- ERRORS=$((ERRORS + 1))
- fi
-
- if [ "$ERRORS" -gt 0 ]; then
- echo ""
- echo "To fix: ensure version in .sure-version matches"
- echo "both 'version' and 'appVersion' in charts/sure/Chart.yaml"
- exit 1
- fi
-
- echo "All versions are in sync."
-
helm-checks:
runs-on: ubuntu-latest
steps:
diff --git a/.github/workflows/chart-release.yml b/.github/workflows/chart-release.yml
index ee33ddccec..2b8dd61018 100644
--- a/.github/workflows/chart-release.yml
+++ b/.github/workflows/chart-release.yml
@@ -5,6 +5,11 @@ on:
tags:
- 'chart-v*'
workflow_dispatch:
+ inputs:
+ app_version:
+ description: Existing immutable app image version to package (without v)
+ required: true
+ type: string
permissions:
contents: write
@@ -25,23 +30,27 @@ jobs:
- name: Resolve chart release tag
id: tag
shell: bash
+ env:
+ APP_VERSION_INPUT: ${{ inputs.app_version }}
run: |
set -euo pipefail
- # 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 read version from .sure-version"
+ # Chart-only releases select an existing image, never the dev defaults.
+ APP_VERSION=$(sed -n 's/^appVersion: "\{0,1\}\([^" ]*\)"\{0,1\}/\1/p' charts/sure/Chart.yaml)
+ APP_VERSION="${APP_VERSION_INPUT:-$APP_VERSION}"
+ APP_VERSION="${APP_VERSION#v}"
+ if [[ ! "$APP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9]+)?)?$ || "$APP_VERSION" == 0.0.0-* ]]; then
+ echo "::error::Select an existing immutable app_version input, or pin Chart.yaml appVersion for a chart tag release."
exit 1
fi
- echo "App version from .sure-version: $APP_SEMVER"
+ echo "Selected app version: $APP_VERSION"
- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
+ 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}"
+ TAG_NAME="chart-v${APP_VERSION}"
if git rev-parse "refs/tags/${TAG_NAME}" >/dev/null 2>&1; then
- echo "::error::Tag ${TAG_NAME} already exists. Bump the version in .sure-version and charts/sure/Chart.yaml first."
+ echo "::error::Tag ${TAG_NAME} already exists. Use a new chart-v tag for another chart release of this app version."
exit 1
fi
@@ -63,7 +72,7 @@ jobs:
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
echo "chart_version=$CHART_VERSION" >> "$GITHUB_OUTPUT"
- echo "app_version=$APP_SEMVER" >> "$GITHUB_OUTPUT"
+ echo "app_version=$APP_VERSION" >> "$GITHUB_OUTPUT"
publish_chart:
needs: prepare_release
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
index 222ecf164f..e24ff7f2ef 100644
--- a/.github/workflows/desktop-release.yml
+++ b/.github/workflows/desktop-release.yml
@@ -23,17 +23,9 @@ jobs:
shell: bash
run: |
set -euo pipefail
- VERSION="$(tr -d '[:space:]' < .sure-version)"
- TAG_VERSION="${GITHUB_REF_NAME#v}"
-
- if [ -z "$VERSION" ]; then
- echo "::error::.sure-version is empty or unreadable"
- exit 1
- fi
- if [ "$VERSION" != "$TAG_VERSION" ]; then
- echo "::error::.sure-version ($VERSION) does not match release tag (v$TAG_VERSION)"
- exit 1
- fi
+ [[ "$GITHUB_REF_TYPE" == tag && "$GITHUB_REF_NAME" == v* ]] || exit 1
+ VERSION="${GITHUB_REF_NAME#v}"
+ printf '%s\n' "$VERSION" > .sure-version
echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$' \
|| { echo "::error::invalid version '$VERSION'"; exit 1; }
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/flutter-build.yml b/.github/workflows/flutter-build.yml
index 5fe42ea5d5..71636356db 100644
--- a/.github/workflows/flutter-build.yml
+++ b/.github/workflows/flutter-build.yml
@@ -2,6 +2,11 @@ name: Flutter Mobile Build
on:
workflow_call:
+ inputs:
+ app_version:
+ description: Selected mobile release version (v-prefix allowed)
+ required: false
+ type: string
outputs:
has_app_release_aab:
description: "Whether a signed release AAB artifact was produced"
@@ -38,6 +43,23 @@ jobs:
channel: 'stable'
cache: true
+ - name: Resolve app version
+ shell: bash
+ env:
+ APP_VERSION_INPUT: ${{ inputs.app_version }}
+ run: |
+ set -euo pipefail
+ if [[ -n "$APP_VERSION_INPUT" ]]; then
+ version="${APP_VERSION_INPUT#v}"
+ elif [[ "$GITHUB_REF_TYPE" == tag && "$GITHUB_REF_NAME" == v* ]]; then
+ version="${GITHUB_REF_NAME#v}"
+ else
+ version="$(sed -n 's/^version: *//p' mobile/pubspec.yaml)"
+ version="${version%%+*}"
+ fi
+ printf '%s\n' "$version" > .sure-version
+ echo "SURE_BUILD_NAME=$version" >> "$GITHUB_ENV"
+
- name: Get dependencies
working-directory: mobile
run: flutter pub get
@@ -88,10 +110,10 @@ jobs:
run: |
if [ "${{ steps.check_secrets.outputs.has_keystore }}" == "true" ]; then
echo "Building signed release APK..."
- flutter build apk --release
+ flutter build apk --release --build-name="$SURE_BUILD_NAME"
else
echo "Building debug-signed APK..."
- flutter build apk --debug
+ flutter build apk --debug --build-name="$SURE_BUILD_NAME"
fi
- name: Upload APK artifact
@@ -107,7 +129,7 @@ jobs:
- name: Build App Bundle (Release)
if: steps.check_secrets.outputs.has_keystore == 'true'
working-directory: mobile
- run: flutter build appbundle --release
+ run: flutter build appbundle --release --build-name="$SURE_BUILD_NAME"
- name: Upload AAB artifact
if: steps.check_secrets.outputs.has_keystore == 'true'
@@ -135,6 +157,23 @@ jobs:
channel: 'stable'
cache: true
+ - name: Resolve app version
+ shell: bash
+ env:
+ APP_VERSION_INPUT: ${{ inputs.app_version }}
+ run: |
+ set -euo pipefail
+ if [[ -n "$APP_VERSION_INPUT" ]]; then
+ version="${APP_VERSION_INPUT#v}"
+ elif [[ "$GITHUB_REF_TYPE" == tag && "$GITHUB_REF_NAME" == v* ]]; then
+ version="${GITHUB_REF_NAME#v}"
+ else
+ version="$(sed -n 's/^version: *//p' mobile/pubspec.yaml)"
+ version="${version%%+*}"
+ fi
+ printf '%s\n' "$version" > .sure-version
+ echo "SURE_BUILD_NAME=${version%%-*}" >> "$GITHUB_ENV"
+
- name: Get dependencies
working-directory: mobile
run: flutter pub get
@@ -160,7 +199,7 @@ jobs:
- name: Build iOS (No Code Signing)
working-directory: mobile
- run: flutter build ios --release --no-codesign
+ run: flutter build ios --release --no-codesign --build-name="$SURE_BUILD_NAME"
- name: Create IPA archive info
working-directory: mobile
diff --git a/.github/workflows/helm-publish.yml b/.github/workflows/helm-publish.yml
index 0588162c0b..ea26b59c90 100644
--- a/.github/workflows/helm-publish.yml
+++ b/.github/workflows/helm-publish.yml
@@ -4,13 +4,17 @@ on:
workflow_call:
inputs:
chart_version:
- description: Chart semver version (v-prefix allowed)
+ description: Chart version (v-prefix allowed)
required: false
type: string
app_version:
description: App version value for Chart.yaml appVersion
required: false
type: string
+ compatibility_version:
+ description: Optional legacy chart version; uses the canonical app image
+ required: false
+ type: string
update_gh_pages:
description: Whether to publish packaged chart to gh-pages index
required: false
@@ -100,6 +104,16 @@ jobs:
mkdir -p .cr-release-packages
helm package charts/sure -d .cr-release-packages
+ - name: Package compatibility chart
+ if: inputs.compatibility_version != ''
+ env:
+ COMPATIBILITY_VERSION: ${{ inputs.compatibility_version }}
+ APP_VERSION: ${{ steps.version.outputs.app_version }}
+ run: |
+ set -euo pipefail
+ [[ "$COMPATIBILITY_VERSION" =~ ^0\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(alpha|beta|rc)\.(0|[1-9][0-9]*))?$ ]] || exit 1
+ helm package charts/sure --version "$COMPATIBILITY_VERSION" --app-version "$APP_VERSION" -d .cr-release-packages
+
- name: Upload packaged chart artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
diff --git a/.github/workflows/ios-testflight.yml b/.github/workflows/ios-testflight.yml
index 718f49bade..542af973f8 100644
--- a/.github/workflows/ios-testflight.yml
+++ b/.github/workflows/ios-testflight.yml
@@ -9,6 +9,10 @@ on:
type: string
workflow_call:
inputs:
+ app_version:
+ description: Selected mobile release version (v-prefix allowed)
+ required: false
+ type: string
notes:
description: "TestFlight release notes"
required: false
@@ -21,7 +25,40 @@ permissions:
contents: read
jobs:
+ validate-release:
+ runs-on: ubuntu-latest
+ outputs:
+ eligible: ${{ steps.release.outputs.eligible }}
+ steps:
+ - name: Validate automatic release tag
+ id: release
+ shell: bash
+ env:
+ APP_VERSION_INPUT: ${{ inputs.app_version }}
+ run: |
+ set -euo pipefail
+ if [[ "$GITHUB_EVENT_NAME" == push ]]; then
+ # Mobile-only callers pass their selected version explicitly.
+ if [[ "$GITHUB_REF" == refs/tags/mobile-v* && -n "$APP_VERSION_INPUT" ]]; then
+ echo "eligible=true" >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ version="${GITHUB_REF#refs/tags/v}"
+ if [[ ! "$GITHUB_REF" == refs/tags/v* || ! "$version" =~ ^[2-9][0-9]{3}\.[1-9][0-9]?\.[1-9][0-9]?(-alpha)?$ ]]; then
+ echo "eligible=false" >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ base="${version%%-*}"
+ if [[ "$(date -u -d "${base//./-}" +%Y.%-m.%-d 2>/dev/null)" != "$base" ]]; then
+ echo "eligible=false" >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ fi
+ echo "eligible=true" >> "$GITHUB_OUTPUT"
+
build-and-upload:
+ needs: [validate-release]
+ if: needs.validate-release.outputs.eligible == 'true'
name: Build signed IPA and upload to TestFlight
runs-on: macos-26
timeout-minutes: 120
@@ -32,6 +69,24 @@ jobs:
with:
persist-credentials: false
+ - name: Resolve app version
+ id: version
+ shell: bash
+ env:
+ APP_VERSION_INPUT: ${{ inputs.app_version }}
+ run: |
+ set -euo pipefail
+ if [[ -n "$APP_VERSION_INPUT" ]]; then
+ version="${APP_VERSION_INPUT#v}"
+ elif [[ "$GITHUB_REF_TYPE" == tag && "$GITHUB_REF_NAME" == v* ]]; then
+ version="${GITHUB_REF_NAME#v}"
+ else
+ version="$(sed -n 's/^version: *//p' mobile/pubspec.yaml)"
+ version="${version%%+*}"
+ fi
+ printf '%s\n' "$version" > .sure-version
+ echo "ios_version=${version%%-*}" >> "$GITHUB_OUTPUT"
+
- name: Check TestFlight credentials
id: check_prereqs
env:
@@ -153,6 +208,7 @@ jobs:
working-directory: mobile
if: ${{ steps.check_prereqs.outputs.enabled == 'true' }}
env:
+ IOS_VERSION: ${{ steps.version.outputs.ios_version }}
APP_BUNDLE_ID: ${{ vars.IOS_APP_BUNDLE_ID || 'am.sure.mobile' }}
IOS_TEAM_ID: ${{ secrets.IOS_TEAM_ID }}
PROFILE_NAME: ${{ secrets.IOS_PROVISIONING_PROFILE_NAME }}
@@ -160,7 +216,6 @@ jobs:
run: |
set -euo pipefail
- IOS_VERSION="$(tr -d '[:space:]' < ../.sure-version | sed 's/-.*$//')"
IOS_BUILD_NUMBER="$(date -u +%Y%m%d%H%M)"
ARCHIVE_PATH="$RUNNER_TEMP/Runner.xcarchive"
EXPORT_PATH="$PWD/build/ios/ipa"
diff --git a/.github/workflows/mobile-release.yml b/.github/workflows/mobile-release.yml
index dc462ba0a0..0f0e8e0f5a 100644
--- a/.github/workflows/mobile-release.yml
+++ b/.github/workflows/mobile-release.yml
@@ -68,7 +68,10 @@ jobs:
build:
name: Build Mobile Apps
+ needs: [prepare_release]
uses: ./.github/workflows/flutter-build.yml
+ with:
+ app_version: ${{ needs.prepare_release.outputs.release_version }}
secrets: inherit
play-store:
@@ -86,6 +89,7 @@ jobs:
needs: [build, prepare_release]
uses: ./.github/workflows/ios-testflight.yml
with:
+ app_version: ${{ needs.prepare_release.outputs.release_version }}
notes: "Mobile release ${{ needs.prepare_release.outputs.tag_name }}"
secrets: inherit
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index e3bdcef576..a9818cdab3 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -38,20 +38,120 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
+ # Select the release channel and legacy alias through December; no date pin.
+ COMPATIBILITY_CHANNEL: 'alpha'
+ COMPATIBILITY_VERSION: '0.7.7-alpha.3'
permissions:
contents: write
packages: write
jobs:
+ prepare:
+ name: Resolve canonical release
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ actions: read
+ outputs:
+ version: ${{ steps.release.outputs.version }}
+ commit: ${{ steps.release.outputs.commit }}
+ publish: ${{ steps.release.outputs.publish }}
+ release: ${{ steps.release.outputs.release }}
+ stable: ${{ steps.release.outputs.stable }}
+ alpha: ${{ steps.release.outputs.alpha }}
+ compatibility_version: ${{ steps.release.outputs.compatibility_version }}
+ release_name: ${{ steps.release.outputs.release_name }}
+ alias_note: ${{ steps.release.outputs.alias_note }}
+ image_tags: ${{ steps.release.outputs.image_tags }}
+ steps:
+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
+ with:
+ persist-credentials: false
+ ref: ${{ github.event.inputs.ref || github.sha }}
+ - name: Read original workflow date
+ id: build_date
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ created=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" --jq .created_at)
+ echo "BUILD_DATE=$(date -u -d "$created" +%Y.%-m.%-d)" >> "$GITHUB_ENV"
+
+ - name: Resolve release tags
+ id: release
+ env:
+ SELECTED_REF: ${{ github.event.inputs.ref || github.ref }}
+ shell: bash
+ run: |
+ set -euo pipefail
+ # Legacy tags are aliases only; they must never start another release.
+ if [[ "$GITHUB_EVENT_NAME" == push && "$GITHUB_REF" == refs/tags/v0.* ]]; then
+ printf '%s\n' 'publish=false' 'release=false' >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ version="${BUILD_DATE}-alpha"
+ # Selected tags determine identity; only tag pushes publish releases.
+ selected_tag=""
+ if [[ "$GITHUB_EVENT_NAME" == push && "$GITHUB_REF" == refs/tags/* ]]; then
+ selected_tag="$GITHUB_REF"
+ elif [[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]]; then
+ if [[ "$SELECTED_REF" == refs/tags/* ]]; then
+ selected_tag="$SELECTED_REF"
+ elif git show-ref --verify --quiet "refs/tags/$SELECTED_REF"; then
+ selected_tag="refs/tags/$SELECTED_REF"
+ fi
+ fi
+ if [[ -n "$selected_tag" ]]; then
+ version="${selected_tag#refs/tags/v}"
+ [[ "$version" =~ ^[2-9][0-9]{3}\.[1-9][0-9]?\.[1-9][0-9]?(-alpha)?$ ]] || exit 1
+ base="${version%%-*}"
+ [[ "$(date -u -d "${base//./-}" +%Y.%-m.%-d)" == "$base" ]] || exit 1
+ fi
+ stable=false; alpha=false; compatibility=""
+ [[ "$version" == *-* ]] || stable=true
+ [[ "$version" != *-alpha ]] || alpha=true
+ channel=stable
+ [[ "$alpha" != true ]] || channel=alpha
+ if [[ "$GITHUB_EVENT_NAME" == push && "$GITHUB_REF" == refs/tags/* && "$version" == 2026.* && "$channel" == "$COMPATIBILITY_CHANNEL" ]]; then
+ compatibility="$COMPATIBILITY_VERSION"
+ [[ -z "$compatibility" || "$compatibility" =~ ^0\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(alpha|beta|rc)\.(0|[1-9][0-9]*))?$ ]] || exit 1
+ fi
+ publish=true; release=false
+ if [[ "$GITHUB_EVENT_NAME" == push && "$GITHUB_REF" == refs/tags/* ]]; then
+ release=true
+ fi
+ {
+ echo "version=$version"
+ echo "commit=$(git rev-parse HEAD)"
+ printf '%s\n' "publish=$publish" "release=$release" "stable=$stable" "alpha=$alpha"
+ printf '%s\n' "compatibility_version=$compatibility"
+ echo "release_name=v${version}${compatibility:+ — compatibility: v${compatibility}}"
+ echo "alias_note=${compatibility:+Compatibility alias: v${compatibility} (same commit and image).}"
+ echo 'image_tags<<RELEASE_TAGS'
+ if [[ "$release" == true ]]; then
+ echo "type=raw,value=$version"
+ [[ -z "$compatibility" ]] || echo "type=raw,value=$compatibility"
+ # Hold stable/latest image promotion until CalVer releases are validated.
+ else
+ echo "type=raw,value=sha-$(git rev-parse HEAD)"
+ if [[ "$GITHUB_EVENT_NAME" == schedule ]]; then
+ echo 'type=schedule,pattern=nightly'
+ echo "type=raw,value=${BUILD_DATE}-nightly"
+ fi
+ fi
+ echo 'RELEASE_TAGS'
+ } >> "$GITHUB_OUTPUT"
+
ci:
+ needs: [prepare]
+ if: needs.prepare.outputs.publish == 'true'
uses: ./.github/workflows/ci.yml
with:
require_js_dependency_audit: false
build:
name: Build Docker image
- needs: [ ci ]
+ needs: [prepare, ci]
strategy:
fail-fast: false
@@ -78,7 +178,13 @@ jobs:
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- ref: ${{ github.event.inputs.ref || github.ref }}
+ ref: ${{ needs.prepare.outputs.commit }}
+
+ - name: Generate embedded version
+ id: version_file
+ env:
+ VERSION: ${{ needs.prepare.outputs.version }}
+ run: printf '%s\n' "$VERSION" > .sure-version
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
@@ -90,31 +196,6 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- - name: Configure image tags
- id: tag_config
- shell: bash
- run: |
- BASE_CONFIG="type=sha,format=long"
- if [[ $GITHUB_EVENT_NAME == "schedule" ]]; then
- BASE_CONFIG+=$'\n'"type=schedule,pattern=nightly"
- BASE_CONFIG+=$'\n'"type=schedule,pattern=nightly-{{date 'ddd'}}"
- elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
- TAG_NAME="${GITHUB_REF#refs/tags/}"
- if [[ "$TAG_NAME" == v* ]]; then
- BASE_CONFIG="type=semver,pattern={{version}}"
- if [[ "$TAG_NAME" == v*-alpha* ]]; then
- BASE_CONFIG+=$'\n'"type=raw,value=latest"
- else
- BASE_CONFIG+=$'\n'"type=raw,value=stable"
- fi
- fi
- fi
- {
- echo 'TAGS_SPEC<<EOF'
- echo "$BASE_CONFIG"
- echo EOF
- } >> $GITHUB_ENV
-
- name: Get current date (RFC 3339 format)
id: date
run: echo "date=$(date -Iseconds)" >> $GITHUB_OUTPUT
@@ -125,9 +206,9 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: latest=false
- tags: ${{ env.TAGS_SPEC }}
+ tags: ${{ needs.prepare.outputs.image_tags }}
labels: |
- org.opencontainers.image.version=${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || '' }}
+ org.opencontainers.image.version=${{ needs.prepare.outputs.version }}
org.opencontainers.image.created=${{ steps.date.outputs.date }}
org.opencontainers.image.ref.name=${{ github.ref_name }}
org.opencontainers.image.vendor=we-promise
@@ -139,7 +220,7 @@ jobs:
id: build
with:
context: .
- build-args: BUILD_COMMIT_SHA=${{ github.sha }}
+ build-args: BUILD_COMMIT_SHA=${{ needs.prepare.outputs.commit }}
platforms: 'linux/${{ matrix.platform }}'
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.platform }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.platform }},mode=max
@@ -171,15 +252,36 @@ jobs:
merge:
name: Merge multi-arch manifest & push multi-arch tag
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || github.event_name == 'schedule' || github.event.inputs.push }}
- needs: [build]
+ needs: [prepare, build]
timeout-minutes: 60
runs-on: 'ubuntu-24.04'
permissions:
+ contents: write
packages: write
steps:
+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
+ if: needs.prepare.outputs.release == 'true' && needs.prepare.outputs.compatibility_version != ''
+ - name: Create or verify compatibility tag
+ id: compatibility
+ if: needs.prepare.outputs.release == 'true' && needs.prepare.outputs.compatibility_version != ''
+ env:
+ COMPATIBILITY_VERSION: ${{ needs.prepare.outputs.compatibility_version }}
+ shell: bash
+ run: |
+ set -euo pipefail
+ [[ "$COMPATIBILITY_VERSION" =~ ^0\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(alpha|beta|rc)\.(0|[1-9][0-9]*))?$ ]] || exit 1
+ # A non-force push either creates the alias or leaves the existing tag intact.
+ if ! git push origin "HEAD:refs/tags/v${COMPATIBILITY_VERSION}"; then
+ git fetch --no-tags origin "refs/tags/v${COMPATIBILITY_VERSION}"
+ if [[ "$(git rev-parse 'FETCH_HEAD^{commit}')" != "$(git rev-parse HEAD)" ]]; then
+ echo "Compatibility tag points to another commit; refusing to move it." >&2
+ exit 1
+ fi
+ fi
+
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
@@ -202,6 +304,8 @@ jobs:
TAGS: ${{ needs.build.outputs.tags }}
DIGESTS_DIR: ${{ runner.temp }}/digests
REF_NAME: ${{ github.ref_name }}
+ VERSION: ${{ needs.prepare.outputs.version }}
+ COMMIT: ${{ needs.prepare.outputs.commit }}
shell: bash -xeuo pipefail {0}
run: |
tag_args=()
@@ -218,7 +322,7 @@ jobs:
annotations=(
"index:org.opencontainers.image.created=$(date -Iseconds)"
'index:org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}'
- 'index:org.opencontainers.image.revision=${{ github.sha }}'
+ "index:org.opencontainers.image.revision=${COMMIT}"
"index:org.opencontainers.image.ref.name=${REF_NAME}"
'index:org.opencontainers.image.vendor=we-promise'
'index:org.opencontainers.image.licenses=AGPL-3.0'
@@ -229,9 +333,7 @@ jobs:
for annotation in "${annotations[@]}"; do
annotation_args+=("--annotation=${annotation}")
done
- if [[ $GITHUB_REF_TYPE == "tag" ]]; then
- annotation_args+=("--annotation=index:org.opencontainers.image.version=$GITHUB_REF_NAME")
- fi
+ annotation_args+=("--annotation=index:org.opencontainers.image.version=$VERSION")
attempts=0
until docker buildx imagetools create \
@@ -253,8 +355,8 @@ jobs:
deploy_demo:
name: Deploy alpha to Render demo
- if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref_name, '-alpha.')
- needs: [merge]
+ if: needs.prepare.outputs.release == 'true' && needs.prepare.outputs.alpha == 'true'
+ needs: [prepare, merge]
timeout-minutes: 15
runs-on: 'ubuntu-24.04'
@@ -346,8 +448,8 @@ jobs:
deploy_app:
name: Deploy stable to Render sure-app
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '-')
- needs: [merge]
+ if: needs.prepare.outputs.release == 'true' && needs.prepare.outputs.stable == 'true'
+ needs: [prepare, merge]
timeout-minutes: 15
runs-on: 'ubuntu-24.04'
@@ -444,30 +546,34 @@ jobs:
helm:
name: Package Helm chart
- if: startsWith(github.ref, 'refs/tags/v')
+ needs: [prepare, merge]
+ if: needs.prepare.outputs.release == 'true'
uses: ./.github/workflows/helm-publish.yml
with:
chart_version: ${{ github.ref_name }}
app_version: ${{ github.ref_name }}
update_gh_pages: true
+ compatibility_version: ${{ needs.prepare.outputs.compatibility_version }}
secrets: inherit
mobile:
name: Build Mobile Apps
- if: startsWith(github.ref, 'refs/tags/v')
+ needs: [prepare, merge]
+ if: needs.prepare.outputs.release == 'true'
uses: ./.github/workflows/flutter-build.yml
secrets: inherit
desktop:
name: Build macOS Desktop App
- if: startsWith(github.ref, 'refs/tags/v')
+ needs: [prepare, merge]
+ if: needs.prepare.outputs.release == 'true'
uses: ./.github/workflows/desktop-release.yml
secrets: inherit
release:
name: Create GitHub Release
- if: startsWith(github.ref, 'refs/tags/v')
- needs: [merge, mobile, desktop, helm]
+ if: needs.prepare.outputs.release == 'true'
+ needs: [prepare, merge, mobile, desktop, helm]
runs-on: ubuntu-latest
timeout-minutes: 10
@@ -556,13 +662,15 @@ jobs:
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
tag_name: ${{ github.ref_name }}
- name: ${{ github.ref_name }}
+ name: ${{ needs.prepare.outputs.release_name }}
draft: false
- prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
+ prerelease: ${{ needs.prepare.outputs.stable != 'true' }}
generate_release_notes: true
files: |
${{ runner.temp }}/release-assets/*
body: |
+ ${{ needs.prepare.outputs.alias_note }}
+
## Mobile Debug Builds
This release includes debug builds of the mobile applications. Download from the `Assets` area below.
@@ -571,250 +679,3 @@ jobs:
- **iOS Build**: Unsigned iOS build (requires code signing for installation)
> **Note**: These are debug builds intended for testing purposes. For production use, please build from source with proper signing credentials.
-
-
- create_release_branch:
- name: Create or update release branch
- if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'rc')
- needs: [release]
- runs-on: ubuntu-latest
-
- permissions:
- contents: write
-
- steps:
- - name: Create/update patch release branch
- env:
- TAG_NAME: ${{ github.ref_name }}
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- set -euo pipefail
-
- BRANCH_NAME="$(echo "$TAG_NAME" | sed -E 's/^v([0-9]+)\.([0-9]+)\.([0-9]+)(-.*)?$/v\1.\2.\3-release-branch/')"
- SHA="${GITHUB_SHA}"
-
- echo "Updating ${BRANCH_NAME} -> ${SHA}"
- if ! gh api "repos/${GITHUB_REPOSITORY}/git/refs/heads/${BRANCH_NAME}" \
- --method PATCH \
- --field sha="${SHA}" \
- --field force=true 2>/dev/null; then
- gh api "repos/${GITHUB_REPOSITORY}/git/refs" \
- --method POST \
- --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:
- actions: write
- contents: write
- pull-requests: write
-
- steps:
- - name: Determine source branch for tag
- id: source_branch
- env:
- TAG_NAME: ${{ github.ref_name }}
- 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 the matching release branch over main. Do not select arbitrary
- # feature or PR branches that happen to contain the tagged commit.
- SOURCE_BRANCH="main"
- RELEASE_BRANCH="$(printf '%s\n' "$TAG_NAME" | sed -E 's/^v([0-9]+)\.([0-9]+)\.([0-9]+)(-.*)?$/v\1.\2.\3-release-branch/')"
- LEGACY_RELEASE_BRANCH="$(printf '%s\n' "$TAG_NAME" | sed -E 's/^v([0-9]+)\.([0-9]+)\..*/v\1.\2-release-branch/')"
-
- for branch in $BRANCHES; do
- if [ "$branch" = "$RELEASE_BRANCH" ]; then
- SOURCE_BRANCH="$branch"
- break
- fi
- done
-
- if [ "$SOURCE_BRANCH" = "main" ]; then
- for branch in $BRANCHES; do
- if [ "$branch" = "$LEGACY_RELEASE_BRANCH" ]; then
- SOURCE_BRANCH="$branch"
- break
- fi
- done
- fi
-
- echo "Selected source branch: $SOURCE_BRANCH"
- echo "branch=$SOURCE_BRANCH" >> $GITHUB_OUTPUT
-
- - name: Check out source branch
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- with:
- ref: ${{ steps.source_branch.outputs.branch }}
- token: ${{ github.token }}
-
- - name: Bump pre-release version
- run: |
- set -euo pipefail
-
- 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=$(tr -d '[:space:]' < "$VERSION_FILE")
- if [ -z "$CURRENT_VERSION" ]; then
- echo "ERROR: Could not extract version from $VERSION_FILE"
- exit 1
- fi
- echo "Current version: $CURRENT_VERSION"
-
- if [[ ! "$CURRENT_VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)-(alpha|beta|rc)\.([0-9]+)$ ]]; then
- echo "ERROR: Expected prerelease version like 1.2.3-alpha.4, got $CURRENT_VERSION"
- exit 1
- fi
-
- BASE_VERSION="${BASH_REMATCH[1]}"
- PRE_RELEASE_TAG="${BASH_REMATCH[2]}"
- PRE_RELEASE_NUM="${BASH_REMATCH[3]}"
- NEW_PRE_RELEASE_NUM=$((PRE_RELEASE_NUM + 1))
- 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 }}
- GH_TOKEN: ${{ github.token }}
- REF_NAME: ${{ github.ref_name }}
- run: |
- set -euo pipefail
-
- 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
-
- COMMIT_MESSAGE="Bump version to next iteration after ${REF_NAME} release"
- git commit -m "$COMMIT_MESSAGE"
-
- echo "Pushing to branch: $SOURCE_BRANCH"
-
- # Push directly when allowed. Main is protected and must be updated
- # through a pull request. Other branches get a direct-push attempt, but
- # protected-branch rejections fall back to a pull request immediately.
- push_succeeded=false
- if [[ "$SOURCE_BRANCH" == "main" || "$SOURCE_BRANCH" == "master" ]]; then
- echo "$SOURCE_BRANCH is protected; creating a pull request instead of pushing directly."
- else
- direct_push_output=""
- for attempt in 1 2 3 4; do
- set +e
- direct_push_output=$(git push origin HEAD:"refs/heads/${SOURCE_BRANCH}" 2>&1)
- push_status=$?
- set -e
-
- echo "$direct_push_output"
-
- if [[ $push_status -eq 0 ]]; then
- push_succeeded=true
- break
- fi
-
- if grep -Eq 'GH006|Protected branch update failed|Changes must be made through a pull request' <<< "$direct_push_output"; then
- echo "Direct push is blocked by branch protection; creating a pull request instead."
- break
- fi
-
- if [[ $attempt -eq 4 ]]; then
- echo "Direct push failed after 4 attempts; creating a pull request instead."
- break
- fi
-
- delay=$((2 ** attempt))
- echo "Push failed (attempt $attempt). Retrying in ${delay} seconds..."
- sleep "$delay"
- git fetch origin "${SOURCE_BRANCH}"
- git rebase "origin/${SOURCE_BRANCH}"
- done
- fi
-
- if [[ "$push_succeeded" == "true" ]]; then
- exit 0
- fi
-
- SAFE_TAG=$(printf '%s' "${REF_NAME}" | tr -c '[:alnum:]._-' '-')
- BUMP_BRANCH="automation/bump-version-after-${SAFE_TAG}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
-
- git push --force-with-lease origin HEAD:"refs/heads/${BUMP_BRANCH}"
-
- PR_BODY="This automated PR bumps .sure-version and charts/sure/Chart.yaml after the ${REF_NAME} pre-release. It was opened because the workflow could not push directly to ${SOURCE_BRANCH}."
-
- set +e
- pr_create_output=$(gh pr create \
- --repo "$GITHUB_REPOSITORY" \
- --head "$BUMP_BRANCH" \
- --base "$SOURCE_BRANCH" \
- --title "$COMMIT_MESSAGE" \
- --body "$PR_BODY" 2>&1)
- pr_create_status=$?
- set -e
-
- if [[ $pr_create_status -ne 0 ]]; then
- echo "::error::Pushed ${BUMP_BRANCH}, but could not create the version bump PR: ${pr_create_output}"
- if grep -q "GitHub Actions is not permitted to create or approve pull requests" <<< "$pr_create_output"; then
- echo "::notice::Enable the organization setting that allows GitHub Actions to create and approve pull requests."
- fi
- exit 1
- fi
-
- PR_URL="$pr_create_output"
- echo "Created version bump PR: $PR_URL"
- echo "Dispatching PR checks for $BUMP_BRANCH"
- if ! gh workflow run pr.yml --repo "$GITHUB_REPOSITORY" --ref "$BUMP_BRANCH"; then
- echo "::warning::Could not dispatch pr.yml for $BUMP_BRANCH"
- fi
- if ! gh workflow run chart-ci.yml --repo "$GITHUB_REPOSITORY" --ref "$BUMP_BRANCH"; then
- echo "::warning::Could not dispatch chart-ci.yml for $BUMP_BRANCH"
- fi
diff --git a/.gitignore b/.gitignore
index dd7707feb5..94acba9743 100644
--- a/.gitignore
+++ b/.gitignore
@@ -134,3 +134,6 @@ logs/security/
# Ignore Playwright artifacts
playwright-report/
.playwright-mcp
+
+# Generated by release builds, not committed source metadata.
+/.sure-version
diff --git a/.sure-version b/.sure-version
deleted file mode 100644
index 1af71bf2f9..0000000000
--- a/.sure-version
+++ /dev/null
@@ -1 +0,0 @@
-0.7.7-alpha.3
diff --git a/app/models/user.rb b/app/models/user.rb
index 62dafc8c1c..24101358a3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -682,7 +682,7 @@ class User < ApplicationRecord
def parsed_release_tag_version!(tag)
raise ArgumentError, "invalid release tag" unless tag.to_s.match?(/\Av\d+\.\d+\.\d+(?:[-+.][0-9A-Za-z.-]+)?\z/)
- Semver.from_release_tag(tag).version
+ Calver.from_release_tag(tag).version
end
def parsed_release_tag_version(tag)
diff --git a/charts/sure/CHANGELOG.md b/charts/sure/CHANGELOG.md
index e8f9feb8d8..4f6ff01cd8 100644
--- a/charts/sure/CHANGELOG.md
+++ b/charts/sure/CHANGELOG.md
@@ -3,7 +3,7 @@
All notable changes to the Sure Helm chart will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+and chart releases follow Sure’s [calendar versioning](../../docs/releases/versioning.md).
## [Unreleased]
diff --git a/charts/sure/Chart.yaml b/charts/sure/Chart.yaml
index 47240d2286..0ad867bf42 100644
--- a/charts/sure/Chart.yaml
+++ b/charts/sure/Chart.yaml
@@ -2,8 +2,9 @@ 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.7-alpha.3
-appVersion: "0.7.7-alpha.3"
+# Development defaults only; release packaging stamps the resolved build version.
+version: 0.0.0-dev
+appVersion: "latest"
kubeVersion: ">=1.25.0-0"
diff --git a/config/initializers/version.rb b/config/initializers/version.rb
index 3511dd4343..111fb05b57 100644
--- a/config/initializers/version.rb
+++ b/config/initializers/version.rb
@@ -1,7 +1,7 @@
module Sure
class << self
def version
- Semver.new(semver)
+ Calver.new(version_string)
end
def commit_sha
@@ -15,11 +15,11 @@ module Sure
end
private
- def semver
+ def version_string
stripped_content = Rails.root.join(".sure-version").read.strip
- stripped_content.presence || "n/a: #{commit_sha}"
+ stripped_content.presence || "0.0.0-dev.#{commit_sha.presence || 'unknown'}"
rescue Errno::ENOENT
- "n/a: #{commit_sha || 'unknown'}"
+ "0.0.0-dev.#{commit_sha.presence || 'unknown'}"
end
end
end
diff --git a/desktop/README.md b/desktop/README.md
index d60deadf96..c78ce9d5eb 100644
--- a/desktop/README.md
+++ b/desktop/README.md
@@ -31,7 +31,7 @@ npm run tauri build -- --target universal-apple-darwin
## Publishing a release
The desktop build runs automatically as part of the normal Sure `v*` release.
-The version comes from `.sure-version` and must match the release tag; it is
+The version comes from the release tag and is written to generated `.sure-version`; it is
stamped into `desktop/package.json` and `desktop/src-tauri/tauri.conf.json`
only while building. The universal `.dmg` is attached to that same GitHub
Release—there is no separate desktop action, tag, or version.
diff --git a/docs/releases/versioning.md b/docs/releases/versioning.md
new file mode 100644
index 0000000000..b14db87524
--- /dev/null
+++ b/docs/releases/versioning.md
@@ -0,0 +1,82 @@
+# CalVer transition: October–December 2026
+
+The transition starts with the **`v0.7.7-alpha.3`** release, not the 0.7.6 train.
+Its primary version is **`vYYYY.M.D-alpha`**, using the actual UTC release date;
+`v0.7.7-alpha.3` is only a temporary compatibility alias. No release date is
+checked into the workflow or chart metadata.
+Release tags supply the canonical date to every build.
+Git tags include `v`; Docker tags and chart versions do not.
+
+`.sure-version` is generated build metadata, ignored by Git. The Docker workflow
+writes it into the build context before packaging; Rails, Sentry and backups
+continue reading that immutable file inside the image. Source checkouts without
+it use `0.0.0-dev.<commit_sha>` (or `0.0.0-dev.unknown` when unavailable). Local Docker builds
+can generate the file explicitly to label their image; without it they are dev builds.
+
+Tagged releases derive their version from the tag, so retries retain the same
+identity. Manual builds selecting a canonical tag retain its version but remain
+non-releases: they publish only the selected commit’s SHA image tag when requested. Untagged Docker builds use the original workflow run's UTC date
+(`YYYY.M.D-alpha`); retries retain that date. They keep the existing SHA tags and do not
+promote `stable` or `latest`. Scheduled builds additionally publish floating
+`nightly` and unpadded `YYYY.M.D-nightly` Docker tags (for example,
+`2026.11.1-nightly`), using that same original UTC run date on retries.
+Dated tags replace the rotating weekday tags; existing images and tags are
+not deleted, and no retention or cleanup policy is changed.
+
+Desktop and mobile release builds also derive their versions from the release
+tag. Standalone mobile branch builds retain their explicit pubspec version.
+Release chart packages are stamped from the release tag; chart-only releases
+select an existing immutable image via the `app_version` dispatch input (or an
+explicit Chart.yaml appVersion for chart-tag pushes). The checked-in chart has
+development defaults; it does not claim to be a dated release. No version write-back
+commits or channel-state files are needed.
+
+## Releasing
+
+1. Land this change on `main` before cutting the 0.7.7 alpha.3 candidate.
+ Leave 0.7.6, 0.7.7-alpha.1 and 0.7.7-alpha.2 unchanged. Carry it to the 0.7.7 release branch
+ when that branch is cut; do not backport the transition to 0.7.6.
+2. Generate the canonical tag from the UTC build day, once, when starting the release:
+ `tag="v$(date -u +%Y.%-m.%-d)-alpha"` (omit `-alpha` for stable).
+ Push that tag at the intended release commit; retries reuse it, even after midnight.
+ In `publish.yml`, `COMPATIBILITY_CHANNEL: alpha` selects alpha releases and
+ `COMPATIBILITY_VERSION: 0.7.7-alpha.3` supplies the legacy alias. No date edit is
+ needed. Before a subsequent release, advance the legacy alias; for stable set
+ the channel to `stable` and alias to `0.7.7`. Clear the alias to opt out.
+3. Push only the canonical tag. The workflow creates/verifies the legacy Git
+ tag without force, publishes both Docker names against one manifest, and
+ packages both Helm versions pointing to the canonical image.
+4. Verify both Docker names resolve to the same digest and check the canonical
+ GitHub Release and its assets. There is no duplicate legacy GitHub Release.
+
+The alias applies only to tagged 2026 releases in the selected channel. Untagged
+builds and the other channel never receive it. Advance the legacy alias before
+each new release: leaving an already-used alias fails safely rather than moving it. Manually
+pushing the alias does not trigger another build or deployment. An existing alias
+on another commit blocks publication; retries never move it. Platform-image
+digests may have been built before that check, but named images and charts have not.
+
+## Version names
+
+Use unpadded `YYYY.M.D-alpha` for alpha releases and `YYYY.M.D` for stable releases.
+
+**Floating Docker channel promotion is temporarily paused.** Neither release
+updates `latest` or `stable` while we validate the CalVer rollout. Existing channel
+tags are left pointing to their previous images; they are not deleted. Test using
+explicit CalVer image tags (or the temporary versioned compatibility aliases).
+Re-enabling channel promotion requires a separate workflow change after validation.
+Nightly tags and release/deployment jobs are unchanged.
+There are no numbered canonical prereleases, beta/RC tags or hotfix suffixes.
+Only the temporary legacy compatibility alias keeps its old numbered format.
+
+The date distinguishes releases: publish at most one alpha and one stable per
+UTC day. A retry reuses the same tag and commit; a different release uses a new
+date, not an incremented suffix or a moved tag. Cut release branches as usual;
+daily fixes do not create new ones.
+
+## January
+
+Stop issuing legacy aliases and clear the two compatibility settings. The
+workflow only emits them for 2026 dates. Keep historical tags, images and chart
+packages for pinned installations and rollback. The temporary alias steps can
+then be removed from the workflow—there is no library or registry to migrate.
diff --git a/lib/semver.rb b/lib/calver.rb
similarity index 74%
rename from lib/semver.rb
rename to lib/calver.rb
index 3de91ddb36..e4359a9551 100644
--- a/lib/semver.rb
+++ b/lib/calver.rb
@@ -1,5 +1,6 @@
-# Light wrapper around Gem::Version to support tag parsing
-class Semver
+# Wraps Gem::Version for CalVer release tags, while accepting legacy tags and
+# development versions. Numeric version ordering does not validate calendar dates.
+class Calver
attr_reader :version
def initialize(version_string)
diff --git a/test/controllers/cash_flow_preview_test.rb b/test/controllers/cash_flow_preview_test.rb
index 82bf4bdcfe..c7cacba96d 100644
--- a/test/controllers/cash_flow_preview_test.rb
+++ b/test/controllers/cash_flow_preview_test.rb
@@ -27,7 +27,7 @@ class CashFlowPreviewTest < ActionDispatch::IntegrationTest
get root_path
assert_response :success
assert_select "#cashflow-sankey-chart + form[action='#{dashboard_preferences_path}'] + #cashflow-preview", count: 1
- assert_select "#cashflow-preview[data-sankey-preview-sure-version-value=?]", Rails.root.join(".sure-version").read.strip
+ assert_select "#cashflow-preview[data-sankey-preview-sure-version-value=?]", Sure.version.to_s
assert_select "#cashflow-preview [data-controller='preview-sankey-chart']", count: 2
assert_select "#cashflow-preview [data-cash-flow-url-value*='/dashboard/cash_flow?']", count: 1
assert_equal legacy, css_select("[data-controller='sankey-chart']").map { |chart| chart["data-sankey-chart-data-value"] }
@@ -93,7 +93,7 @@ class CashFlowPreviewTest < ActionDispatch::IntegrationTest
Rails.configuration.x.posthog.stubs(:development_enabled).returns(true)
get root_path
assert_select "head script", text: /posthog.init\('configured-test-project'/
- assert_select "head script", text: /client.register\(\{ sure_version: #{Regexp.escape(Rails.root.join(".sure-version").read.strip.to_json)}/
+ assert_select "head script", text: /client.register\(\{ sure_version: #{Regexp.escape(Sure.version.to_s.to_json)}/
end
test "managed app and demo use the configured environment survey without the shared feedback client" do
diff --git a/test/controllers/release_highlights_controller_test.rb b/test/controllers/release_highlights_controller_test.rb
index ffc847cf2d..b55620def5 100644
--- a/test/controllers/release_highlights_controller_test.rb
+++ b/test/controllers/release_highlights_controller_test.rb
@@ -2,6 +2,7 @@ require "test_helper"
class ReleaseHighlightsControllerTest < ActionDispatch::IntegrationTest
setup do
+ Sure.stubs(:version).returns(Calver.new("2026.11.30"))
sign_in @user = users(:family_admin)
@user.update!(preferences: {})
end
@@ -48,24 +49,24 @@ class ReleaseHighlightsControllerTest < ActionDispatch::IntegrationTest
end
test "dismiss marks the given tag as seen" do
- patch release_highlight_dismiss_path, params: { tag: "v1.2.3" }, as: :json
+ patch release_highlight_dismiss_path, params: { tag: "v2026.11.30" }, as: :json
assert_response :ok
- assert_equal "v1.2.3", @user.reload.last_seen_release_tag
+ assert_equal "v2026.11.30", @user.reload.last_seen_release_tag
end
- test "dismissing a hotfix after its base release survives the next request" do
- @user.update!(preferences: { "last_seen_release_tag" => "v0.7.5" })
- Sure.stubs(:version).returns(Semver.new("0.7.5-hotfix.1"))
+ test "dismissing a newer CalVer release survives the next request and rollback" do
+ @user.update!(preferences: { "last_seen_release_tag" => "v2026.11.30" })
+ Sure.stubs(:version).returns(Calver.new("2026.12.1"))
- patch release_highlight_dismiss_path, params: { tag: "v0.7.5-hotfix.1" }, as: :json
+ patch release_highlight_dismiss_path, params: { tag: "v2026.12.1" }, as: :json
assert_response :ok
Provider::Registry.expects(:get_provider).never
get release_highlight_path
assert_response :no_content
- Sure.stubs(:version).returns(Semver.new("0.7.5"))
+ Sure.stubs(:version).returns(Calver.new("2026.11.30"))
get release_highlight_path
assert_response :no_content
end
diff --git a/test/lib/calver_test.rb b/test/lib/calver_test.rb
new file mode 100644
index 0000000000..ff5b46bffe
--- /dev/null
+++ b/test/lib/calver_test.rb
@@ -0,0 +1,37 @@
+require "test_helper"
+
+class CalverTest < ActiveSupport::TestCase
+ test "preserves calendar release identity" do
+ version = Calver.from_release_tag("v2026.10.28")
+
+ assert_equal "2026.10.28", version.to_s
+ assert_equal "v2026.10.28", version.to_release_tag
+ refute version.prerelease?
+ end
+
+ test "orders calendar releases and numbered prereleases numerically" do
+ assert Calver.new("2026.10.28") > Calver.new("2026.9.30")
+ assert Calver.new("2027.1.1") > Calver.new("2026.12.31")
+ assert Calver.new("2026.10.28-rc.2") < Calver.new("2026.10.28-rc.10")
+ assert Calver.new("2026.10.28-rc.10") < Calver.new("2026.10.28")
+ assert Calver.new("2026.10.28-rc.2").prerelease?
+ assert_equal Calver.new("2026.10.28"), Calver.from_release_tag("v2026.10.28")
+ end
+
+ test "retains legacy release tags used in release highlights history" do
+ [ "0.7.5", "0.7.5-hotfix.1", "0.7.6-alpha.10" ].each do |tag|
+ version = Calver.from_release_tag("v#{tag}")
+
+ assert_equal Gem::Version.new(tag), version.version
+ assert_equal "v#{tag}", version.to_release_tag
+ end
+ end
+
+ test "accepts development fallback without a packaged release" do
+ version = Calver.new("0.0.0-dev")
+
+ assert_equal "0.0.0-dev", version.to_s
+ assert version.prerelease?
+ assert version < Calver.new("2026.10.28")
+ end
+end
diff --git a/test/lib/sure_version_test.rb b/test/lib/sure_version_test.rb
new file mode 100644
index 0000000000..cf28556827
--- /dev/null
+++ b/test/lib/sure_version_test.rb
@@ -0,0 +1,35 @@
+require "test_helper"
+
+class SureVersionTest < ActiveSupport::TestCase
+ test "source checkouts without generated metadata have a valid development version" do
+ path = Rails.root.join(".sure-version")
+ Rails.root.stubs(:join).with(".sure-version").returns(path)
+ path.stubs(:read).raises(Errno::ENOENT)
+ Sure.stubs(:commit_sha).returns("abc123def")
+ assert_equal "0.0.0-dev.abc123def", Sure.version.to_s
+ assert Sure.version.prerelease?
+ end
+
+ test "blank metadata preserves the commit and missing commits use unknown" do
+ path = Rails.root.join(".sure-version")
+ Rails.root.stubs(:join).with(".sure-version").returns(path)
+ [ "", " \n" ].each do |content|
+ path.stubs(:read).returns(content)
+ Sure.stubs(:commit_sha).returns("123abc")
+ assert_equal "0.0.0-dev.123abc", Sure.version.to_s
+ Sure.stubs(:commit_sha).returns(nil)
+ assert_equal "0.0.0-dev.unknown", Sure.version.to_s
+ end
+ path.stubs(:read).raises(Errno::ENOENT)
+ assert_equal "0.0.0-dev.unknown", Sure.version.to_s
+ end
+
+ test "packaged applications report the generated release identity" do
+ path = Rails.root.join(".sure-version")
+ Rails.root.stubs(:join).with(".sure-version").returns(path)
+ path.stubs(:read).returns("2026.10.28\n")
+ assert_equal "2026.10.28", Sure.version.to_s
+ assert_equal "v2026.10.28", Sure.version.to_release_tag
+ assert_not Sure.version.prerelease?
+ end
+end
diff --git a/test/models/release_highlights_test.rb b/test/models/release_highlights_test.rb
index 7b56936098..105a550023 100644
--- a/test/models/release_highlights_test.rb
+++ b/test/models/release_highlights_test.rb
@@ -34,14 +34,14 @@ class ReleaseHighlightsTest < ActiveSupport::TestCase
test "dismissing a hotfix preserves the legacy base release acknowledgement" do
@user.update!(preferences: { "last_seen_release_tag" => "v0.7.5", "custom_preference" => true })
- Sure.stubs(:version).returns(Semver.new("0.7.5-hotfix.1"))
+ Sure.stubs(:version).returns(Calver.new("0.7.5-hotfix.1"))
assert_equal "v0.7.5-hotfix.1", ReleaseHighlights.pending_tag_for(@user)
@user.mark_release_seen!("v0.7.5-hotfix.1")
assert_nil ReleaseHighlights.pending_tag_for(@user.reload)
assert @user.preferences["custom_preference"]
- Sure.stubs(:version).returns(Semver.new("0.7.5"))
+ Sure.stubs(:version).returns(Calver.new("0.7.5"))
assert_nil ReleaseHighlights.pending_tag_for(@user)
end
@@ -59,12 +59,12 @@ class ReleaseHighlightsTest < ActiveSupport::TestCase
@user.reload
[ "0.7.6-alpha.1", "0.7.5-hotfix.1" ].each do |version|
- Sure.stubs(:version).returns(Semver.new(version))
+ Sure.stubs(:version).returns(Calver.new(version))
assert_nil ReleaseHighlights.pending_tag_for(@user)
end
assert_equal 2, @user.preferences.fetch("seen_release_tags").size
- Sure.stubs(:version).returns(Semver.new("0.7.6"))
+ Sure.stubs(:version).returns(Calver.new("0.7.6"))
assert_equal "v0.7.6", ReleaseHighlights.pending_tag_for(@user)
end
@@ -92,7 +92,7 @@ class ReleaseHighlightsTest < ActiveSupport::TestCase
end
test "every release is eligible while the rollout is being tested" do
- assert ReleaseHighlights.eligible?(Semver.new("0.7.5-alpha.7"))
- assert ReleaseHighlights.eligible?(Semver.new("0.7.4"))
+ assert ReleaseHighlights.eligible?(Calver.new("0.7.5-alpha.7"))
+ assert ReleaseHighlights.eligible?(Calver.new("0.7.4"))
end
end
diff --git a/test/system/release_highlights_test.rb b/test/system/release_highlights_test.rb
index 7b7aae2c97..0da3ab0dd7 100644
--- a/test/system/release_highlights_test.rb
+++ b/test/system/release_highlights_test.rb
@@ -4,7 +4,7 @@ class ReleaseHighlightsSystemTest < ApplicationSystemTestCase
setup do
@user = users(:family_admin)
@user.update!(preferences: { "last_seen_release_tag" => "v0.7.5" })
- Sure.stubs(:version).returns(Semver.new("0.7.5-hotfix.1"))
+ Sure.stubs(:version).returns(Calver.new("0.7.5-hotfix.1"))
Provider::Github.any_instance.stubs(:fetch_release_notes).with("v0.7.5-hotfix.1").returns(
avatar: nil,
diff --git a/test/workflows/mobile_release_workflow_test.rb b/test/workflows/mobile_release_workflow_test.rb
new file mode 100644
index 0000000000..0aa46471a5
--- /dev/null
+++ b/test/workflows/mobile_release_workflow_test.rb
@@ -0,0 +1,97 @@
+require "test_helper"
+require "open3"
+require "tmpdir"
+require "yaml"
+
+class MobileReleaseWorkflowTest < ActiveSupport::TestCase
+ test "Android preserves alpha identity while iOS uses the numeric version" do
+ %w[2026.10.31-alpha 2026.10.31].each do |version|
+ { "build-android" => version, "build-ios" => "2026.10.31" }.each do |job, name|
+ result = resolve("flutter-build", job, ref: "v#{version}")
+ assert_equal "#{version}\n", result[:metadata]
+ assert_includes result[:output], "SURE_BUILD_NAME=#{name}\n"
+ end
+ result = resolve("ios-testflight", "build-and-upload", ref: "v#{version}")
+ assert_equal "#{version}\n", result[:metadata]
+ assert_includes result[:output], "ios_version=2026.10.31\n"
+ end
+ end
+
+ test "mobile-only tag and manual callers pass the selected version to every build" do
+ caller_jobs = workflow("mobile-release").fetch("jobs")
+ %w[build testflight].each do |job|
+ assert_includes caller_jobs.fetch(job).fetch("needs"), "prepare_release"
+ assert_equal "${{ needs.prepare_release.outputs.release_version }}", caller_jobs.fetch(job).fetch("with").fetch("app_version")
+ end
+ [ [ "mobile-v2026.11.1-alpha", "v2026.11.1-alpha" ],
+ [ "main", "v2026.11.1-p202611011234" ] ].each do |ref, selected|
+ [ [ "flutter-build", "build-android", selected.delete_prefix("v") ],
+ [ "flutter-build", "build-ios", "2026.11.1" ],
+ [ "ios-testflight", "build-and-upload", "2026.11.1" ] ].each do |file, job, name|
+ result = resolve(file, job, ref: ref, selected: selected)
+ assert_equal "#{selected.delete_prefix('v')}\n", result[:metadata]
+ assert_includes result[:output], "=#{name}\n"
+ end
+ end
+ end
+
+ test "standalone branch builds retain pubspec fallback" do
+ [ [ "flutter-build", "build-android" ], [ "flutter-build", "build-ios" ],
+ [ "ios-testflight", "build-and-upload" ] ].each do |file, job|
+ result = resolve(file, job, ref: "main")
+ assert_equal "0.6.9\n", result[:metadata]
+ assert_includes result[:output], "=0.6.9\n"
+ end
+ end
+
+ test "automatic TestFlight accepts only canonical calendar tags" do
+ %w[v2026.10.31 v2026.10.31-alpha v2028.2.29-alpha].each do |ref|
+ assert eligible?("push", "refs/tags/#{ref}"), ref
+ end
+ %w[v0.7.7-alpha.2 v2026.10.31-beta v2026.10.31-rc.1 v2026.10.31-alpha.2
+ v2026.02.1 v2026.2.29 v2026.4.31 v2026.13.1 vgarbage].each do |ref|
+ assert_not eligible?("push", "refs/tags/#{ref}"), ref
+ end
+ assert_not eligible?("push", "refs/heads/main")
+ job = workflow("ios-testflight").fetch("jobs").fetch("build-and-upload")
+ assert_includes job.fetch("needs"), "validate-release"
+ assert_equal "needs.validate-release.outputs.eligible == 'true'", job.fetch("if")
+ end
+
+ test "TestFlight preserves explicit mobile callers and non-push events" do
+ assert eligible?("push", "refs/tags/mobile-v2026.11.1-alpha", "v2026.11.1-alpha")
+ assert_not eligible?("push", "refs/tags/mobile-v2026.11.1-alpha")
+ assert_not eligible?("push", "refs/tags/v2026.11.1-beta", "v2026.11.1")
+ assert eligible?("workflow_dispatch", "refs/heads/main")
+ assert eligible?("workflow_dispatch", "refs/heads/main", "v2026.11.1-p202611011234")
+ end
+
+ private
+ def workflow(name)
+ YAML.load_file(Rails.root.join(".github/workflows/#{name}.yml"))
+ end
+
+ def execute(file, job, step_name, env)
+ Dir.mktmpdir do |dir|
+ FileUtils.mkdir_p(File.join(dir, "mobile"))
+ File.write(File.join(dir, "mobile/pubspec.yaml"), "version: 0.6.9+42\n")
+ output_path = File.join(dir, "output")
+ env = env.merge("GITHUB_ENV" => output_path, "GITHUB_OUTPUT" => output_path)
+ script = workflow(file).fetch("jobs").fetch(job).fetch("steps").find { |step| step["name"] == step_name }.fetch("run")
+ output, status = Open3.capture2e(env, "bash", "-c", script, chdir: dir)
+ assert status.success?, output
+ metadata_path = File.join(dir, ".sure-version")
+ { output: File.read(output_path), metadata: File.exist?(metadata_path) ? File.read(metadata_path) : nil }
+ end
+ end
+
+ def resolve(file, job, ref:, selected: "")
+ execute(file, job, "Resolve app version", "GITHUB_REF_TYPE" => ref == "main" ? "branch" : "tag",
+ "GITHUB_REF_NAME" => ref, "APP_VERSION_INPUT" => selected)
+ end
+
+ def eligible?(event, ref, selected = "")
+ execute("ios-testflight", "validate-release", "Validate automatic release tag",
+ "GITHUB_EVENT_NAME" => event, "GITHUB_REF" => ref, "APP_VERSION_INPUT" => selected)[:output].include?("eligible=true\n")
+ end
+end
diff --git a/test/workflows/release_workflow_test.rb b/test/workflows/release_workflow_test.rb
new file mode 100644
index 0000000000..7362eac78b
--- /dev/null
+++ b/test/workflows/release_workflow_test.rb
@@ -0,0 +1,254 @@
+require "test_helper"
+require "open3"
+require "tmpdir"
+require "yaml"
+
+class ReleaseWorkflowTest < ActiveSupport::TestCase
+ setup do
+ skip "Release shell steps target Linux runners with GNU date" unless RUBY_PLATFORM.include?("linux")
+ end
+
+ test "canonical tag publishes while its compatibility alias is a no-op" do
+ with_repo do |dir|
+ success, output = resolve(dir, "2026.10.30-alpha")
+ assert success
+ %w[release=true compatibility_version=0.7.7-alpha.3 type=raw,value=2026.10.30-alpha type=raw,value=0.7.7-alpha.3].each { |line| assert_includes output, line }
+ success, output = resolve(dir, "2026.10.28", ref: "refs/tags/v0.7.7-alpha.3")
+ assert success
+ assert_includes output, "publish=false"
+ assert_includes output, "release=false"
+ assert_not resolve(dir, "2026.10.28", ref: "refs/tags/vgarbage").first
+ end
+ end
+
+ test "alpha and stable releases publish explicit versions without floating channels" do
+ with_repo do |dir|
+ %w[2026.11.2-alpha 2026.11.2].each do |version|
+ success, output = resolve(dir, version)
+ assert success, version
+ assert_includes output, "release=true"
+ assert_includes output, "type=raw,value=#{version}"
+ assert_not_includes output, "type=raw,value=stable"
+ assert_not_includes output, "type=raw,value=latest"
+ end
+ end
+ end
+
+ test "Docker metadata disables automatic latest tagging" do
+ metadata = workflow.fetch("jobs").fetch("build").fetch("steps").find { |step| step["id"] == "meta" }.fetch("with")
+ assert_equal "latest=false", metadata.fetch("flavor")
+ assert_equal "${{ needs.prepare.outputs.image_tags }}", metadata.fetch("tags")
+ end
+
+ test "compatibility channel follows release dates without matching other channels" do
+ with_repo do |dir|
+ %w[alpha stable].each do |phase|
+ suffix = phase == "stable" ? "" : "-#{phase}"
+ version = "2026.11.2#{suffix}"
+ legacy = phase == "stable" ? "0.7.7" : "0.7.7-alpha.4"
+ success, output = resolve(dir, version, extra_env: { "COMPATIBILITY_CHANNEL" => phase, "COMPATIBILITY_VERSION" => legacy })
+ assert success
+ assert_includes output, "compatibility_version=#{legacy}"
+ end
+ %w[2026.10.31-alpha 2026.11.2-alpha 2026.12.31-alpha].each do |version|
+ success, output = resolve(dir, version, extra_env: { "BUILD_DATE" => "2027.1.2" })
+ assert success
+ assert_includes output, "version=#{version}"
+ assert_includes output, "compatibility_version=0.7.7-alpha.3"
+ end
+ %w[2026.10.30 2026.10.31].each do |version|
+ success, output = resolve(dir, version)
+ assert success
+ assert_not_includes output, "type=raw,value=0.7.7"
+ end
+ success, output = resolve(dir, "2026.10.30-alpha", ref: "refs/heads/main",
+ extra_env: { "BUILD_DATE" => "2026.10.30", "GITHUB_RUN_NUMBER" => "2" })
+ assert success
+ assert_not_includes output, "compatibility_version=0.7.7"
+ end
+ end
+
+ test "invalid dates and all canonical suffixes other than alpha are rejected" do
+ with_repo do |dir|
+ %w[2026.11.02 2026.11.0 2026.2.29 2026.4.31 2026.10.28-hotfix.1 2026.10.28-1 2026.10.30-alpha.2 2026.10.30-alpha.0 2026.10.30-beta 2026.10.30-rc.1].each do |version|
+ assert_not resolve(dir, version).first, version
+ end
+ end
+ end
+
+ test "non-release builds and January do not emit compatibility tags" do
+ with_repo do |dir|
+ [ "push", "schedule", "workflow_dispatch" ].each do |event|
+ success, output = resolve(dir, "2026.10.28", event: event, ref: "refs/heads/main")
+ assert success
+ assert_includes output, "release=false"
+ assert_includes output, "version=2026.10.28-alpha"
+ assert_not_includes output, "type=raw,value=latest"
+ assert_not_includes output, "type=raw,value=stable"
+ assert_not_includes output, "compatibility_version=0.7.7"
+ if event == "schedule"
+ assert_includes output, "type=schedule,pattern=nightly"
+ assert_includes output, "type=raw,value=2026.10.28-nightly"
+ assert_not_includes output, "pattern=nightly-"
+ else
+ assert_includes output, "type=raw,value=sha-#{git!(dir, 'rev-parse', 'HEAD').strip}"
+ end
+ end
+ success, output = resolve(dir, "2027.1.1", extra_env: { "COMPATIBILITY_CHANNEL" => "stable" })
+ assert success
+ assert_not_includes output, "type=raw,value=0.7.7"
+ assert_includes output, "type=raw,value=2027.1.1"
+ assert_not_includes output, "type=raw,value=stable"
+ assert_not_includes output, "type=raw,value=latest"
+ end
+ end
+
+ test "manual tag builds preserve selected identity without publishing a release" do
+ with_repo do |dir|
+ workflow_sha = git!(dir, "rev-parse", "HEAD").strip
+ git!(dir, "commit", "--allow-empty", "-m", "selected commit")
+ selected_sha = git!(dir, "rev-parse", "HEAD").strip
+ %w[2026.11.2 2026.11.2-alpha].each do |version|
+ git!(dir, "tag", "-a", "v#{version}", "-m", "release")
+ [ "v#{version}", "refs/tags/v#{version}" ].each do |selected_ref|
+ success, output = resolve(dir, version, event: "workflow_dispatch", ref: "refs/heads/main",
+ extra_env: { "SELECTED_REF" => selected_ref, "GITHUB_SHA" => workflow_sha })
+ assert success, output
+ assert_includes output, "version=#{version}\n"
+ assert_includes output, "release=false"
+ assert_includes output, "compatibility_version=\n"
+ assert_includes output, "type=raw,value=sha-#{selected_sha}"
+ assert_not_includes output, "type=raw,value=sha-#{workflow_sha}"
+ assert_not_includes output, "type=raw,value=#{version}"
+ end
+ end
+ [ "main", "refs/heads/main", selected_sha ].each do |selected_ref|
+ success, output = resolve(dir, "unused", event: "workflow_dispatch", ref: "refs/tags/v2026.11.2",
+ extra_env: { "SELECTED_REF" => selected_ref })
+ assert success, output
+ assert_includes output, "version=2026.10.28-alpha"
+ assert_includes output, "release=false"
+ end
+ %w[v2026.11.31 v2026.11.2-beta v0.7.7].each do |tag|
+ git!(dir, "tag", tag)
+ assert_not resolve(dir, "unused", event: "workflow_dispatch", ref: "refs/heads/main",
+ extra_env: { "SELECTED_REF" => tag }).first
+ end
+ end
+ end
+
+ test "non-force alias step accepts retries and annotated tags but not other commits" do
+ with_repo do |dir|
+ remote = File.join(dir, "remote.git")
+ git!(dir, "init", "--bare", remote)
+ git!(dir, "remote", "add", "origin", remote)
+ 2.times { assert run_step(dir, "merge", "compatibility", "COMPATIBILITY_VERSION" => "0.7.7-alpha.3").first }
+ git!(dir, "tag", "-a", "v0.7.7", "-m", "annotated")
+ git!(dir, "push", "origin", "v0.7.7")
+ assert run_step(dir, "merge", "compatibility", "COMPATIBILITY_VERSION" => "0.7.7").first
+ original = git!(remote, "rev-parse", "v0.7.7-alpha.3")
+ git!(dir, "commit", "--allow-empty", "-m", "different")
+ success, output = run_step(dir, "merge", "compatibility", "COMPATIBILITY_VERSION" => "0.7.7-alpha.3")
+ assert_not success
+ assert_includes output, "refusing to move"
+ assert_equal original, git!(remote, "rev-parse", "v0.7.7-alpha.3")
+ end
+ end
+
+ test "release tag wins over build date and is embedded without a tracked file" do
+ with_repo do |dir|
+ success, output = resolve(dir, "2026.10.28", extra_env: { "BUILD_DATE" => "2026.11.1" })
+ assert success
+ assert_includes output, "version=2026.10.28"
+ assert_not File.exist?(File.join(dir, ".sure-version"))
+ assert run_step(dir, "build", "version_file", "VERSION" => "2026.10.28").first
+ assert_equal "2026.10.28\n", File.read(File.join(dir, ".sure-version"))
+ end
+ end
+
+ test "workflow creation date drives branch builds across month and year boundaries" do
+ with_repo do |dir|
+ gh = File.join(dir, "gh")
+ File.write(gh, "#!/bin/sh\nprintf '%s\\n' \"$CREATED_AT\"\n")
+ File.chmod(0755, gh)
+ env_file = File.join(dir, "env")
+ { "2026-11-01T00:00:01Z" => "2026.11.1", "2027-01-01T00:00:01Z" => "2027.1.1" }.each do |created, date|
+ File.write(env_file, "")
+ env = { "PATH" => "#{dir}:#{ENV.fetch('PATH')}", "CREATED_AT" => created,
+ "GITHUB_REPOSITORY" => "test/repo", "GITHUB_RUN_ID" => "42", "GITHUB_ENV" => env_file }
+ 2.times { assert run_step(dir, "prepare", "build_date", env).first }
+ assert_equal [ "BUILD_DATE=#{date}", "BUILD_DATE=#{date}" ], File.readlines(env_file, chomp: true)
+ success, output = resolve(dir, date, ref: "refs/heads/main", extra_env: { "BUILD_DATE" => date })
+ assert success
+ assert_includes output, "version=#{date}-alpha"
+ assert_not_includes output, "compatibility_version=0.7.7"
+ 2.times do
+ success, output = resolve(dir, date, event: "schedule", ref: "refs/heads/main", extra_env: { "BUILD_DATE" => date })
+ assert success
+ assert_includes output, "type=raw,value=#{date}-nightly"
+ assert_includes output, "type=raw,value=sha-#{git!(dir, 'rev-parse', 'HEAD').strip}"
+ assert_includes output, "type=schedule,pattern=nightly"
+ assert_not_includes output, "pattern=nightly-"
+ end
+ end
+ end
+ end
+
+ test "chart-only release requires an existing image instead of development defaults" do
+ with_repo do |dir|
+ FileUtils.mkdir_p(File.join(dir, "charts/sure"))
+ FileUtils.cp(Rails.root.join("charts/sure/Chart.yaml"), File.join(dir, "charts/sure/Chart.yaml"))
+ script = YAML.load_file(Rails.root.join(".github/workflows/chart-release.yml"))
+ .fetch("jobs").fetch("prepare_release").fetch("steps").find { |step| step["id"] == "tag" }.fetch("run")
+ output_file = File.join(dir, "output")
+ env = { "GITHUB_EVENT_NAME" => "push", "GITHUB_REF_NAME" => "chart-v2026.11.2",
+ "GITHUB_OUTPUT" => output_file, "APP_VERSION_INPUT" => "" }
+ output, status = Open3.capture2e(env, "bash", "-c", script, chdir: dir)
+ assert_not status.success?
+ assert_includes output, "Select an existing immutable"
+ env["APP_VERSION_INPUT"] = "2026.11.1-alpha"
+ output, status = Open3.capture2e(env, "bash", "-c", script, chdir: dir)
+ assert status.success?, output
+ assert_includes File.read(output_file), "app_version=2026.11.1-alpha"
+ assert_includes File.read(output_file), "chart_version=2026.11.2"
+ end
+ end
+
+ private
+ def workflow
+ @workflow ||= YAML.load_file(Rails.root.join(".github/workflows/publish.yml"))
+ end
+
+ def run_step(dir, job, id, env)
+ script = workflow.fetch("jobs").fetch(job).fetch("steps").find { |step| step["id"] == id }.fetch("run")
+ output, status = Open3.capture2e(env, "bash", "-c", script, chdir: dir)
+ [ status.success?, output ]
+ end
+
+ def resolve(dir, version, event: "push", ref: "refs/tags/v#{version}", extra_env: {})
+ path = File.join(dir, "output")
+ File.write(path, "")
+ env = { "COMPATIBILITY_CHANNEL" => "alpha", "COMPATIBILITY_VERSION" => "0.7.7-alpha.3",
+ "BUILD_DATE" => "2026.10.28", "GITHUB_RUN_NUMBER" => "42",
+ "GITHUB_EVENT_NAME" => event,
+ "SELECTED_REF" => ref, "GITHUB_REF" => ref, "GITHUB_OUTPUT" => path }.merge(extra_env)
+ success, error = run_step(dir, "prepare", "release", env)
+ [ success, File.read(path) + error ]
+ end
+
+ def with_repo
+ Dir.mktmpdir do |dir|
+ git!(dir, "init")
+ git!(dir, "config", "user.email", "[email protected]")
+ git!(dir, "config", "user.name", "Release Test")
+ git!(dir, "commit", "--allow-empty", "-m", "candidate")
+ yield dir
+ end
+ end
+
+ def git!(dir, *args)
+ output, status = Open3.capture2e("git", *args, chdir: dir)
+ assert status.success?, output
+ output
+ end
+end