Skip to content

fix(ci): derive version from Cargo.toml in release artifacts#804

Merged
lklimek merged 6 commits intov1.0-devfrom
fix/unify-version-source
Mar 30, 2026
Merged

fix(ci): derive version from Cargo.toml in release artifacts#804
lklimek merged 6 commits intov1.0-devfrom
fix/unify-version-source

Conversation

@lklimek
Copy link
Copy Markdown
Contributor

@lklimek lklimek commented Mar 30, 2026

Summary

  • macOS Info.plist version fields now derived from Cargo.toml at build time instead of hardcoded 1.0.0
    • CFBundleShortVersionString (marketing version): stripped semver from Cargo.toml (e.g., 1.0.0)
    • CFBundleVersion (build number): CI github.run_number — monotonically increasing, distinguishes dev/rc/release builds
  • Flatpak metainfo.xml release version auto-synced from Cargo.toml by CI
  • Version extraction uses cargo metadata + jq — proper TOML parsing, zero new dependencies
  • Prerelease and build metadata suffixes stripped for Apple plist compliance with format validation
  • Flatpak date uses release.published_at for release events, commit date for tags, current date otherwise
  • Validation with fast-fail error handling on all extraction steps

Test plan

  • Trigger release workflow — verify macOS .app bundle has CFBundleShortVersionString=1.0.0 and CFBundleVersion=<run_number>
  • Trigger flatpak workflow — verify metainfo.xml contains version="1.0.0-dev" with correct date
  • Verify prerelease suffix stripping: 1.0.0-dev → plist gets 1.0.0
  • Verify build metadata stripping: version with +build → plist gets clean numeric
  • Verify failure mode: malformed version → workflow fails with clear error

🤖 Co-authored by Claudius the Magnificent AI Agent

Summary by CodeRabbit

  • Chores
    • Automatically extract the app version from the project manifest for macOS and Flatpak builds.
    • Populate macOS build version fields dynamically instead of a fixed value; include build number as CFBundleVersion.
    • Synchronize and update release version/date metadata across artifacts; added CI-origin note in Flatpak metadata.
    • Validate extracted version and fail the build if the value is missing or invalid.

macOS Info.plist CFBundleVersion/CFBundleShortVersionString and
Flatpak metainfo.xml release version were hardcoded to 1.0.0.
Now all derive from Cargo.toml at build time, making it the
single source of truth for version across all release artifacts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 957d2f9d-7bbd-4c2c-86da-bb625500122b

📥 Commits

Reviewing files that changed from the base of the PR and between 01b7f88 and 21fae07.

📒 Files selected for processing (2)
  • .github/workflows/flatpak.yml
  • .github/workflows/release.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/flatpak.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/release.yml

📝 Walkthrough

Walkthrough

CI workflows now extract the dash-evo-tool crate version via cargo metadata and inject it into packaging metadata, updating Flatpak metainfo.xml release attributes and populating macOS Info.plist bundle version fields during release builds.

Changes

Cohort / File(s) Summary
CI Workflow: Flatpak update
.github/workflows/flatpak.yml
Adds pre-install steps to install Rust, run cargo metadata and jq to read dash-evo-tool version, compute a release date (release published_at / tag commit date / today), use sed to update the first <release> version and date in flatpak/org.dash.DashEvoTool.metainfo.xml, and verify via grep; failures abort the job.
CI Workflow: macOS release
.github/workflows/release.yml
Adds id: version step in build-macos-arm64 and build-macos-x86 to extract crate version, derive numeric-only plist_version, validate it, and export version, plist_version, and build_number; updates generated macOS Info.plist values to use these outputs instead of a hardcoded "1.0.0".
Flatpak metadata comment
flatpak/org.dash.DashEvoTool.metainfo.xml
Inserted an XML comment indicating <releases> version/date fields are auto-synchronized from Cargo.toml by CI; no functional changes to release entries.
sequenceDiagram
    participant GH as GitHub Actions
    participant Rust as "Rust toolchain"
    participant Cargo as "cargo metadata"
    participant JQ as jq
    participant Shell as "shell (sed/grep)"
    participant Repo as "repo files"

    GH->>Rust: install toolchain
    GH->>Cargo: run `cargo metadata`
    Cargo->>JQ: crate info JSON
    JQ->>GH: `dash-evo-tool` version
    GH->>Shell: compute release date (published_at / tag commit / now)
    GH->>Shell: update metainfo and emit outputs
    Shell->>Repo: modify `flatpak/org.dash.DashEvoTool.metainfo.xml` and generated Info.plist
    Shell->>GH: verify update (grep) -> success/fail
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibbled through Cargo's lore,
CI hopped up and checked the score.
Versions fetched and dates aligned,
Metainfo and plist entwined.
A tiny hop — release defined. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the primary change: deriving version numbers from Cargo.toml in release artifacts (macOS Info.plist and Flatpak metainfo.xml) instead of hardcoded values.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/unify-version-source

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lklimek lklimek requested a review from Copilot March 30, 2026 12:48
@lklimek lklimek marked this pull request as ready for review March 30, 2026 12:48
@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Mar 30, 2026

Review Gate

Commit: 8f9eac4f

  • Debounce: 1m ago (need 30m)

  • CI checks: checks still running (1 pending)

  • CodeRabbit review: comment found

  • Run review now (check to override)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates CI workflows so release artifact versioning is derived from Cargo.toml, aiming to make Cargo.toml the single source of truth for version values across macOS and Flatpak packaging metadata.

Changes:

  • Extract version from Cargo.toml in release.yml and inject it into generated macOS Info.plist.
  • Update flatpak.yml to rewrite metainfo.xml release version (and date) during CI based on Cargo.toml.
  • Add a note to metainfo.xml indicating version/date are CI-synced.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
flatpak/org.dash.DashEvoTool.metainfo.xml Documents that release metadata is synced from Cargo.toml by CI.
.github/workflows/release.yml Adds a step to extract Cargo version and uses it for CFBundleVersion/CFBundleShortVersionString in macOS artifacts.
.github/workflows/flatpak.yml Adds a CI step to rewrite Flatpak metainfo release version/date based on Cargo.toml.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/flatpak.yml Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/flatpak.yml:
- Around line 40-47: Ensure the metainfo sync step fails when parsing or
replacement doesn't apply: after extracting VERSION and DATE (symbols VERSION
and DATE) verify VERSION is non-empty and exit with failure if empty, run the
sed replacement targeting flatpak/org.dash.DashEvoTool.metainfo.xml and then
verify the file actually contains the new <release version="..."> string (or
check sed’s exit/changed status); if the replacement did not apply, emit an
error and exit 1 so the workflow fails instead of silently leaving stale
metadata.

In @.github/workflows/release.yml:
- Around line 174-179: The "Extract version from Cargo.toml" step currently
parses version with a brittle grep and may yield empty/incorrect VERSION;
replace the shell parsing with a deterministic TOML parse (e.g., run a short
Python snippet: import toml or tomllib to read Cargo.toml and print
package.version) or at minimum ensure you first locate the [package] table
before extracting version, and then validate VERSION is non-empty; if empty or
malformed, emit a clear error via echo and exit 1 so the job fails fast. Update
the step that sets VERSION (variable name VERSION and the run block) and mirror
the same fix for the other macOS job that performs the same extraction.
- Around line 279-281: Create a sanitized plist-safe version variable by
stripping any prerelease/build suffix from steps.version.outputs.version (e.g.,
drop "-dev" or "+meta") and validate it matches the Apple-required pattern of
three dot-separated integers; then replace direct uses of
steps.version.outputs.version when setting CFBundleVersion and
CFBundleShortVersionString with this sanitized variable. Specifically, add a
step that reads steps.version.outputs.version, applies a regex to capture only
the leading X.Y.Z numeric groups (discarding any "-..." or "+..." suffixes),
validate the result matches /^\d+\.\d+\.\d+$/ and fail the job if not, and
export that value (e.g., plist_safe_version) so the workflow keys
CFBundleVersion and CFBundleShortVersionString use plist_safe_version instead of
steps.version.outputs.version.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0a3a1153-ba74-433d-b4f9-3f423eb3aa3d

📥 Commits

Reviewing files that changed from the base of the PR and between 8e1786c and c90bf7c.

📒 Files selected for processing (3)
  • .github/workflows/flatpak.yml
  • .github/workflows/release.yml
  • flatpak/org.dash.DashEvoTool.metainfo.xml

Comment thread .github/workflows/flatpak.yml
Comment thread .github/workflows/release.yml
Comment thread .github/workflows/release.yml Outdated
- Strip prerelease suffix for CFBundleVersion (Apple requires numeric)
- Add validation: fail fast if version extraction returns empty
- Verify Flatpak metainfo.xml replacement actually applied
- Use git tag date for Flatpak releases, current date for dev builds

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/flatpak.yml Outdated
lklimek and others added 2 commits March 30, 2026 16:59
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tpak

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/release.yml
Comment thread .github/workflows/release.yml Outdated
Comment thread .github/workflows/flatpak.yml
Comment thread .github/workflows/flatpak.yml Outdated
Comment thread .github/workflows/release.yml
Comment thread .github/workflows/release.yml Outdated
CFBundleVersion (build number) now uses github.run_number for monotonic
increase across builds. CFBundleShortVersionString (marketing version)
stays as the stripped semver from Cargo.toml. This follows Apple's
recommended pattern and distinguishes dev/rc/release builds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/release.yml (1)

174-191: Consider de-duplicating the repeated version extraction block.

The same shell logic exists in both macOS jobs; centralizing it will reduce drift risk on future edits.

♻️ Suggested approach (YAML anchor)
+ x-extract-version-step: &extract-version-step
+   name: Extract version from Cargo.toml
+   id: version
+   run: |
+     VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "dash-evo-tool") | .version')
+     if [ -z "$VERSION" ]; then
+       echo "::error::Failed to extract version from Cargo.toml"
+       exit 1
+     fi
+     PLIST_VERSION=$(echo "$VERSION" | sed 's/[-+].*//')
+     if ! echo "$PLIST_VERSION" | grep -Eq '^[0-9]+(\.[0-9]+){0,2}$'; then
+       echo "::error::Invalid plist version '$PLIST_VERSION' derived from Cargo version '$VERSION'. Expected numeric x[.y[.z]]."
+       exit 1
+     fi
+     echo "version=$VERSION" >> $GITHUB_OUTPUT
+     echo "plist_version=$PLIST_VERSION" >> $GITHUB_OUTPUT
+     echo "build_number=${{ github.run_number }}" >> $GITHUB_OUTPUT
+
  jobs:
    build-macos-arm64:
      steps:
-       - name: Extract version from Cargo.toml
-         id: version
-         run: |
-           ...
+       - *extract-version-step
    build-macos-x86:
      steps:
-       - name: Extract version from Cargo.toml
-         id: version
-         run: |
-           ...
+       - *extract-version-step

Also applies to: 490-507

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/release.yml around lines 174 - 191, The "Extract version
from Cargo.toml" step (id: version) is duplicated across macOS jobs; centralize
it by extracting that shell block into a single reusable step and referencing it
from both jobs—either create a YAML anchor for the step and replace the
duplicated blocks with the anchor alias, or move the logic into a reusable
workflow/composite action that emits outputs (version, plist_version,
build_number) to be consumed by both macOS jobs; ensure the step still sets
VERSION and PLIST_VERSION, validates the plist regex, writes outputs to
$GITHUB_OUTPUT, and preserves the echo of "Extracted version: $VERSION ..." so
downstream steps that rely on those outputs keep working.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/release.yml:
- Around line 174-191: The "Extract version from Cargo.toml" step (id: version)
is duplicated across macOS jobs; centralize it by extracting that shell block
into a single reusable step and referencing it from both jobs—either create a
YAML anchor for the step and replace the duplicated blocks with the anchor
alias, or move the logic into a reusable workflow/composite action that emits
outputs (version, plist_version, build_number) to be consumed by both macOS
jobs; ensure the step still sets VERSION and PLIST_VERSION, validates the plist
regex, writes outputs to $GITHUB_OUTPUT, and preserves the echo of "Extracted
version: $VERSION ..." so downstream steps that rely on those outputs keep
working.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3de6f67a-ea64-4eac-8171-7d892b2541fe

📥 Commits

Reviewing files that changed from the base of the PR and between 8f9eac4 and 01b7f88.

📒 Files selected for processing (1)
  • .github/workflows/release.yml

- Move Rust toolchain install before cargo metadata in both macOS jobs
- Add Rust toolchain step to flatpak workflow for cargo metadata
- Quote $GITHUB_OUTPUT consistently
- Verify both version and date in flatpak metainfo check

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lklimek lklimek merged commit 99b13c1 into v1.0-dev Mar 30, 2026
10 checks passed
@lklimek lklimek deleted the fix/unify-version-source branch March 30, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants