Restore action that was errorneously deleted in d1d3912e9aed14be28c75… #265
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: CI and release pipeline | |
| on: | |
| pull_request: | |
| push: | |
| branches: [ "main", "develop" ] | |
| tags: [ "*" ] | |
| jobs: | |
| static-analysis: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| check: | |
| - name: Check code-formatting | |
| run: poetry run ruff format --check . | |
| - name: Lint | |
| run: poetry run ruff check | |
| - name: Check static typing | |
| run: poetry run mypy dmarc_metrics_exporter | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: git fetch --no-tags --prune --depth=1 origin | |
| +refs/heads/main:refs/remotes/origin/main | |
| - name: Set up Python | |
| uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: "3.13" | |
| - uses: actions/cache@v5.0.0 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip | |
| - uses: actions/cache@v5.0.0 | |
| with: | |
| path: .venv | |
| key: ${{ runner.os }}-py3.13-venv-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-py3.13-venv- | |
| - uses: ./.github/actions/setup-project | |
| - name: ${{ matrix.check.name }} | |
| run: ${{ matrix.check.run }} | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - uses: actions/cache@v5.0.0 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip | |
| - uses: actions/cache@v5.0.0 | |
| with: | |
| path: .venv | |
| key: ${{ runner.os }}-py${{ matrix.python-version }}-venv-${{ | |
| hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-py${{ matrix.python-version }}-venv- | |
| - uses: ./.github/actions/setup-project | |
| - name: Start required services (Greenmail) | |
| run: docker compose up -d | |
| - name: Test and measure coverage with pytest | |
| run: poetry run pytest --verbose --cov=dmarc_metrics_exporter --cov-report=xml | |
| - uses: codecov/codecov-action@v6 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [ static-analysis, test ] | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6.2.0 | |
| with: | |
| python-version: "3.13" | |
| - uses: actions/cache@v5.0.0 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip | |
| - uses: actions/cache@v5.0.0 | |
| with: | |
| path: .venv | |
| key: ${{ runner.os }}-py3.13-venv-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-py3.13-venv- | |
| - uses: ./.github/actions/setup-project | |
| - name: Publish to PyPI | |
| run: poetry publish --build | |
| env: | |
| POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} | |
| - name: Wait for release to become available | |
| run: sleep 10 | |
| - name: Set version | |
| id: version | |
| run: echo "version=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT | |
| - name: Extract changelog | |
| id: changelog | |
| run: sed -E -n '/^\[${{ steps.version.outputs.version | |
| }}\]/,/^\[[0-9\.]+\]/{/^\[[0-9\.]+\]|^-+$/!p;}' CHANGELOG.rst > | |
| release-body.rst | |
| - uses: docker://pandoc/core:3 | |
| with: | |
| args: --wrap none -f rst -t gfm --output=release-body.md release-body.rst | |
| - name: Check if prerelease | |
| id: check-prerelease | |
| uses: ./.github/actions/check-prerelease | |
| with: | |
| version: ${{ steps.version.outputs.version }} | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body_path: release-body.md | |
| tag_name: v${{ steps.version.outputs.version }} | |
| prerelease: ${{ steps.check-prerelease.outputs.prerelease }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| docker-image: | |
| needs: [ release ] | |
| uses: "jgosmann/dmarc-metrics-exporter/.github/workflows/docker-publish.yml@main" | |
| with: | |
| version: ${{ github.ref }} | |
| secrets: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |