Skip to content

Commit 443e1b8

Browse files
committed
ci(cli): stamp Cargo version from release tag before build
1 parent c6b7cb2 commit 443e1b8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/release-cli-npm.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,39 @@ jobs:
109109
name: vendored-assets
110110
path: crates-tauri/yaak-app/vendored
111111

112+
- name: Set CLI build version
113+
shell: bash
114+
env:
115+
WORKFLOW_VERSION: ${{ inputs.version }}
116+
run: |
117+
set -euo pipefail
118+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
119+
VERSION="$WORKFLOW_VERSION"
120+
else
121+
VERSION="${GITHUB_REF_NAME#yaak-cli-}"
122+
fi
123+
VERSION="${VERSION#v}"
124+
echo "Building yaak version: $VERSION"
125+
python - "$VERSION" <<'PY'
126+
import pathlib
127+
import re
128+
import sys
129+
130+
version = sys.argv[1]
131+
manifest = pathlib.Path("crates-cli/yaak-cli/Cargo.toml")
132+
contents = manifest.read_text()
133+
updated, replacements = re.subn(
134+
r'(?m)^version = ".*"$',
135+
f'version = "{version}"',
136+
contents,
137+
count=1,
138+
)
139+
if replacements != 1:
140+
raise SystemExit("Failed to update yaak-cli version in Cargo.toml")
141+
manifest.write_text(updated)
142+
print(f"Updated {manifest} to version {version}")
143+
PY
144+
112145
- name: Build yaak
113146
run: cargo build --locked --release -p yaak-cli --bin yaak --target ${{ matrix.target }}
114147

0 commit comments

Comments
 (0)