Skip to content

Commit

Permalink
feat: add deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaPipolo committed May 31, 2024
1 parent 45adff2 commit de1af7e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ php_errorlog
.idea/
.well-known
/tags
.github/.version
.github/.release-notes

# Patch/diff artifacts
*.diff
Expand Down
34 changes: 34 additions & 0 deletions bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Ask the user for the new version number
read -p "Enter the new version: " new_version

# Check if the new version is provided
if [[ -z "$new_version" ]]; then
echo "You must provide a new version!"
exit 1
fi

echo "v$new_version" >.github/.version

# Define the files to update
files_to_update=("composer.json" "package.json" "style.css")

# Loop through the files and update the version
for file in "${files_to_update[@]}"; do
if [[ -f "$file" ]]; then
if [[ "$file" == "style.css" ]]; then
sed -i '' -E "s/(Version: )[0-9]+\.[0-9]+\.[0-9]+/\1$new_version/" "$file"
else
sed -i '' -E "s/(\"version\": \")[0-9]+\.[0-9]+\.[0-9]+\"/\1$new_version\"/" "$file"
fi
else
echo "Warning: File $file does not exist and was not updated."
fi
done

# Commit the changes with the provided message
git add "${files_to_update[@]}"
git commit -m "chore(🚀): bump project version"

echo "Version updated to $new_version and committed to git."
15 changes: 15 additions & 0 deletions create-release-notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Fetch the latest tags from the remote repository
git fetch --tags

# Get the latest version from the .version file
new_version=$(<.github/.version)

# Get the latest tag before the new version
previous_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1))

# Generate the release notes content
echo "**CHANGELOG:**" >.github/.release-notes
echo "" >>.github/.release-notes
echo "- https://github.com/somoscuatro/sc-starter-theme/compare/${previous_tag}...${new_version}" >>.github/.release-notes
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"lint-fix:js": "eslint ./**/*.js --fix && prettier --write ./**/*.js",
"sniff": "pnpm run sniff:php",
"sniff:php": "composer sniff",
"deploy": "bash bump-version.sh && git push origin main && git push origin --tags && bash create-release-notes.sh && gh release create \"$(<.github/.version)\" --title \"$(<.github/.version)\" --notes \"$(<.github/.release-notes)\"",
"postinstall": "husky"
},
"lint-staged": {
Expand Down

0 comments on commit de1af7e

Please sign in to comment.