Skip to content

Commit

Permalink
👷 Add release script
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella committed Feb 6, 2023
1 parent 3c80eca commit 5dba8b0
Show file tree
Hide file tree
Showing 3 changed files with 2,254 additions and 35 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "rallly2",
"name": "rallly",
"version": "0.1.0",
"private": true,
"scripts": {
Expand All @@ -12,7 +12,9 @@
"lint:tsc": "tsc --noEmit",
"lint:i18n": "i18n-unused remove-unused",
"test": "PORT=3001 playwright test",
"test:codegen": "playwright codegen http://localhost:3000"
"test:codegen": "playwright codegen http://localhost:3000",
"release": "./scripts/create-release.sh",
"changelog:update": "gitmoji-changelog"
},
"dependencies": {
"@floating-ui/react-dom-interactions": "^0.13.3",
Expand Down Expand Up @@ -86,6 +88,7 @@
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"gitmoji-changelog": "^2.3.0",
"i18n-unused": "^0.12.0",
"prettier": "^2.3.0",
"prettier-plugin-tailwindcss": "^0.1.8",
Expand Down
32 changes: 32 additions & 0 deletions scripts/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

read -p "Enter the new version number: " new_version

# Check if the version number follows semver format
if ! [[ $new_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version number. The version number must follow the semver format (e.g. 1.0.0)."
exit 1
fi

if [ ! -f "package.json" ]; then
echo "Error: package.json file not found."
exit 1
fi

# Replace the version in the package.json file
sed -i "" "s/\"version\": \".*\"/\"version\": \"$new_version\"/g" package.json

# Update the changelog file
yarn changelog:update

# Run prettier on the changelog file
yarn prettier --write CHANGELOG.md

# Commit the changes with a message indicating the new version number
git add package.json CHANGELOG.md
git commit -m "🔖 Release $new_version"

# Tag the commit with the new version number (prefixed with "v")
git tag -a "v$new_version" -m "Tag for version $new_version"

echo "Version in package.json file updated to $new_version, changelog updated, and tagged in Git as v$new_version"
Loading

0 comments on commit 5dba8b0

Please sign in to comment.