feat(release): introduce dedicated release script to replace flawed git push hook
All checks were successful
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 7s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m4s
Monorepo Pipeline / 🧹 Lint (push) Successful in 2m50s
Monorepo Pipeline / 🏗️ Build (push) Successful in 2m21s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Image Processor (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
All checks were successful
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 7s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m4s
Monorepo Pipeline / 🧹 Lint (push) Successful in 2m50s
Monorepo Pipeline / 🏗️ Build (push) Successful in 2m21s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Image Processor (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
This commit is contained in:
@@ -5,49 +5,4 @@ if [ -f "$SCRIPT_DIR/scripts/validate-sdk-imports.sh" ]; then
|
||||
"$SCRIPT_DIR/scripts/validate-sdk-imports.sh" || exit 1
|
||||
fi
|
||||
|
||||
# Check if we are pushing a tag
|
||||
while read local_ref local_sha remote_ref remote_sha
|
||||
do
|
||||
if [[ "$remote_ref" == refs/tags/* ]]; then
|
||||
TAG=${remote_ref#refs/tags/}
|
||||
echo "🏷️ Tag detected: $TAG, ensuring versions are synced..."
|
||||
|
||||
# Run sync script
|
||||
pnpm sync-versions "$TAG"
|
||||
|
||||
# Check for changes in relevant files
|
||||
SYNC_FILES="package.json packages/*/package.json apps/*/package.json .env.example"
|
||||
CHANGES=$(git status --porcelain $SYNC_FILES)
|
||||
|
||||
if [[ -n "$CHANGES" ]]; then
|
||||
echo "📝 Version sync made changes. Integrating into tag..."
|
||||
|
||||
# Stage and commit
|
||||
git add $SYNC_FILES
|
||||
git commit -m "chore: sync versions to $TAG" --no-verify
|
||||
|
||||
# Force update the local tag to point to the new commit
|
||||
git tag -f "$TAG" > /dev/null
|
||||
|
||||
echo "✅ Tag $TAG has been updated locally with synced versions."
|
||||
# Push branch AND tag directly inside the hook because Git native push has already recorded the old SHA
|
||||
CURRENT_BRANCH=$(git branch --show-current)
|
||||
if [ -n "$CURRENT_BRANCH" ]; then
|
||||
git push origin "$CURRENT_BRANCH" --no-verify
|
||||
fi
|
||||
git push origin "$TAG" --force --no-verify
|
||||
|
||||
echo ""
|
||||
echo "✨ VERSIONS SYNCED & PUSHED SUCCESSFULLY ✨"
|
||||
echo "The correct commit has been tagged on origin."
|
||||
echo "(Info: You will see a 'pre-push hook failed' and 'failed to push' error below. Please completely ignore it. We MUST abort the native git push, otherwise Git would push the pre-sync commit to the tag and break the version history.)"
|
||||
echo ""
|
||||
|
||||
# We MUST exit 1, otherwise native Git will push the wrong commit to the tag
|
||||
exit 1
|
||||
else
|
||||
echo "✨ Versions already in sync for $TAG."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"changeset": "changeset",
|
||||
"version-packages": "changeset version",
|
||||
"sync-versions": "tsx scripts/sync-versions.ts --",
|
||||
"release:version": "bash scripts/release.sh",
|
||||
"release": "pnpm build && changeset publish",
|
||||
"release:tag": "pnpm build && pnpm -r publish --no-git-checks --access public",
|
||||
"prepare": "husky"
|
||||
|
||||
50
scripts/release.sh
Executable file
50
scripts/release.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
VERSION=$1
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Error: Missing version argument."
|
||||
echo "Usage: pnpm release <version>"
|
||||
echo "Example: pnpm release 1.9.0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure version does not have 'v' prefix for the variable
|
||||
VERSION=${VERSION#v}
|
||||
TAG="v$VERSION"
|
||||
|
||||
echo "🚀 Starting release process for $TAG..."
|
||||
|
||||
# 1. Sync versions across monorepo
|
||||
pnpm exec tsx scripts/sync-versions.ts -- "$TAG"
|
||||
|
||||
# 2. Check if anything changed
|
||||
SYNC_FILES="package.json packages/*/package.json apps/*/package.json .env.example"
|
||||
CHANGES=$(git status --porcelain $SYNC_FILES)
|
||||
|
||||
if [[ -n "$CHANGES" ]]; then
|
||||
echo "📝 Version sync made changes. Committing and tagging..."
|
||||
|
||||
# Stage and commit
|
||||
git add $SYNC_FILES
|
||||
git commit -m "chore: release $TAG" --no-verify
|
||||
else
|
||||
echo "✨ Versions are already in sync."
|
||||
fi
|
||||
|
||||
# 3. Tag and push
|
||||
echo "🏷️ Tagging $TAG..."
|
||||
git tag -f "$TAG" > /dev/null
|
||||
|
||||
echo "🚀 Pushing branch and tag to origin..."
|
||||
CURRENT_BRANCH=$(git branch --show-current)
|
||||
if [ -n "$CURRENT_BRANCH" ]; then
|
||||
git push origin "$CURRENT_BRANCH" --no-verify
|
||||
fi
|
||||
git push origin "$TAG" --force --no-verify
|
||||
|
||||
echo ""
|
||||
echo "✨ VERSIONS SYNCED & PUSHED SUCCESSFULLY ✨"
|
||||
echo "✅ Release $TAG is complete!"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user