mirror of
https://github.com/Vikeo/LifeTrinket.git
synced 2025-11-18 16:58:01 +00:00
create script for releasing
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "life-trinket",
|
"name": "life-trinket",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.2",
|
"version": "1.0.4",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20",
|
"node": ">=20",
|
||||||
@@ -14,7 +14,8 @@
|
|||||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"generate-icons": "npx @svgr/cli src/Icons/svgs",
|
"generate-icons": "npx @svgr/cli src/Icons/svgs",
|
||||||
"deploy": "bun run build && firebase deploy --only hosting"
|
"deploy": "bun run build && firebase deploy --only hosting",
|
||||||
|
"release": "bash scripts/create-release.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"firebase": "^10.14.1",
|
"firebase": "^10.14.1",
|
||||||
|
|||||||
74
scripts/README.md
Normal file
74
scripts/README.md
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
# Release Scripts
|
||||||
|
|
||||||
|
## create-release.sh
|
||||||
|
|
||||||
|
This script automates the process of creating a new release for LifeTrinket.
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run release
|
||||||
|
# or
|
||||||
|
pnpm release
|
||||||
|
# or
|
||||||
|
bash scripts/create-release.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### What it does
|
||||||
|
|
||||||
|
1. **Reads the current version** from `package.json`
|
||||||
|
2. **Checks for existing tags** - If a tag with the current version already exists, it will prompt you to update the version in `package.json` first
|
||||||
|
3. **Warns about uncommitted changes** - Prompts for confirmation if you have uncommitted changes
|
||||||
|
4. **Prompts for release description** - You can enter a multi-line description for the release
|
||||||
|
5. **Creates an annotated git tag** with the version and description
|
||||||
|
6. **Pushes the tag to remote** - This triggers the GitHub Actions workflow that builds and deploys the app
|
||||||
|
|
||||||
|
### Workflow
|
||||||
|
|
||||||
|
When you push a tag, the following happens:
|
||||||
|
|
||||||
|
1. The `firebase-release.yml` workflow is triggered
|
||||||
|
2. The app is built and deployed to Firebase Hosting
|
||||||
|
3. A GitHub release is created with the version number
|
||||||
|
|
||||||
|
### Before running
|
||||||
|
|
||||||
|
Make sure to:
|
||||||
|
|
||||||
|
1. **Update the version** in `package.json` if needed
|
||||||
|
2. **Commit all changes** you want to include in the release
|
||||||
|
3. **Test the build** with `npm run build` to ensure everything works
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Update version in package.json to 1.0.3
|
||||||
|
# 2. Commit your changes
|
||||||
|
git add .
|
||||||
|
git commit -m "feat: add new features for v1.0.3"
|
||||||
|
|
||||||
|
# 3. Run the release script
|
||||||
|
npm run release
|
||||||
|
|
||||||
|
# The script will:
|
||||||
|
# - Show current version: 1.0.3
|
||||||
|
# - Prompt for confirmation
|
||||||
|
# - Ask for release description
|
||||||
|
# - Create and push the tag
|
||||||
|
# - Trigger the deployment workflow
|
||||||
|
```
|
||||||
|
|
||||||
|
### Troubleshooting
|
||||||
|
|
||||||
|
**"Tag already exists" error:**
|
||||||
|
|
||||||
|
- Update the version in `package.json` before creating a new release
|
||||||
|
|
||||||
|
**"Failed to push tag" error:**
|
||||||
|
|
||||||
|
- Check your git remote permissions
|
||||||
|
- Try pushing manually: `git push origin <version>`
|
||||||
|
|
||||||
|
**Script won't run:**
|
||||||
|
|
||||||
|
- Make sure the script is executable: `chmod +x scripts/create-release.sh`
|
||||||
87
scripts/create-release.sh
Executable file
87
scripts/create-release.sh
Executable file
@@ -0,0 +1,87 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Color codes for output
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo -e "${BLUE}=== LifeTrinket Release Script ===${NC}\n"
|
||||||
|
|
||||||
|
# Get current version from package.json
|
||||||
|
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
||||||
|
|
||||||
|
if [ -z "$CURRENT_VERSION" ]; then
|
||||||
|
echo -e "${RED}Error: Could not read version from package.json${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${BLUE}Current version in package.json:${NC} ${GREEN}$CURRENT_VERSION${NC}"
|
||||||
|
|
||||||
|
# Check if we're on a clean working tree
|
||||||
|
if [[ -n $(git status -s) ]]; then
|
||||||
|
echo -e "${YELLOW}Warning: You have uncommitted changes.${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fetch latest tags from remote
|
||||||
|
echo -e "\n${BLUE}Fetching latest tags from remote...${NC}"
|
||||||
|
git fetch --tags
|
||||||
|
|
||||||
|
# Check if tag already exists locally or remotely
|
||||||
|
if git rev-parse "$CURRENT_VERSION" >/dev/null 2>&1; then
|
||||||
|
echo -e "${RED}Error: Tag '$CURRENT_VERSION' already exists!${NC}"
|
||||||
|
echo -e "${YELLOW}Please update the version in package.json before creating a new release.${NC}"
|
||||||
|
echo -e "${YELLOW}Current version: $CURRENT_VERSION${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the latest tag (if any)
|
||||||
|
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
|
||||||
|
|
||||||
|
if [ -n "$LATEST_TAG" ]; then
|
||||||
|
echo -e "${BLUE}Latest existing tag:${NC} ${YELLOW}$LATEST_TAG${NC}"
|
||||||
|
|
||||||
|
# Compare versions
|
||||||
|
if [ "$LATEST_TAG" = "$CURRENT_VERSION" ]; then
|
||||||
|
echo -e "${RED}Error: Latest tag matches current version ($CURRENT_VERSION)${NC}"
|
||||||
|
echo -e "${YELLOW}Please update the version in package.json before creating a new release.${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}No existing tags found. This will be the first release.${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get release description from user
|
||||||
|
echo -e "\n${BLUE}Enter release description (optional, press Enter to skip):${NC}"
|
||||||
|
read -r RELEASE_DESCRIPTION
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_DESCRIPTION" ]; then
|
||||||
|
RELEASE_DESCRIPTION="Release $CURRENT_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create annotated tag with description
|
||||||
|
echo -e "\n${BLUE}Creating tag '$CURRENT_VERSION'...${NC}"
|
||||||
|
git tag -a "$CURRENT_VERSION" -m "$RELEASE_DESCRIPTION"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo -e "${RED}Error: Failed to create tag${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}✓ Tag created successfully${NC}"
|
||||||
|
|
||||||
|
# Push tag to remote
|
||||||
|
echo -e "\n${BLUE}Pushing tag to remote...${NC}"
|
||||||
|
git push origin "$CURRENT_VERSION"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo -e "${RED}Error: Failed to push tag${NC}"
|
||||||
|
echo -e "${YELLOW}Tag was created locally. You can try pushing manually:${NC}"
|
||||||
|
echo -e " git push origin $CURRENT_VERSION"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n${GREEN}✓ Tag pushed successfully!${NC}"
|
||||||
|
echo -e "${BLUE}GitHub Actions will now build and deploy version $CURRENT_VERSION${NC}"
|
||||||
|
echo -e "${BLUE}Check the progress at:${NC} https://github.com/Vikeo/LifeTrinket/actions"
|
||||||
Reference in New Issue
Block a user