Skip to content

Commit 99b13c1

Browse files
lklimekclaude
andauthored
fix(ci): derive version from Cargo.toml in release artifacts (#804)
* fix(ci): derive version from Cargo.toml in release artifacts 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> * fix(ci): harden version extraction and fix macOS plist format - 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> * fix(ci): use cargo metadata instead of grep for version extraction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): harden plist version validation and use release date for Flatpak Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): use CI run number for CFBundleVersion build number 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> * fix(ci): harden workflow ordering and quoting - 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> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8e1786c commit 99b13c1

3 files changed

Lines changed: 70 additions & 4 deletions

File tree

.github/workflows/flatpak.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,33 @@ jobs:
3737
- name: Check out code
3838
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3939

40+
- name: Install Rust toolchain (for cargo metadata)
41+
uses: dtolnay/rust-toolchain@stable
42+
43+
- name: Sync metainfo version from Cargo.toml
44+
run: |
45+
VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "dash-evo-tool") | .version')
46+
if [ -z "$VERSION" ]; then
47+
echo "::error::Failed to extract version from Cargo.toml"
48+
exit 1
49+
fi
50+
# Use release published date when available, tag commit date for tag pushes, current date otherwise
51+
if [ -n "${{ github.event.release.published_at }}" ]; then
52+
DATE=$(echo "${{ github.event.release.published_at }}" | cut -dT -f1)
53+
elif [ "${{ github.ref_type }}" = "tag" ]; then
54+
DATE=$(git log -1 --format=%cs "${{ github.ref }}")
55+
else
56+
DATE=$(date +%Y-%m-%d)
57+
fi
58+
sed -i "s|<release version=\"[^\"]*\" date=\"[^\"]*\"|<release version=\"${VERSION}\" date=\"${DATE}\"|" \
59+
flatpak/org.dash.DashEvoTool.metainfo.xml
60+
# Verify replacement applied
61+
if ! grep -q "version=\"${VERSION}\" date=\"${DATE}\"" flatpak/org.dash.DashEvoTool.metainfo.xml; then
62+
echo "::error::Failed to update metainfo.xml with version ${VERSION} and date ${DATE}"
63+
exit 1
64+
fi
65+
echo "Metainfo version set to ${VERSION}, date ${DATE}"
66+
4067
- name: Install Flatpak and Flatpak Builder
4168
run: |
4269
sudo apt-get update

.github/workflows/release.yml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,25 @@ jobs:
177177
- name: Add Rust target
178178
run: rustup target add aarch64-apple-darwin
179179

180+
- name: Extract version from Cargo.toml
181+
id: version
182+
run: |
183+
VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "dash-evo-tool") | .version')
184+
if [ -z "$VERSION" ]; then
185+
echo "::error::Failed to extract version from Cargo.toml"
186+
exit 1
187+
fi
188+
# Strip prerelease and build metadata suffixes for macOS plist (Apple requires numeric-only)
189+
PLIST_VERSION=$(echo "$VERSION" | sed 's/[-+].*//')
190+
if ! echo "$PLIST_VERSION" | grep -Eq '^[0-9]+(\.[0-9]+){0,2}$'; then
191+
echo "::error::Invalid plist version '$PLIST_VERSION' derived from Cargo version '$VERSION'. Expected numeric x[.y[.z]]."
192+
exit 1
193+
fi
194+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
195+
echo "plist_version=$PLIST_VERSION" >> "$GITHUB_OUTPUT"
196+
echo "build_number=${{ github.run_number }}" >> "$GITHUB_OUTPUT"
197+
echo "Extracted version: $VERSION (plist: $PLIST_VERSION, build: ${{ github.run_number }})"
198+
180199
- name: Initial disk cleanup
181200
run: |
182201
echo "Disk usage before initial cleanup:"
@@ -270,9 +289,9 @@ jobs:
270289
<key>CFBundleDisplayName</key>
271290
<string>Dash Evo Tool</string>
272291
<key>CFBundleVersion</key>
273-
<string>1.0.0</string>
292+
<string>${{ steps.version.outputs.build_number }}</string>
274293
<key>CFBundleShortVersionString</key>
275-
<string>1.0.0</string>
294+
<string>${{ steps.version.outputs.plist_version }}</string>
276295
<key>CFBundlePackageType</key>
277296
<string>APPL</string>
278297
<key>CFBundleSignature</key>
@@ -474,6 +493,25 @@ jobs:
474493
- name: Add Rust target
475494
run: rustup target add x86_64-apple-darwin
476495

496+
- name: Extract version from Cargo.toml
497+
id: version
498+
run: |
499+
VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "dash-evo-tool") | .version')
500+
if [ -z "$VERSION" ]; then
501+
echo "::error::Failed to extract version from Cargo.toml"
502+
exit 1
503+
fi
504+
# Strip prerelease and build metadata suffixes for macOS plist (Apple requires numeric-only)
505+
PLIST_VERSION=$(echo "$VERSION" | sed 's/[-+].*//')
506+
if ! echo "$PLIST_VERSION" | grep -Eq '^[0-9]+(\.[0-9]+){0,2}$'; then
507+
echo "::error::Invalid plist version '$PLIST_VERSION' derived from Cargo version '$VERSION'. Expected numeric x[.y[.z]]."
508+
exit 1
509+
fi
510+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
511+
echo "plist_version=$PLIST_VERSION" >> "$GITHUB_OUTPUT"
512+
echo "build_number=${{ github.run_number }}" >> "$GITHUB_OUTPUT"
513+
echo "Extracted version: $VERSION (plist: $PLIST_VERSION, build: ${{ github.run_number }})"
514+
477515
- name: Initial disk cleanup
478516
run: |
479517
echo "Disk usage before initial cleanup:"
@@ -563,9 +601,9 @@ jobs:
563601
<key>CFBundleDisplayName</key>
564602
<string>Dash Evo Tool</string>
565603
<key>CFBundleVersion</key>
566-
<string>1.0.0</string>
604+
<string>${{ steps.version.outputs.build_number }}</string>
567605
<key>CFBundleShortVersionString</key>
568-
<string>1.0.0</string>
606+
<string>${{ steps.version.outputs.plist_version }}</string>
569607
<key>CFBundlePackageType</key>
570608
<string>APPL</string>
571609
<key>CFBundleSignature</key>

flatpak/org.dash.DashEvoTool.metainfo.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<name>Dash Core Group</name>
4444
</developer>
4545

46+
<!-- Version and date are auto-synced from Cargo.toml by CI (flatpak.yml) -->
4647
<releases>
4748
<release version="1.0.0-dev" date="2026-02-17" type="development" />
4849
</releases>

0 commit comments

Comments
 (0)