Skip to content

refactor: Remove Makefile and adjust Codecov target coverage to 70% #21

refactor: Remove Makefile and adjust Codecov target coverage to 70%

refactor: Remove Makefile and adjust Codecov target coverage to 70% #21

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.0.0)'
required: true
type: string
push:
tags:
- 'v*'
permissions:
contents: write
pages: write
id-token: write
jobs:
create-release:
runs-on: ubuntu-latest
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
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: Set release version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Generate changelog
id: changelog
run: |
# Generate changelog from git commits since last tag
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
CHANGES=$(git log --pretty=format:"- %s" --no-merges)
else
CHANGES=$(git log --pretty=format:"- %s" --no-merges $LAST_TAG..HEAD)
fi
# Create changelog content
cat > CHANGELOG_TEMP.md << EOF
## What's Changed
$CHANGES
## πŸš€ Features
- Enhanced Django REST API functionality
- Improved test coverage and CI/CD pipeline
- Updated documentation and README
## πŸ› Bug Fixes
- Various bug fixes and improvements
## πŸ”§ Technical Improvements
- Code quality improvements
- Security enhancements
- Performance optimizations
**Full Changelog**: https://github.com/${{ github.repository }}/compare/$LAST_TAG...${{ steps.version.outputs.version }}
EOF
- name: Run tests
run: |
python manage.py check
pytest --verbose
- name: Create source distribution
run: |
# Create a clean source archive
mkdir -p dist/
git archive --format=tar.gz --prefix=SecCodeSmith-backend-${{ steps.version.outputs.version_number }}/ HEAD > dist/SecCodeSmith-backend-${{ steps.version.outputs.version_number }}.tar.gz
git archive --format=zip --prefix=SecCodeSmith-backend-${{ steps.version.outputs.version_number }}/ HEAD > dist/SecCodeSmith-backend-${{ steps.version.outputs.version_number }}.zip
- name: Generate deployment artifacts
run: |
# Create deployment script
cat > dist/deploy.sh << 'EOF'
#!/bin/bash
# SecCodeSmith Backend Deployment Script
set -e
echo "πŸš€ Starting SecCodeSmith Backend deployment..."
# Update system packages
sudo apt-get update
# Install Python and dependencies
sudo apt-get install -y python3 python3-pip python3-venv postgresql postgresql-contrib redis-server
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install Python dependencies
pip install -r requirements.txt
# Set up database
python manage.py migrate
# Collect static files (if applicable)
python manage.py collectstatic --noinput || true
# Create superuser (optional)
echo "To create a superuser, run: python manage.py createsuperuser"
# Start services
echo "βœ… Deployment complete!"
echo "To start the server, run: python manage.py runserver"
EOF
chmod +x dist/deploy.sh
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.version }}
release_name: SecCodeSmith Backend ${{ steps.version.outputs.version }}
body_path: CHANGELOG_TEMP.md
draft: false
prerelease: false
- name: Upload Source Archive (tar.gz)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/SecCodeSmith-backend-${{ steps.version.outputs.version_number }}.tar.gz
asset_name: SecCodeSmith-backend-${{ steps.version.outputs.version_number }}.tar.gz
asset_content_type: application/gzip
- name: Upload Source Archive (zip)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/SecCodeSmith-backend-${{ steps.version.outputs.version_number }}.zip
asset_name: SecCodeSmith-backend-${{ steps.version.outputs.version_number }}.zip
asset_content_type: application/zip
- name: Upload Deployment Script
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/deploy.sh
asset_name: deploy.sh
asset_content_type: application/x-shellscript
- name: Generate Docker image (if Dockerfile exists)
if: hashFiles('Dockerfile') != ''
run: |
docker build -t seccodesmith/backend:${{ steps.version.outputs.version_number }} .
docker build -t seccodesmith/backend:latest .
# Save Docker image as artifact
docker save seccodesmith/backend:${{ steps.version.outputs.version_number }} | gzip > dist/seccodesmith-backend-${{ steps.version.outputs.version_number }}-docker.tar.gz
- name: Upload Docker Image
if: hashFiles('Dockerfile') != ''
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/seccodesmith-backend-${{ steps.version.outputs.version_number }}-docker.tar.gz
asset_name: seccodesmith-backend-${{ steps.version.outputs.version_number }}-docker.tar.gz
asset_content_type: application/gzip
create-documentation:
runs-on: ubuntu-latest
needs: create-release
if: github.ref == 'refs/heads/main' || github.ref_type == 'tag'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11.x
- name: Install documentation dependencies
run: |
python -m pip install --upgrade pip
pip install sphinx sphinx-rtd-theme
- name: Generate API documentation
run: |
# Create basic documentation structure
mkdir -p docs/
cat > docs/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SecCodeSmith Backend Documentation</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; line-height: 1.6; }
.header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; border-radius: 8px; }
.section { margin: 20px 0; }
.code { background: #f4f4f4; padding: 10px; border-radius: 4px; font-family: monospace; }
.endpoint { background: #e8f5e8; padding: 10px; margin: 5px 0; border-left: 4px solid #4CAF50; }
</style>
</head>
<body>
<div class="header">
<h1>πŸ”₯ SecCodeSmith Backend API</h1>
<p>Django-powered REST API for the SecCodeSmith portfolio website</p>
</div>
<div class="section">
<h2>πŸ“š API Endpoints</h2>
<div class="endpoint">
<strong>GET /api/csrf</strong><br>
Retrieve CSRF token for secure form submissions
</div>
<div class="endpoint">
<strong>GET /api/skills-cards</strong><br>
List skill cards for frontend display
</div>
<div class="endpoint">
<strong>GET /api/about/</strong><br>
Get content for the About page
</div>
<div class="endpoint">
<strong>GET /api/footer-links</strong><br>
List social and footer links
</div>
<div class="endpoint">
<strong>GET /api/contact/</strong><br>
Get content for the Contact page
</div>
<div class="endpoint">
<strong>GET /blog-api/post/</strong><br>
List all blog posts
</div>
<div class="endpoint">
<strong>GET /project-api/projects/</strong><br>
List all projects
</div>
</div>
<div class="section">
<h2>πŸš€ Quick Start</h2>
<div class="code">
# Clone the repository<br>
git clone https://github.com/SecCodeSmith/SecCodeSmith-backend.git<br>

Check failure on line 286 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

You have an error in your yaml syntax on line 286
cd SecCodeSmith-backend<br><br>
# Set up virtual environment<br>
python -m venv .venv<br>
source .venv/bin/activate # On Windows: .venv\Scripts\activate<br><br>
# Install dependencies<br>
pip install -r requirements.txt<br><br>
# Run migrations and start server<br>
python manage.py migrate<br>
python manage.py runserver
</div>
</div>
<div class="section">
<h2>πŸ“– More Information</h2>
<p>For detailed documentation, please refer to the <a href="https://github.com/SecCodeSmith/SecCodeSmith-backend">GitHub Repository</a>.</p>
</div>
</body>
</html>
EOF
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
destination_dir: docs