| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- name: Release
- on:
- push:
- tags:
- - 'v*'
- workflow_dispatch:
- permissions:
- contents: write
- pull-requests: read
- jobs:
- release:
- name: Create Release
- runs-on: ubuntu-latest
- timeout-minutes: 10
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v7
- with:
- fetch-depth: 0
- - name: Set up Python
- uses: actions/setup-python@v6.3.0
- with:
- python-version: "3.11"
- cache: 'pip'
- - name: Install system dependencies
- run: |
- sudo apt-get update
- sudo apt-get install -y build-essential libssl-dev libicapapi-dev python3-dev libpq-dev
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- - name: Create distribution
- run: |
- # Create a simple distribution with the necessary files
- mkdir -p dist/squidstats
- cp -r app.py requirements.txt database/ parsers/ services/ static/ templates/ utils/ dist/squidstats/
- cd dist && tar -czf squidstats-${GITHUB_REF_NAME}.tar.gz squidstats/
- - name: Generate changelog
- id: changelog
- run: |
- # Get the previous tag
- PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
-
- # Generate changelog
- if [ -n "$PREV_TAG" ]; then
- echo "## Changes since $PREV_TAG" > CHANGELOG.md
- git log --pretty=format:"- %s (%h)" $PREV_TAG..HEAD >> CHANGELOG.md
- else
- echo "## Initial Release" > CHANGELOG.md
- echo "First release of SquidStats" >> CHANGELOG.md
- fi
-
- echo "changelog<<EOF" >> $GITHUB_OUTPUT
- cat CHANGELOG.md >> $GITHUB_OUTPUT
- echo "EOF" >> $GITHUB_OUTPUT
- - name: Create Release
- id: create_release
- uses: actions/create-release@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- tag_name: ${{ github.ref_name }}
- release_name: SquidStats ${{ github.ref_name }}
- body: ${{ steps.changelog.outputs.changelog }}
- draft: false
- prerelease: false
- - name: Upload Release Asset
- uses: actions/upload-release-asset@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: ./dist/squidstats-${{ github.ref_name }}.tar.gz
- asset_name: squidstats-${{ github.ref_name }}.tar.gz
- asset_content_type: application/gzip
- docker:
- name: Build Docker Image
- runs-on: ubuntu-latest
- timeout-minutes: 20
- needs: release
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v7
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
- - name: Login to GitHub Container Registry
- uses: docker/login-action@v3
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- - name: Extract metadata
- id: meta
- uses: docker/metadata-action@v5
- with:
- images: ghcr.io/${{ github.repository_owner }}/squidstats
- tags: |
- type=ref,event=tag
- type=semver,pattern={{version}}
- type=semver,pattern={{major}}.{{minor}}
- type=semver,pattern={{major}}
- - name: Build and push Docker image
- uses: docker/build-push-action@v5
- with:
- context: .
- push: true
- tags: ${{ steps.meta.outputs.tags }}
- labels: ${{ steps.meta.outputs.labels }}
- cache-from: type=gha
- cache-to: type=gha,mode=max
|