summaryrefslogtreecommitdiffstats
path: root/.github/workflows/release.yml
blob: 6b9088f0c0b4e7f006c51984eec0dff2a41014a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
name: "Tag & Release management"
on:
  release:
    types:
      - published

jobs:
  pypi:
    name: Publish version to Pypi servers
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install setuptools wheel build
      - name: Build package
        run: |
          python -m build
      - name: Publish package to Pypi
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}

  release-coverage:
    name: Updated ANTA release coverage badge
    runs-on: ubuntu-20.04
    needs: [pypi]
    steps:
      - uses: actions/checkout@v4
      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - name: Install dependencies
        run: pip install genbadge[coverage] tox tox-gh-actions
      - name: "Run pytest via tox for ${{ matrix.python }}"
        run: tox
      - name: Generate coverage badge
        run: genbadge coverage -i .coverage.xml -o badge/latest-release-coverage.svg
      - name: Publish coverage badge to gh-pages branch
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          branch: coverage-badge
          folder: badge
  release-doc:
    name: "Publish documentation for release ${{github.ref_name}}"
    runs-on: ubuntu-latest
    needs: [release-coverage]
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: 'Setup Python 3 on runner'
        uses: actions/setup-python@v5
        with:
          python-version: '3.x'
      - name: Setup Git config
        run: |
          git config --global user.name 'github-actions[bot]'
          git config --global user.email 'github-actions[bot]@users.noreply.github.com'

      - name: 'Build mkdocs content to site folder'
        run: |
          pip install .[doc]
          mike deploy --update-alias --push  ${{github.ref_name}} stable

  docker:
    name: Docker Image Build
    runs-on: ubuntu-latest
    needs: [pypi]
    strategy:
      matrix:
        platform:
          - linux/amd64
          - linux/arm64
          - linux/arm/v7
          - linux/arm/v8
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Docker meta for TAG
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ghcr.io/${{ github.repository }}
          tags: |
            type=semver,pattern={{version}}
            type=raw,value=latest

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          context: .
          file: Dockerfile
          push: true
          platforms: linux/amd64
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}