Skip to content

Commit

Permalink
Add release script
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalmaster committed Dec 24, 2024
1 parent 7263d79 commit ac0c1eb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"test-debug": "TZ=UTC node --inspect-brk node_modules/.bin/jest --runInBand --watch --verbose",
"changelog-generate": "auto-changelog --starting-version v16 --handlebars-setup changelog-setup.js --template changelog-template.hbs --commit-limit false",
"changelog-data": "npm run changelog-generate -- --template json --output changelog-data.json",
"changelog": "npm run changelog-data && npm run changelog-generate && git add CHANGELOG.md"
"changelog": "npm run changelog-data && npm run changelog-generate && git add CHANGELOG.md",
"release": "./scripts/release.sh"
},
"jest": {
"testEnvironment": "jsdom",
Expand Down
45 changes: 45 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Colors for logging
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Logging function
log() {
echo -e "${GREEN}==>${NC} ${BLUE}$1${NC}"
}

log "Getting current version from package.json"
CURRENT_VERSION=$(node -p "require('./package.json').version")
NEW_VERSION=$((CURRENT_VERSION + 1))
log "Incrementing version from $CURRENT_VERSION to $NEW_VERSION"

log "Updating version in package.json"
node -e "const pkg=require('./package.json'); pkg.version=String($NEW_VERSION); require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2)+'\n')"

log "Removing local tag if it exists"
git tag -d v$NEW_VERSION 2>/dev/null || true

log "Remove remote tag if it exists"
git push --delete origin v$NEW_VERSION 2>/dev/null || true

log "Creating initial tag v$NEW_VERSION"
git tag v$NEW_VERSION

log "Generating changelog"
npm run changelog

log "Creating release commit"
git add package.json
git add CHANGELOG.md
git commit -m "Release v$NEW_VERSION"

log "Moving tag to include changelog"
git tag --delete v$NEW_VERSION
git tag v$NEW_VERSION

log "Pushing new tag"
git push --tags

log "Release v$NEW_VERSION completed! Now push latest commit and open depot PR 🎉"

0 comments on commit ac0c1eb

Please sign in to comment.