fix(ci): derive version from Cargo.toml in release artifacts#804
fix(ci): derive version from Cargo.toml in release artifacts#804
Conversation
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>
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughCI workflows now extract the Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Review GateCommit:
|
There was a problem hiding this comment.
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
versionfromCargo.tomlinrelease.ymland inject it into generated macOSInfo.plist. - Update
flatpak.ymlto rewritemetainfo.xmlrelease version (and date) during CI based onCargo.toml. - Add a note to
metainfo.xmlindicating 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.
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
.github/workflows/flatpak.yml.github/workflows/release.ymlflatpak/org.dash.DashEvoTool.metainfo.xml
- 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>
There was a problem hiding this comment.
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.
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>
There was a problem hiding this comment.
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.
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>
There was a problem hiding this comment.
🧹 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-stepAlso 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
📒 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>
Summary
Info.plistversion fields now derived fromCargo.tomlat build time instead of hardcoded1.0.0CFBundleShortVersionString(marketing version): stripped semver from Cargo.toml (e.g.,1.0.0)CFBundleVersion(build number): CIgithub.run_number— monotonically increasing, distinguishes dev/rc/release buildsmetainfo.xmlrelease version auto-synced fromCargo.tomlby CIcargo metadata+jq— proper TOML parsing, zero new dependenciesrelease.published_atfor release events, commit date for tags, current date otherwiseTest plan
.appbundle hasCFBundleShortVersionString=1.0.0andCFBundleVersion=<run_number>metainfo.xmlcontainsversion="1.0.0-dev"with correct date1.0.0-dev→ plist gets1.0.0+build→ plist gets clean numeric🤖 Co-authored by Claudius the Magnificent AI Agent
Summary by CodeRabbit