--- 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 permissions: contents: read 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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: "3.12" - name: Install `bumpver` run: |- pip install bumpver - name: Set target version id: target_version env: INPUT_VALUE: ${{ inputs.TESTPYPI_VERSION }} run: |- CURRENT_VERSION=$(bumpver show --environ | grep PEP | cut -f "2" -d "=") 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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 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 env: TARGET_VERSION: ${{ needs.target_version.outputs.target_version }} run: |- git config --global user.email "anta-dev@arista.com" git config --global user.name "ANTA CI BOT" bumpver update --set-version "$TARGET_VERSION" - name: Build run: |- python -m build - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 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: contents: read id-token: write steps: - name: Download anta dist uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: anta-dist path: dist/ - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false sparse-checkout: |- tests pyproject.toml - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: ${{ matrix.python }} - name: Install `anta` from test Pypi env: TARGET_VERSION: ${{ needs.target_version.outputs.target_version }} shell: bash run: |- pip install -i https://test.pypi.org/simple/ "anta[cli]==$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: contents: read id-token: write steps: - name: Checkout code uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false - name: Download anta dist uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: anta-dist path: dist/ - name: Publish distribution ๐Ÿ“ฆ to PyPI uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 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] permissions: contents: write steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: fetch-depth: 0 persist-credentials: false - name: 'Setup Python 3 on runner' uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 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 Zensical content to site folder' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REF_NAME: ${{ github.ref_name }} run: | git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" pip install --group doc -e tools/zensical_extensions mike deploy --update-alias --push "$REF_NAME" stable docker: name: Docker Image Build runs-on: ubuntu-latest # Release docker only if successfully deployed to Pypi needs: [publish-anta-pypi] permissions: contents: read packages: write strategy: matrix: platform: - linux/amd64 - linux/arm64 - linux/arm/v7 - linux/arm/v8 steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false - name: Docker meta for TAG id: meta uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0 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@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0 with: context: . file: Dockerfile push: true platforms: linux/amd64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}