Skip to content

feat: Add issue and pull request templates for better contribution gu… #10

feat: Add issue and pull request templates for better contribution gu…

feat: Add issue and pull request templates for better contribution gu… #10

Workflow file for this run

name: Pre-release
on:
push:
branches:
- develop
- feature/*
- fix/*
workflow_dispatch:
permissions:
contents: write
jobs:
pre-release:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
python manage.py check
pytest --verbose
- name: Generate pre-release version
id: version
run: |
# Get current date and time for unique versioning
TIMESTAMP=$(date +'%Y%m%d-%H%M%S')
BRANCH_NAME=${GITHUB_REF#refs/heads/}
BRANCH_CLEAN=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9-]/-/g')
# Get short commit hash
COMMIT_HASH=$(git rev-parse --short HEAD)
# Create pre-release version
VERSION="pre-${TIMESTAMP}-${BRANCH_CLEAN}-${COMMIT_HASH}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=pre-release-$VERSION" >> $GITHUB_OUTPUT
echo "name=Pre-release $VERSION" >> $GITHUB_OUTPUT
- name: Delete old pre-releases
run: |
# Keep only the last 5 pre-releases to avoid clutter
gh release list --limit 20 | grep "Pre-release" | tail -n +6 | while read line; do
tag=$(echo "$line" | awk '{print $1}')
echo "Deleting old pre-release: $tag"
gh release delete "$tag" --yes || true
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create pre-release archives
run: |
mkdir -p dist/
# Create timestamp-based archives
git archive --format=tar.gz --prefix=SecCodeSmith-backend-${{ steps.version.outputs.version }}/ HEAD > dist/SecCodeSmith-backend-${{ steps.version.outputs.version }}.tar.gz
git archive --format=zip --prefix=SecCodeSmith-backend-${{ steps.version.outputs.version }}/ HEAD > dist/SecCodeSmith-backend-${{ steps.version.outputs.version }}.zip
- name: Generate development notes
run: |
cat > DEV_NOTES.md << 'EOF'
## 🚧 Development Pre-release
This is an automated pre-release build from the development branch.
### ⚠️ Important Notes:
- This is a **development build** and may contain unstable features
- Not recommended for production use
- Use for testing and development purposes only
### πŸ“‹ Build Information:
- **Branch**: `${{ github.ref_name }}`
- **Commit**: `${{ github.sha }}`
- **Build Time**: `$(date -u '+%Y-%m-%d %H:%M:%S UTC')`
- **Workflow**: `${{ github.workflow }}`
### πŸ§ͺ Tests Status:
- βœ… All tests passed
- βœ… Code quality checks passed
- βœ… Security scans completed
### πŸ“¦ What's Included:
- Source code archive (tar.gz and zip)
- Development deployment scripts
- Latest documentation
### πŸš€ Quick Start:
```bash
# Download and extract
wget https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/SecCodeSmith-backend-${{ steps.version.outputs.version }}.tar.gz
tar -xzf SecCodeSmith-backend-${{ steps.version.outputs.version }}.tar.gz
cd SecCodeSmith-backend-${{ steps.version.outputs.version }}
# Set up and run
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
```
### πŸ”— Related Links:
- [Main Repository](https://github.com/${{ github.repository }})
- [Latest Stable Release](https://github.com/${{ github.repository }}/releases/latest)
- [Development Documentation](https://github.com/${{ github.repository }}/wiki)
---
*This pre-release will be automatically cleaned up when newer versions are created.*
EOF
- name: Create pre-release
uses: actions/create-release@v1
id: create_prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.tag }}
release_name: ${{ steps.version.outputs.name }}
body_path: DEV_NOTES.md
draft: false
prerelease: true
- name: Upload pre-release tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_prerelease.outputs.upload_url }}
asset_path: ./dist/SecCodeSmith-backend-${{ steps.version.outputs.version }}.tar.gz
asset_name: SecCodeSmith-backend-${{ steps.version.outputs.version }}.tar.gz
asset_content_type: application/gzip
- name: Upload pre-release zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_prerelease.outputs.upload_url }}
asset_path: ./dist/SecCodeSmith-backend-${{ steps.version.outputs.version }}.zip
asset_name: SecCodeSmith-backend-${{ steps.version.outputs.version }}.zip
asset_content_type: application/zip
- name: Create development deployment script
run: |
cat > dist/dev-deploy.sh << 'EOF'
#!/bin/bash
# SecCodeSmith Backend Development Deployment Script
set -e
echo "🚧 Starting SecCodeSmith Backend development deployment..."
echo "⚠️ This is a development build - not for production!"
# Check for required tools
command -v python3 >/dev/null 2>&1 || { echo "Python 3 is required but not installed. Aborting." >&2; exit 1; }
command -v pip >/dev/null 2>&1 || { echo "pip is required but not installed. Aborting." >&2; exit 1; }
# Create virtual environment
echo "πŸ“¦ Setting up virtual environment..."
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
echo "⬇️ Installing dependencies..."
pip install --upgrade pip
pip install -r requirements.txt
# Set up environment variables for development
echo "βš™οΈ Setting up development environment..."
cat > .env << 'ENVEOF'
DEBUG=True
SECRET_KEY=dev-secret-key-change-in-production
ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0
DATABASE_TYPE=sqlite
ENVEOF
# Run migrations
echo "πŸ—„οΈ Running database migrations..."
python manage.py migrate
# Create superuser (optional)
echo "πŸ‘€ Creating superuser (optional)..."
echo "To create a superuser for admin access, run:"
echo "python manage.py createsuperuser"
# Start development server
echo "βœ… Development deployment complete!"
echo ""
echo "πŸš€ To start the development server:"
echo "source .venv/bin/activate"
echo "python manage.py runserver"
echo ""
echo "πŸ“ Access the API at: http://localhost:8000/"
echo "πŸ”§ Access admin panel at: http://localhost:8000/admin/"
EOF
chmod +x dist/dev-deploy.sh
- name: Upload development deployment script
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_prerelease.outputs.upload_url }}
asset_path: ./dist/dev-deploy.sh
asset_name: dev-deploy.sh
asset_content_type: application/x-shellscript
- name: Notify on success
if: success()
run: |
echo "βœ… Pre-release ${{ steps.version.outputs.name }} created successfully!"
echo "πŸ”— View at: https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag }}"