fix: unify version management - pass git tag to post-goreleaser.sh

This commit is contained in:
tianlei.qjb
2026-04-01 17:03:52 +08:00
parent c650afa6eb
commit 86355413fc
3 changed files with 39 additions and 4 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
set -e
VERSION="v1.0.6"
echo "==> Running GoReleaser snapshot..."
goreleaser release --snapshot --clean
echo "==> Running post-goreleaser.sh..."
DWS_PACKAGE_VERSION=$VERSION ./scripts/release/post-goreleaser.sh
echo "==> Verifying artifacts..."
echo "Binary version:"
./dist/dws-darwin-arm64/dws version 2>/dev/null || ./dist/dws-linux-amd64/dws version
echo "npm package.json:"
cat dist/npm/dingtalk-workspace-cli/package.json | grep '"version"'
echo "dws-skills.zip:"
ls -lh dist/dws-skills.zip
echo "==> npm publish dry-run..."
cd dist/npm/dingtalk-workspace-cli
npm publish --access public --dry-run
echo "==> All checks passed!"
+12 -3
View File
@@ -53,14 +53,23 @@ detect_arch() {
}
resolve_version() {
# Priority 1: Use DWS_PACKAGE_VERSION environment variable (set by CI)
if [ -n "$PACKAGE_VERSION" ]; then
printf '%s\n' "$PACKAGE_VERSION"
# Strip leading 'v' if present for semver compatibility
printf '%s\n' "$PACKAGE_VERSION" | sed 's/^v//'
return
fi
# Priority 2: Get version from git tag (for local snapshot builds with tag)
if git describe --tags --exact-match HEAD >/dev/null 2>&1; then
git describe --tags --exact-match HEAD | sed 's/^v//'
return
fi
# Priority 3: Read from version.go (for local development without tag)
version_line="$(sed -n 's/^var version = "v\{0,1\}\([^"]*\)".*/\1/p' "$ROOT/internal/app/version.go" | head -1)"
if [ -z "$version_line" ]; then
err "could not resolve package version from internal/app/version.go"
if [ -z "$version_line" ] || [ "$version_line" = "dev" ]; then
err "could not resolve package version - set DWS_PACKAGE_VERSION or create a git tag"
fi
printf '%s\n' "$version_line"
}