feat: Add issue and pull request templates for better contribution gu⦠#10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" |