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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
---
name: "Tag & Release management"
"on":
release:
types:
- published
# Allow for manual trigger on the selected branch in UI
# Reducing it to only execute on devel branch today.
workflow_dispatch:
inputs:
TESTPYPI_VERSION:
description: "Version string to use for manual push to test Pypi"
required: true
type: string
jobs:
target_version:
name: ๐ฏ Set target version
runs-on: ubuntu-latest
outputs:
current_version: ${{ steps.target_version.outputs.CURRENT_VERSION }}
target_version: ${{ steps.target_version.outputs.TARGET_VERSION }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install `bumpver`
run: |-
pip install bumpver
- name: Set target version
id: target_version
run: |-
CURRENT_VERSION=$(bumpver show --environ | grep PEP | cut -f "2" -d "=")
INPUT_VALUE="${{ inputs.TESTPYPI_VERSION }}"
TARGET_VERSION="${INPUT_VALUE:-$CURRENT_VERSION}"
echo "TARGET_VERSION=$TARGET_VERSION" >> $GITHUB_OUTPUT
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_OUTPUT
build-anta-dist:
name: ๐จ Build ANTA distribution ${{ needs.target_version.outputs.target_version }}
needs: [target_version]
# Building universal wheel as we are not platform dependent
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install Python requirements
run: |-
pip install bumpver build setuptools
- name: Update version
if: needs.target_version.outputs.target_version != needs.target_version.outputs.current_version
run: |-
git config --global user.email "anta-dev@arista.com"
git config --global user.name "ANTA CI BOT"
bumpver update --set-version ${{ needs.target_version.outputs.target_version }}
- name: Build
run: |-
python -m build
- uses: actions/upload-artifact@v6
with:
name: anta-dist
path: dist/
publish-anta-testpypi:
name: ๐ฆ ๐ Publish ANTA Python distribution to test PyPI
needs: [build-anta-dist]
runs-on: ubuntu-latest
if: |
github.event_name == 'release'
|| (github.event_name == 'workflow_dispatch')
# && github.ref == 'refs/heads/main')
environment:
name: test
url: https://test.pypi.org/p/anta
permissions:
id-token: write
steps:
- name: Download anta dist
uses: actions/download-artifact@v7
with:
name: anta-dist
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# For now
skip-existing: true
test-anta-from-test-pypi:
name: ๐งช Test from test PyPI on ${{ matrix.os }} for python ${{ matrix.python }}
needs: [target_version, publish-anta-testpypi]
runs-on: ${{ matrix.os }}
if: |
github.event_name == 'release'
|| (github.event_name == 'workflow_dispatch')
# && github.ref == 'refs/heads/main')
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-24.04-arm
- windows-latest
- macos-15-intel
- macos-latest
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout only the tests
uses: actions/checkout@v6
with:
sparse-checkout: |-
tests
pyproject.toml
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- name: Install `anta` from test Pypi
run: |-
pip install -i https://test.pypi.org/simple/ "anta[cli]==${{ needs.target_version.outputs.target_version }}" --group test --extra-index-url https://pypi.org/simple
- name: Run tests
run: |-
pytest tests/units
publish-anta-pypi:
name: ๐ฆ ๐ Publish ANTA Python distribution to PyPI
needs: [test-anta-from-test-pypi]
runs-on: ubuntu-latest
# We can only publish to Pypi if running on a published release, not with workflow_dispatch
if: github.event_name == 'release'
environment:
name: production
url: https://pypi.org/p/anta
permissions:
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download anta dist
uses: actions/download-artifact@v7
with:
name: anta-dist
path: dist/
- name: Publish distribution ๐ฆ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
release-doc:
name: "Publish documentation for release ${{github.ref_name}}"
runs-on: ubuntu-latest
# Release doc only if successfully deployed to Pypi
needs: [publish-anta-pypi]
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 'Setup Python 3 on runner'
uses: actions/setup-python@v6
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 --group doc
mike deploy --update-alias --push ${{github.ref_name}} stable
docker:
name: Docker Image Build
runs-on: ubuntu-latest
# Release docker only if successfully deployed to Pypi
needs: [publish-anta-pypi]
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7
- linux/arm/v8
steps:
- name: Checkout
uses: actions/checkout@v6
- 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@v6
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
|