feat: Add release script for versioning and tagging
This commit is contained in:
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '...'
|
||||
3. Scroll down to '...'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Environment (please complete the following information):**
|
||||
- OS: [e.g. macOS, Windows]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
32
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
32
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
## Description
|
||||
|
||||
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
|
||||
|
||||
Fixes # (issue)
|
||||
|
||||
## Type of change
|
||||
|
||||
Please delete options that are not relevant.
|
||||
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
- [ ] This change requires a documentation update
|
||||
|
||||
## How Has This Been Tested?
|
||||
|
||||
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
|
||||
|
||||
- [ ] Test A
|
||||
- [ ] Test B
|
||||
|
||||
## Checklist:
|
||||
|
||||
- [ ] My code follows the style guidelines of this project
|
||||
- [ ] I have performed a self-review of my own code
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
- [ ] I have added tests that prove my fix is effective or that my feature works
|
||||
- [ ] New and existing unit tests pass locally with my changes
|
||||
- [ ] Any dependent changes have been merged and published in downstream modules
|
||||
94
CONTRIBUTING.md
Normal file
94
CONTRIBUTING.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# Contributing to MyTube
|
||||
|
||||
First off, thanks for taking the time to contribute! 🎉
|
||||
|
||||
The following is a set of guidelines for contributing to MyTube. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before you begin, ensure you have the following installed:
|
||||
- [Node.js](https://nodejs.org/) (v14 or higher)
|
||||
- [npm](https://www.npmjs.com/) (v6 or higher)
|
||||
- [Docker](https://www.docker.com/) (optional, for containerized development)
|
||||
|
||||
### Installation
|
||||
|
||||
1. **Fork the repository** on GitHub.
|
||||
2. **Clone your fork** locally:
|
||||
```bash
|
||||
git clone https://github.com/your-username/mytube.git
|
||||
cd mytube
|
||||
```
|
||||
3. **Install dependencies** for both frontend and backend:
|
||||
```bash
|
||||
npm run install:all
|
||||
```
|
||||
Alternatively, you can install them manually:
|
||||
```bash
|
||||
npm install
|
||||
cd frontend && npm install
|
||||
cd ../backend && npm install
|
||||
```
|
||||
|
||||
### Running Locally
|
||||
|
||||
To start the development environment (both frontend and backend):
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
- **Frontend**: http://localhost:5556
|
||||
- **Backend API**: http://localhost:5551
|
||||
|
||||
## Project Structure
|
||||
|
||||
- `frontend/`: React application (Vite + TypeScript).
|
||||
- `backend/`: Express.js API (TypeScript).
|
||||
- `docker-compose.yml`: Docker configuration for running the full stack.
|
||||
|
||||
## Development Workflow
|
||||
|
||||
1. **Create a Branch**: Always work on a new branch for your changes.
|
||||
```bash
|
||||
git checkout -b feature/my-awesome-feature
|
||||
# or
|
||||
git checkout -b fix/annoying-bug
|
||||
```
|
||||
2. **Make Changes**: Implement your feature or fix.
|
||||
3. **Commit**: Write clear, descriptive commit messages.
|
||||
```bash
|
||||
git commit -m "feat: add new video player controls"
|
||||
```
|
||||
*We recommend following [Conventional Commits](https://www.conventionalcommits.org/) convention.*
|
||||
|
||||
## Code Quality
|
||||
|
||||
### Frontend
|
||||
- Run linting to ensure code style consistency:
|
||||
```bash
|
||||
cd frontend
|
||||
npm run lint
|
||||
```
|
||||
|
||||
### Backend
|
||||
- Run tests to ensure nothing is broken:
|
||||
```bash
|
||||
cd backend
|
||||
npm run test
|
||||
```
|
||||
|
||||
## Pull Request Process
|
||||
|
||||
1. Ensure your code builds and runs locally.
|
||||
2. Update the `README.md` if you are adding new features or changing configuration.
|
||||
3. Push your branch to your fork on GitHub.
|
||||
4. Open a Pull Request against the `main` branch of the original repository.
|
||||
5. Provide a clear description of the problem and solution.
|
||||
6. Link to any related issues.
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed under its MIT License.
|
||||
62
RELEASING.md
Normal file
62
RELEASING.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# Release Process
|
||||
|
||||
MyTube follows [Semantic Versioning 2.0.0](https://semver.org/).
|
||||
|
||||
## Versioning Scheme
|
||||
|
||||
Versions are formatted as `MAJOR.MINOR.PATCH` (e.g., `1.0.0`).
|
||||
|
||||
- **MAJOR**: Incompatible API changes.
|
||||
- **MINOR**: Backwards-compatible functionality.
|
||||
- **PATCH**: Backwards-compatible bug fixes.
|
||||
|
||||
## Creating a Release
|
||||
|
||||
We use the `release.sh` script to automate the release process. This script handles:
|
||||
1. Updating version numbers in `package.json` files.
|
||||
2. Creating a git tag.
|
||||
3. Building and pushing Docker images.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Ensure you are on the `main` branch.
|
||||
- Ensure your working directory is clean (no uncommitted changes).
|
||||
- Ensure you are logged in to Docker Hub (`docker login`).
|
||||
|
||||
### Usage
|
||||
|
||||
Run the release script with the desired version number:
|
||||
|
||||
```bash
|
||||
./release.sh <version>
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
./release.sh 1.2.0
|
||||
```
|
||||
|
||||
Alternatively, you can specify the increment type:
|
||||
|
||||
```bash
|
||||
./release.sh patch # 1.1.0 -> 1.1.1
|
||||
./release.sh minor # 1.1.0 -> 1.2.0
|
||||
./release.sh major # 1.1.0 -> 2.0.0
|
||||
```
|
||||
|
||||
### What the Script Does
|
||||
|
||||
1. **Checks** that you are on `main` and have a clean git status.
|
||||
2. **Updates** `version` in:
|
||||
- `package.json`
|
||||
- `frontend/package.json`
|
||||
- `backend/package.json`
|
||||
3. **Commits** the changes with message `chore(release): v<version>`.
|
||||
4. **Tags** the commit with `v<version>`.
|
||||
5. **Builds** Docker images for backend and frontend.
|
||||
6. **Pushes** images to Docker Hub with tags:
|
||||
- `franklioxygen/mytube:backend-<version>`
|
||||
- `franklioxygen/mytube:backend-latest`
|
||||
- `franklioxygen/mytube:frontend-<version>`
|
||||
- `franklioxygen/mytube:frontend-latest`
|
||||
33
SECURITY.md
Normal file
33
SECURITY.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Use this section to tell people about which versions of your project are currently being supported with security updates.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 1.1.x | :white_check_mark: |
|
||||
| 1.0.x | :x: |
|
||||
| < 1.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
We take the security of our software seriously. If you believe you have found a security vulnerability in MyTube, please report it to us as described below.
|
||||
|
||||
**Please do not report security vulnerabilities through public GitHub issues.**
|
||||
|
||||
Instead, please report them by:
|
||||
|
||||
1. Sending an email to [INSERT EMAIL HERE].
|
||||
2. Opening a draft Security Advisory if you are a collaborator.
|
||||
|
||||
You should receive a response within 48 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
|
||||
|
||||
We prefer all communications to be in English or Chinese.
|
||||
|
||||
## Disclosure Policy
|
||||
|
||||
1. We will investigate the issue and verify the vulnerability.
|
||||
2. We will work on a patch to fix the vulnerability.
|
||||
3. We will release a new version of the software with the fix.
|
||||
4. We will publish a Security Advisory to inform users about the vulnerability and the fix.
|
||||
@@ -3,8 +3,16 @@ set -e
|
||||
|
||||
DOCKER_PATH="/Applications/Docker.app/Contents/Resources/bin/docker"
|
||||
USERNAME="franklioxygen"
|
||||
BACKEND_IMAGE="$USERNAME/mytube:backend-latest"
|
||||
FRONTEND_IMAGE="$USERNAME/mytube:frontend-latest"
|
||||
VERSION=$1
|
||||
|
||||
BACKEND_LATEST="$USERNAME/mytube:backend-latest"
|
||||
FRONTEND_LATEST="$USERNAME/mytube:frontend-latest"
|
||||
|
||||
if [ -n "$VERSION" ]; then
|
||||
echo "🔖 Version specified: $VERSION"
|
||||
BACKEND_VERSION_TAG="$USERNAME/mytube:backend-$VERSION"
|
||||
FRONTEND_VERSION_TAG="$USERNAME/mytube:frontend-$VERSION"
|
||||
fi
|
||||
|
||||
# Default build arguments (can be overridden by environment variables)
|
||||
VITE_API_URL=${VITE_API_URL:-"http://localhost:5551/api"}
|
||||
@@ -18,7 +26,10 @@ echo "✅ Docker is running!"
|
||||
# Build backend image with no-cache to force rebuild
|
||||
echo "🏗️ Building backend image..."
|
||||
cd backend
|
||||
$DOCKER_PATH build --no-cache --platform linux/amd64 -t $BACKEND_IMAGE .
|
||||
$DOCKER_PATH build --no-cache --platform linux/amd64 -t $BACKEND_LATEST .
|
||||
if [ -n "$VERSION" ]; then
|
||||
$DOCKER_PATH tag $BACKEND_LATEST $BACKEND_VERSION_TAG
|
||||
fi
|
||||
cd ..
|
||||
|
||||
# Build frontend image with no-cache to force rebuild
|
||||
@@ -27,17 +38,31 @@ cd frontend
|
||||
$DOCKER_PATH build --no-cache --platform linux/amd64 \
|
||||
--build-arg VITE_API_URL="$VITE_API_URL" \
|
||||
--build-arg VITE_BACKEND_URL="$VITE_BACKEND_URL" \
|
||||
-t $FRONTEND_IMAGE .
|
||||
-t $FRONTEND_LATEST .
|
||||
|
||||
if [ -n "$VERSION" ]; then
|
||||
$DOCKER_PATH tag $FRONTEND_LATEST $FRONTEND_VERSION_TAG
|
||||
fi
|
||||
cd ..
|
||||
|
||||
# Push images to Docker Hub
|
||||
echo "🚀 Pushing images to Docker Hub..."
|
||||
$DOCKER_PATH push $BACKEND_IMAGE
|
||||
$DOCKER_PATH push $FRONTEND_IMAGE
|
||||
$DOCKER_PATH push $BACKEND_LATEST
|
||||
$DOCKER_PATH push $FRONTEND_LATEST
|
||||
|
||||
if [ -n "$VERSION" ]; then
|
||||
echo "🚀 Pushing versioned images..."
|
||||
$DOCKER_PATH push $BACKEND_VERSION_TAG
|
||||
$DOCKER_PATH push $FRONTEND_VERSION_TAG
|
||||
fi
|
||||
|
||||
echo "✅ Successfully built and pushed images to Docker Hub!"
|
||||
echo "Backend image: $BACKEND_IMAGE"
|
||||
echo "Frontend image: $FRONTEND_IMAGE"
|
||||
echo "Backend image: $BACKEND_LATEST"
|
||||
echo "Frontend image: $FRONTEND_LATEST"
|
||||
if [ -n "$VERSION" ]; then
|
||||
echo "Backend version: $BACKEND_VERSION_TAG"
|
||||
echo "Frontend version: $FRONTEND_VERSION_TAG"
|
||||
fi
|
||||
echo ""
|
||||
echo "To deploy to your server or QNAP Container Station:"
|
||||
echo "1. Upload the docker-compose.yml file to your server"
|
||||
|
||||
61
release.sh
Executable file
61
release.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Function to display usage
|
||||
usage() {
|
||||
echo "Usage: $0 <version|major|minor|patch>"
|
||||
echo "Examples:"
|
||||
echo " $0 1.2.0"
|
||||
echo " $0 patch"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if argument is provided
|
||||
if [ -z "$1" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
INPUT_VERSION=$1
|
||||
|
||||
# Ensure git workspace is clean
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "❌ Git workspace is not clean. Please commit or stash changes first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure we are on main branch
|
||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
if [ "$CURRENT_BRANCH" != "main" ]; then
|
||||
echo "⚠️ You are not on the main branch (current: $CURRENT_BRANCH)."
|
||||
read -p "Do you want to continue? (y/N) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update version in package.json files
|
||||
echo "🔄 Updating version numbers..."
|
||||
npm version $INPUT_VERSION --no-git-tag-version --allow-same-version
|
||||
|
||||
# Get the new version number
|
||||
NEW_VERSION=$(node -p "require('./package.json').version")
|
||||
echo "✅ New version: $NEW_VERSION"
|
||||
|
||||
# Update sub-packages
|
||||
cd frontend && npm version $NEW_VERSION --no-git-tag-version --allow-same-version && cd ..
|
||||
cd backend && npm version $NEW_VERSION --no-git-tag-version --allow-same-version && cd ..
|
||||
|
||||
# Commit and Tag
|
||||
echo "📦 Committing and tagging..."
|
||||
git add package.json frontend/package.json backend/package.json
|
||||
git commit -m "chore(release): v$NEW_VERSION"
|
||||
git tag "v$NEW_VERSION"
|
||||
|
||||
echo "✅ Version bumped and tagged: v$NEW_VERSION"
|
||||
|
||||
# Build and Push
|
||||
echo "🚀 Starting build and push process..."
|
||||
./build-and-push.sh $NEW_VERSION
|
||||
|
||||
echo "🎉 Release v$NEW_VERSION completed successfully!"
|
||||
Reference in New Issue
Block a user