General improvements #106
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: Python application and Docker image CI | |
| on: | |
| push: | |
| branches: [ master, develop, feature/* ] | |
| tags: [ '*.*.*' ] # Enable pipeline on tag pushes | |
| pull_request: | |
| branches: [ master, develop ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| sudo apt-get -qq update | |
| sudo apt-get install -y libemail-outlook-message-perl | |
| uv sync | |
| export PERL_MM_USE_DEFAULT=1 | |
| sudo cpan -f -i Email::Outlook::Message | |
| - name: Run tests | |
| env: | |
| PYTHONPATH: src | |
| run: | | |
| make test | |
| uv run mail-parser -v | |
| uv run mail-parser -h | |
| uv run mail-parser -f tests/mails/mail_malformed_3 -j | |
| cat tests/mails/mail_malformed_3 | uv run mail-parser -k -j | |
| - name: Run pre-commit | |
| run: | | |
| make pre-commit | |
| - name: Report to Coveralls | |
| if: matrix.python-version == '3.10' | |
| uses: coverallsapp/github-action@v2.2.3 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build | |
| if: matrix.python-version == '3.10' | |
| run: | | |
| uv build | |
| - name: Upload artifacts | |
| if: matrix.python-version == '3.10' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: | | |
| dist/mail_parser-* | |
| - name: Publish to PyPI | |
| if: matrix.python-version == '3.10' && startsWith(github.ref, 'refs/tags/') | |
| uses: pypa/gh-action-pypi-publish@v1.13.0 | |
| with: | |
| user: ${{ secrets.PYPI_USERNAME }} | |
| password: ${{ secrets.PYPI_PASSWORD }} | |
| docker: | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: dist/ | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: docker.io | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract branch or tag name | |
| id: extract_ref | |
| run: | | |
| if [ -n "${GITHUB_HEAD_REF}" ]; then | |
| REF_NAME=${GITHUB_HEAD_REF} | |
| else | |
| REF_NAME=$(git describe --tags --exact-match 2>/dev/null || git rev-parse --abbrev-ref HEAD) | |
| fi | |
| echo "REF_NAME=${REF_NAME,,}" >> $GITHUB_ENV | |
| - name: Build and push Docker image on GitHub Container Registry | |
| run: | | |
| IMAGE_NAME=ghcr.io/ghcr.io/spamscope/mail-parser/mailparser | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| TAG=${GITHUB_REF#refs/tags/} | |
| docker build \ | |
| --label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ | |
| --label "org.opencontainers.image.description=Easy way to pass from raw mail to Python object" \ | |
| --label "org.opencontainers.image.licenses=Apache-2.0" \ | |
| -t $IMAGE_NAME:$TAG \ | |
| -t $IMAGE_NAME:latest . | |
| docker push $IMAGE_NAME:$TAG | |
| docker push $IMAGE_NAME:latest | |
| else | |
| docker build \ | |
| --label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ | |
| --label "org.opencontainers.image.description=Easy way to pass from raw mail to Python object" \ | |
| --label "org.opencontainers.image.licenses=Apache-2.0" \ | |
| -t $IMAGE_NAME:develop . | |
| docker push $IMAGE_NAME:develop | |
| fi | |
| - name: Build and push Docker image on Docker Hub | |
| run: | | |
| IMAGE_NAME=docker.io/${{ secrets.DOCKER_USERNAME }}/spamscope-mail-parser | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| TAG=${GITHUB_REF#refs/tags/} | |
| docker build \ | |
| --label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ | |
| --label "org.opencontainers.image.description=Easy way to pass from raw mail to Python object" \ | |
| --label "org.opencontainers.image.licenses=Apache-2.0" \ | |
| -t $IMAGE_NAME:$TAG \ | |
| -t $IMAGE_NAME:latest . | |
| docker push $IMAGE_NAME:$TAG | |
| docker push $IMAGE_NAME:latest | |
| else | |
| docker build \ | |
| --label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ | |
| --label "org.opencontainers.image.description=Easy way to pass from raw mail to Python object" \ | |
| --label "org.opencontainers.image.licenses=Apache-2.0" \ | |
| -t $IMAGE_NAME:develop . | |
| docker push $IMAGE_NAME:develop | |
| fi |