Skip to content

Commit 2e840c3

Browse files
lklimekclaude
andcommitted
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>
1 parent c90bf7c commit 2e840c3

2 files changed

Lines changed: 35 additions & 5 deletions

File tree

.github/workflows/flatpak.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,23 @@ jobs:
4040
- name: Sync metainfo version from Cargo.toml
4141
run: |
4242
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
43-
DATE=$(date +%Y-%m-%d)
43+
if [ -z "$VERSION" ]; then
44+
echo "::error::Failed to extract version from Cargo.toml"
45+
exit 1
46+
fi
47+
# Use tag date for releases, current date for manual/PR builds
48+
if [ "${{ github.ref_type }}" = "tag" ]; then
49+
DATE=$(git log -1 --format=%cs "${{ github.ref }}")
50+
else
51+
DATE=$(date +%Y-%m-%d)
52+
fi
4453
sed -i "s|<release version=\"[^\"]*\" date=\"[^\"]*\"|<release version=\"${VERSION}\" date=\"${DATE}\"|" \
4554
flatpak/org.dash.DashEvoTool.metainfo.xml
55+
# Verify replacement applied
56+
if ! grep -q "version=\"${VERSION}\"" flatpak/org.dash.DashEvoTool.metainfo.xml; then
57+
echo "::error::Failed to update metainfo.xml with version ${VERSION}"
58+
exit 1
59+
fi
4660
echo "Metainfo version set to ${VERSION}, date ${DATE}"
4761
4862
- name: Install Flatpak and Flatpak Builder

.github/workflows/release.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,15 @@ jobs:
175175
id: version
176176
run: |
177177
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
178+
if [ -z "$VERSION" ]; then
179+
echo "::error::Failed to extract version from Cargo.toml"
180+
exit 1
181+
fi
182+
# Strip prerelease suffix for macOS plist (Apple requires numeric-only)
183+
PLIST_VERSION=$(echo "$VERSION" | sed 's/-.*//')
178184
echo "version=$VERSION" >> $GITHUB_OUTPUT
185+
echo "plist_version=$PLIST_VERSION" >> $GITHUB_OUTPUT
186+
echo "Extracted version: $VERSION (plist: $PLIST_VERSION)"
179187
180188
- name: Install Rust toolchain
181189
uses: dtolnay/rust-toolchain@stable
@@ -276,9 +284,9 @@ jobs:
276284
<key>CFBundleDisplayName</key>
277285
<string>Dash Evo Tool</string>
278286
<key>CFBundleVersion</key>
279-
<string>${{ steps.version.outputs.version }}</string>
287+
<string>${{ steps.version.outputs.plist_version }}</string>
280288
<key>CFBundleShortVersionString</key>
281-
<string>${{ steps.version.outputs.version }}</string>
289+
<string>${{ steps.version.outputs.plist_version }}</string>
282290
<key>CFBundlePackageType</key>
283291
<string>APPL</string>
284292
<key>CFBundleSignature</key>
@@ -478,7 +486,15 @@ jobs:
478486
id: version
479487
run: |
480488
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
489+
if [ -z "$VERSION" ]; then
490+
echo "::error::Failed to extract version from Cargo.toml"
491+
exit 1
492+
fi
493+
# Strip prerelease suffix for macOS plist (Apple requires numeric-only)
494+
PLIST_VERSION=$(echo "$VERSION" | sed 's/-.*//')
481495
echo "version=$VERSION" >> $GITHUB_OUTPUT
496+
echo "plist_version=$PLIST_VERSION" >> $GITHUB_OUTPUT
497+
echo "Extracted version: $VERSION (plist: $PLIST_VERSION)"
482498
483499
- name: Install Rust toolchain
484500
uses: dtolnay/rust-toolchain@stable
@@ -575,9 +591,9 @@ jobs:
575591
<key>CFBundleDisplayName</key>
576592
<string>Dash Evo Tool</string>
577593
<key>CFBundleVersion</key>
578-
<string>${{ steps.version.outputs.version }}</string>
594+
<string>${{ steps.version.outputs.plist_version }}</string>
579595
<key>CFBundleShortVersionString</key>
580-
<string>${{ steps.version.outputs.version }}</string>
596+
<string>${{ steps.version.outputs.plist_version }}</string>
581597
<key>CFBundlePackageType</key>
582598
<string>APPL</string>
583599
<key>CFBundleSignature</key>

0 commit comments

Comments
 (0)