| 1 |
--- |
| 2 |
name: "Tag & Release management" |
| 3 |
"on": |
| 4 |
release: |
| 5 |
types: |
| 6 |
- published |
| 7 |
|
| 8 |
|
| 9 |
workflow_dispatch: |
| 10 |
inputs: |
| 11 |
TESTPYPI_VERSION: |
| 12 |
description: "Version string to use for manual push to test Pypi" |
| 13 |
required: true |
| 14 |
type: string |
| 15 |
|
| 16 |
permissions: |
| 17 |
contents: read |
| 18 |
|
| 19 |
jobs: |
| 20 |
target_version: |
| 21 |
name: ๐ฏ Set target version |
| 22 |
runs-on: ubuntu-latest |
| 23 |
outputs: |
| 24 |
current_version: ${{ steps.target_version.outputs.CURRENT_VERSION }} |
| 25 |
target_version: ${{ steps.target_version.outputs.TARGET_VERSION }} |
| 26 |
steps: |
| 27 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 |
| 28 |
with: |
| 29 |
persist-credentials: false |
| 30 |
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 |
| 31 |
with: |
| 32 |
python-version: "3.12" |
| 33 |
- name: Install `bumpver` |
| 34 |
run: |- |
| 35 |
pip install bumpver |
| 36 |
- name: Set target version |
| 37 |
id: target_version |
| 38 |
env: |
| 39 |
INPUT_VALUE: ${{ inputs.TESTPYPI_VERSION }} |
| 40 |
run: |- |
| 41 |
CURRENT_VERSION=$(bumpver show --environ | grep PEP | cut -f "2" -d "=") |
| 42 |
TARGET_VERSION="${INPUT_VALUE:-$CURRENT_VERSION}" |
| 43 |
echo "TARGET_VERSION=$TARGET_VERSION" >> $GITHUB_OUTPUT |
| 44 |
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_OUTPUT |
| 45 |
|
| 46 |
build-anta-dist: |
| 47 |
name: ๐จ Build ANTA distribution ${{ needs.target_version.outputs.target_version }} |
| 48 |
needs: [target_version] |
| 49 |
|
| 50 |
runs-on: ubuntu-latest |
| 51 |
steps: |
| 52 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 |
| 53 |
with: |
| 54 |
persist-credentials: false |
| 55 |
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 |
| 56 |
with: |
| 57 |
python-version: "3.12" |
| 58 |
- name: Install Python requirements |
| 59 |
run: |- |
| 60 |
pip install bumpver build setuptools |
| 61 |
- name: Update version |
| 62 |
if: needs.target_version.outputs.target_version != needs.target_version.outputs.current_version |
| 63 |
env: |
| 64 |
TARGET_VERSION: ${{ needs.target_version.outputs.target_version }} |
| 65 |
run: |- |
| 66 |
git config --global user.email "[email protected]" |
| 67 |
git config --global user.name "ANTA CI BOT" |
| 68 |
bumpver update --set-version "$TARGET_VERSION" |
| 69 |
- name: Build |
| 70 |
run: |- |
| 71 |
python -m build |
| 72 |
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a |
| 73 |
with: |
| 74 |
name: anta-dist |
| 75 |
path: dist/ |
| 76 |
|
| 77 |
publish-anta-testpypi: |
| 78 |
name: ๐ฆ ๐ Publish ANTA Python distribution to test PyPI |
| 79 |
needs: [build-anta-dist] |
| 80 |
runs-on: ubuntu-latest |
| 81 |
if: | |
| 82 |
github.event_name == 'release' |
| 83 |
|| (github.event_name == 'workflow_dispatch') |
| 84 |
|
| 85 |
environment: |
| 86 |
name: test |
| 87 |
url: https://test.pypi.org/p/anta |
| 88 |
permissions: |
| 89 |
contents: read |
| 90 |
id-token: write |
| 91 |
steps: |
| 92 |
- name: Download anta dist |
| 93 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| 94 |
with: |
| 95 |
name: anta-dist |
| 96 |
path: dist/ |
| 97 |
- name: Publish distribution to PyPI |
| 98 |
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b |
| 99 |
with: |
| 100 |
repository-url: https://test.pypi.org/legacy/ |
| 101 |
|
| 102 |
skip-existing: true |
| 103 |
|
| 104 |
test-anta-from-test-pypi: |
| 105 |
name: ๐งช Test from test PyPI on ${{ matrix.os }} for python ${{ matrix.python }} |
| 106 |
needs: [target_version, publish-anta-testpypi] |
| 107 |
runs-on: ${{ matrix.os }} |
| 108 |
if: | |
| 109 |
github.event_name == 'release' |
| 110 |
|| (github.event_name == 'workflow_dispatch') |
| 111 |
|
| 112 |
strategy: |
| 113 |
matrix: |
| 114 |
os: |
| 115 |
- ubuntu-latest |
| 116 |
- ubuntu-24.04-arm |
| 117 |
- windows-latest |
| 118 |
- macos-15-intel |
| 119 |
- macos-latest |
| 120 |
python: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
| 121 |
steps: |
| 122 |
- name: Checkout only the tests |
| 123 |
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 |
| 124 |
with: |
| 125 |
persist-credentials: false |
| 126 |
sparse-checkout: |- |
| 127 |
tests |
| 128 |
pyproject.toml |
| 129 |
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 |
| 130 |
with: |
| 131 |
python-version: ${{ matrix.python }} |
| 132 |
- name: Install `anta` from test Pypi |
| 133 |
env: |
| 134 |
TARGET_VERSION: ${{ needs.target_version.outputs.target_version }} |
| 135 |
shell: bash |
| 136 |
run: |- |
| 137 |
pip install -i https://test.pypi.org/simple/ "anta[cli]==$TARGET_VERSION" --group test --extra-index-url https://pypi.org/simple |
| 138 |
- name: Run tests |
| 139 |
run: |- |
| 140 |
pytest tests/units |
| 141 |
|
| 142 |
publish-anta-pypi: |
| 143 |
name: ๐ฆ ๐ Publish ANTA Python distribution to PyPI |
| 144 |
needs: [test-anta-from-test-pypi] |
| 145 |
runs-on: ubuntu-latest |
| 146 |
|
| 147 |
if: github.event_name == 'release' |
| 148 |
environment: |
| 149 |
name: production |
| 150 |
url: https://pypi.org/p/anta |
| 151 |
permissions: |
| 152 |
contents: read |
| 153 |
id-token: write |
| 154 |
steps: |
| 155 |
- name: Checkout code |
| 156 |
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 |
| 157 |
with: |
| 158 |
persist-credentials: false |
| 159 |
- name: Download anta dist |
| 160 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| 161 |
with: |
| 162 |
name: anta-dist |
| 163 |
path: dist/ |
| 164 |
- name: Publish distribution ๐ฆ to PyPI |
| 165 |
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b |
| 166 |
|
| 167 |
release-doc: |
| 168 |
name: "Publish documentation for release ${{github.ref_name}}" |
| 169 |
runs-on: ubuntu-latest |
| 170 |
|
| 171 |
needs: [publish-anta-pypi] |
| 172 |
permissions: |
| 173 |
contents: write |
| 174 |
steps: |
| 175 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 |
| 176 |
with: |
| 177 |
fetch-depth: 0 |
| 178 |
persist-credentials: false |
| 179 |
- name: 'Setup Python 3 on runner' |
| 180 |
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 |
| 181 |
with: |
| 182 |
python-version: '3.x' |
| 183 |
- name: Setup Git config |
| 184 |
run: | |
| 185 |
git config --global user.name 'github-actions[bot]' |
| 186 |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 187 |
|
| 188 |
- name: 'Build Zensical content to site folder' |
| 189 |
env: |
| 190 |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 191 |
REF_NAME: ${{ github.ref_name }} |
| 192 |
run: | |
| 193 |
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" |
| 194 |
pip install --group doc -e tools/zensical_extensions |
| 195 |
mike deploy --update-alias --push "$REF_NAME" stable |
| 196 |
|
| 197 |
docker: |
| 198 |
name: Docker Image Build |
| 199 |
runs-on: ubuntu-latest |
| 200 |
|
| 201 |
needs: [publish-anta-pypi] |
| 202 |
permissions: |
| 203 |
contents: read |
| 204 |
packages: write |
| 205 |
strategy: |
| 206 |
matrix: |
| 207 |
platform: |
| 208 |
- linux/amd64 |
| 209 |
- linux/arm64 |
| 210 |
- linux/arm/v7 |
| 211 |
- linux/arm/v8 |
| 212 |
steps: |
| 213 |
- name: Checkout |
| 214 |
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 |
| 215 |
with: |
| 216 |
persist-credentials: false |
| 217 |
|
| 218 |
- name: Docker meta for TAG |
| 219 |
id: meta |
| 220 |
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 |
| 221 |
with: |
| 222 |
images: ghcr.io/${{ github.repository }} |
| 223 |
tags: | |
| 224 |
type=semver,pattern={{version}} |
| 225 |
type=raw,value=latest |
| 226 |
|
| 227 |
- name: Login to GitHub Container Registry |
| 228 |
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee |
| 229 |
with: |
| 230 |
registry: ghcr.io |
| 231 |
username: ${{ github.actor }} |
| 232 |
password: ${{ secrets.GITHUB_TOKEN }} |
| 233 |
|
| 234 |
- name: Build and push |
| 235 |
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf |
| 236 |
with: |
| 237 |
context: . |
| 238 |
file: Dockerfile |
| 239 |
push: true |
| 240 |
platforms: linux/amd64 |
| 241 |
tags: ${{ steps.meta.outputs.tags }} |
| 242 |
labels: ${{ steps.meta.outputs.labels }} |