Skip to content

Commit 7976e8e

Browse files
committed
Sync package.json version from git tag in release workflow
1 parent 4c7654a commit 7976e8e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ jobs:
5151
- name: Install dependencies
5252
run: npm ci
5353

54+
# electron-builder reads `version` from package.json for artifact
55+
# naming (e.g. OpenCluely-1.0.0-x64.dmg). When we build from a
56+
# git tag (v1.0.7) the package.json still says 1.0.0 by default,
57+
# so artifact names drift from the release tag. Sync them here.
58+
# `npm pkg set` is cross-platform and doesn't touch git.
59+
- name: Sync package.json version from tag
60+
if: startsWith(github.ref, 'refs/tags/v')
61+
shell: bash
62+
run: |
63+
VERSION="${GITHUB_REF_NAME#v}"
64+
echo "Tag version: $VERSION"
65+
CURRENT=$(node -p "require('./package.json').version")
66+
echo "Current package.json version: $CURRENT"
67+
if [ "$VERSION" != "$CURRENT" ]; then
68+
npm pkg set "version=$VERSION"
69+
echo "Updated package.json to $VERSION"
70+
else
71+
echo "Version already matches tag"
72+
fi
73+
5474
# Linux: install LinuxBuild dependencies so electron-builder can produce .deb / .AppImage
5575
- name: Install Linux build dependencies
5676
if: matrix.os == 'ubuntu-latest'

0 commit comments

Comments
 (0)