fix: unify version management - pass git tag to post-goreleaser.sh
This commit is contained in:
@@ -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!"
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user