feat(build): bash release scripts
This commit is contained in:
82
scripts/check-release-deps.sh
Normal file
82
scripts/check-release-deps.sh
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
# Check Release Dependencies
|
||||
# Validates environment and requirements before releasing
|
||||
|
||||
echo "Checking Release Dependencies"
|
||||
echo "=============================="
|
||||
echo ""
|
||||
|
||||
# Check if .env file exists
|
||||
echo "[1/3] Checking .env file..."
|
||||
if [ ! -f .env ]; then
|
||||
echo "ERROR: .env file not found"
|
||||
exit 1
|
||||
fi
|
||||
echo " .env file found"
|
||||
|
||||
# Source the .env file and validate required variables
|
||||
set +u
|
||||
source .env
|
||||
set -u
|
||||
|
||||
echo "[2/3] Validating Sentry configuration..."
|
||||
|
||||
if [ -z "${SENTRY_ORG:-}" ] || [ "$SENTRY_ORG" != "longhorn-developers" ]; then
|
||||
echo "ERROR: SENTRY_ORG must be set to 'longhorn-developers' in .env"
|
||||
exit 1
|
||||
fi
|
||||
echo " SENTRY_ORG: $SENTRY_ORG"
|
||||
|
||||
if [ -z "${SENTRY_PROJECT:-}" ] || [ "$SENTRY_PROJECT" != "ut-registration-plus" ]; then
|
||||
echo "ERROR: SENTRY_PROJECT must be set to 'ut-registration-plus' in .env"
|
||||
exit 1
|
||||
fi
|
||||
echo " SENTRY_PROJECT: $SENTRY_PROJECT"
|
||||
|
||||
if [ -z "${SENTRY_AUTH_TOKEN:-}" ]; then
|
||||
echo "ERROR: SENTRY_AUTH_TOKEN must be populated in .env"
|
||||
exit 1
|
||||
fi
|
||||
echo " SENTRY_AUTH_TOKEN: [set]"
|
||||
|
||||
# Check for required commands
|
||||
echo "[3/3] Checking required commands..."
|
||||
|
||||
MISSING_DEPS=()
|
||||
|
||||
if ! command -v pnpm &>/dev/null; then
|
||||
MISSING_DEPS+=("pnpm")
|
||||
fi
|
||||
|
||||
if ! command -v npm &>/dev/null; then
|
||||
MISSING_DEPS+=("npm")
|
||||
fi
|
||||
|
||||
if ! command -v conventional-changelog &>/dev/null; then
|
||||
MISSING_DEPS+=("conventional-changelog")
|
||||
fi
|
||||
|
||||
# Check for version control
|
||||
if command -v jj &>/dev/null; then
|
||||
echo " Version control: jujutsu"
|
||||
elif command -v git &>/dev/null; then
|
||||
echo " Version control: git"
|
||||
else
|
||||
MISSING_DEPS+=("git or jujutsu")
|
||||
fi
|
||||
|
||||
if [ ${#MISSING_DEPS[@]} -ne 0 ]; then
|
||||
echo ""
|
||||
echo "ERROR: Missing required dependencies:"
|
||||
for dep in "${MISSING_DEPS[@]}"; do
|
||||
echo " - $dep"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " All required commands found"
|
||||
echo ""
|
||||
echo "All dependency checks passed."
|
||||
54
scripts/publish-release.sh
Normal file
54
scripts/publish-release.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
# Publish Release
|
||||
# Creates distribution package and displays checksum
|
||||
|
||||
echo "Publishing Release"
|
||||
echo "=================="
|
||||
echo ""
|
||||
|
||||
# Remove old zip files
|
||||
echo "[1/2] Creating distribution package..."
|
||||
rm -f package/*.zip 2>/dev/null || true
|
||||
|
||||
TEMP_ZIP=$(mktemp)
|
||||
trap "rm -f $TEMP_ZIP" EXIT
|
||||
|
||||
FORCE_COLOR=1 pnpm zip:to-publish 2>&1 | tee "$TEMP_ZIP"
|
||||
|
||||
if grep -qi "error\|failed" "$TEMP_ZIP"; then
|
||||
echo ""
|
||||
echo "ERROR: Package creation failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find and verify the zip file
|
||||
ZIP_FILE=$(find package/ -name "*.zip" -type f -print -quit 2>/dev/null)
|
||||
|
||||
if [ -z "$ZIP_FILE" ]; then
|
||||
echo "ERROR: No package found in package/ directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Calculate SHA256 checksum
|
||||
echo ""
|
||||
echo "[2/2] Calculating SHA256 checksum..."
|
||||
echo " Package: $ZIP_FILE"
|
||||
echo ""
|
||||
|
||||
if command -v shasum &>/dev/null; then
|
||||
shasum -a 256 "$ZIP_FILE"
|
||||
elif command -v sha256sum &>/dev/null; then
|
||||
sha256sum "$ZIP_FILE"
|
||||
else
|
||||
echo "ERROR: Neither shasum nor sha256sum found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Release published successfully!"
|
||||
echo ""
|
||||
echo "Package ready for distribution:"
|
||||
echo " $ZIP_FILE"
|
||||
124
scripts/stage-release.sh
Normal file
124
scripts/stage-release.sh
Normal file
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
VERSION_TYPE=${1:-minor}
|
||||
|
||||
# Stage Release
|
||||
# Bumps version, generates changelog, and commits changes
|
||||
|
||||
echo "Staging Release"
|
||||
echo "==============="
|
||||
echo "Version type: $VERSION_TYPE"
|
||||
echo ""
|
||||
|
||||
# Detect version control system
|
||||
if command -v jj &>/dev/null; then
|
||||
VCS="jj"
|
||||
echo "Using jujutsu"
|
||||
elif command -v git &>/dev/null; then
|
||||
VCS="git"
|
||||
echo "Using git"
|
||||
|
||||
# Check for uncommitted changes (git only)
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
echo "ERROR: You have uncommitted changes. Please commit or stash them first."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "ERROR: No version control system found (git or jujutsu required)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Bump version in package.json WITHOUT committing or tagging
|
||||
echo "[1/5] Bumping version in package.json..."
|
||||
npm version $VERSION_TYPE --no-git-tag-version
|
||||
|
||||
# Get the new version
|
||||
NEW_VERSION=$(node -p "require('./package.json').version")
|
||||
echo " New version: $NEW_VERSION"
|
||||
|
||||
# Generate changelog
|
||||
echo ""
|
||||
echo "[2/5] Generating changelog with new version..."
|
||||
|
||||
if [ -f CHANGELOG.md ]; then
|
||||
CHANGELOG_BEFORE=$(stat -c %Y CHANGELOG.md 2>/dev/null || stat -f %m CHANGELOG.md 2>/dev/null)
|
||||
else
|
||||
CHANGELOG_BEFORE=0
|
||||
fi
|
||||
|
||||
TEMP_CHANGELOG=$(mktemp)
|
||||
trap "rm -f $TEMP_CHANGELOG" EXIT
|
||||
|
||||
FORCE_COLOR=1 pnpm generate-changelog 2>&1 | tee "$TEMP_CHANGELOG"
|
||||
|
||||
if grep -qi "error\|failed\|command not found" "$TEMP_CHANGELOG"; then
|
||||
echo ""
|
||||
echo "ERROR: Changelog generation failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f CHANGELOG.md ]; then
|
||||
CHANGELOG_AFTER=$(stat -c %Y CHANGELOG.md 2>/dev/null || stat -f %m CHANGELOG.md 2>/dev/null)
|
||||
if [ "$CHANGELOG_AFTER" -le "$CHANGELOG_BEFORE" ]; then
|
||||
echo ""
|
||||
echo "ERROR: CHANGELOG.md was not updated"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
echo "ERROR: CHANGELOG.md was not created"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Commit changes
|
||||
echo ""
|
||||
echo "[3/5] Committing changes..."
|
||||
|
||||
if [ "$VCS" = "jj" ]; then
|
||||
jj commit -m "chore: release v$NEW_VERSION"
|
||||
echo " Commit created"
|
||||
else
|
||||
git add package.json package-lock.json CHANGELOG.md
|
||||
git commit -m "chore: release v$NEW_VERSION"
|
||||
echo " Commit created"
|
||||
fi
|
||||
|
||||
# Update main bookmark (jujutsu only)
|
||||
if [ "$VCS" = "jj" ]; then
|
||||
echo ""
|
||||
echo "[4/5] Updating main bookmark..."
|
||||
jj bookmark set main -r @
|
||||
echo " Bookmark 'main' updated to current commit"
|
||||
fi
|
||||
|
||||
# Create tag
|
||||
echo ""
|
||||
if [ "$VCS" = "jj" ]; then
|
||||
echo "[5/5] Creating annotated tag via git..."
|
||||
# Jujutsu doesn't support annotated tags yet, so we use git
|
||||
jj git export
|
||||
git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
|
||||
jj git import
|
||||
echo " Annotated tag 'v$NEW_VERSION' created via git"
|
||||
else
|
||||
echo "[5/5] Creating annotated tag..."
|
||||
git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
|
||||
echo " Annotated tag 'v$NEW_VERSION' created"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Release v$NEW_VERSION staged successfully!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
if [ "$VCS" = "jj" ]; then
|
||||
echo " - Review changes: jj show @-"
|
||||
echo " - Push to remote: jj git push && git push --tags"
|
||||
else
|
||||
echo " - Review changes: git show"
|
||||
echo " - Push to remote: git push && git push --tags"
|
||||
fi
|
||||
echo " - Publish release: ./publish-release.sh"
|
||||
Reference in New Issue
Block a user