ci: update github actions and enable renovate automerge #80
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: Test, Release and Publish | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| test: | |
| name: Test and Lint Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip-${{ matrix.python-version }}- | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| pip install ruff black mypy types-requests pytest flask | |
| - name: Run ruff (linting) | |
| run: | | |
| echo "Running ruff linter..." | |
| ruff check check_netscaler/ tests/ --output-format=github | |
| continue-on-error: false | |
| - name: Run black (code formatting check) | |
| run: | | |
| echo "Checking code formatting with black..." | |
| black --check --diff check_netscaler/ tests/ | |
| continue-on-error: false | |
| - name: Run mypy (type checking) | |
| run: | | |
| echo "Running mypy type checker..." | |
| mypy check_netscaler/ --ignore-missing-imports --no-strict-optional | |
| continue-on-error: true | |
| - name: Run tests | |
| run: | | |
| echo "Running pytest..." | |
| pytest tests/ -vv --tb=short | |
| continue-on-error: false | |
| - name: Test CLI | |
| run: | | |
| check_netscaler --help | |
| check_netscaler --version | |
| build: | |
| name: Build Package | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.9' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: python -m build | |
| - name: Check package | |
| run: twine check dist/* | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: dist | |
| path: dist/ | |
| build-binaries: | |
| name: Build Binaries (${{ matrix.os }}) | |
| needs: test | |
| runs-on: ${{ matrix.os }} | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| include: | |
| - os: ubuntu-latest | |
| artifact_name: check_netscaler-linux | |
| asset_name: check_netscaler-linux | |
| - os: windows-latest | |
| artifact_name: check_netscaler.exe | |
| asset_name: check_netscaler-windows.exe | |
| - os: macos-latest | |
| artifact_name: check_netscaler-macos | |
| asset_name: check_netscaler-macos | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.13' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| pip install pyinstaller | |
| - name: Build with PyInstaller | |
| run: | | |
| pyinstaller check_netscaler.spec | |
| - name: Smoke test (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| chmod +x dist/check_netscaler | |
| ./dist/check_netscaler --version | |
| ./dist/check_netscaler --help | |
| - name: Smoke test (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| dist\check_netscaler.exe --version | |
| dist\check_netscaler.exe --help | |
| - name: Rename binary (Linux) | |
| if: runner.os == 'Linux' | |
| run: mv dist/check_netscaler dist/${{ matrix.artifact_name }} | |
| - name: Rename binary (macOS) | |
| if: runner.os == 'macOS' | |
| run: mv dist/check_netscaler dist/${{ matrix.artifact_name }} | |
| - name: Generate SHA256 checksum (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cd dist | |
| sha256sum ${{ matrix.artifact_name }} > ${{ matrix.artifact_name }}.sha256sum | |
| - name: Generate SHA256 checksum (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| cd dist | |
| certutil -hashfile ${{ matrix.artifact_name }} SHA256 > ${{ matrix.artifact_name }}.sha256sum | |
| - name: Upload binary artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: | | |
| dist/${{ matrix.artifact_name }} | |
| dist/${{ matrix.artifact_name }}.sha256sum | |
| if-no-files-found: error | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: [test, build, build-binaries] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| outputs: | |
| released: ${{ steps.semantic.outputs.released }} | |
| version: ${{ steps.semantic.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.9' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| path: artifacts/ | |
| - name: Display artifact structure | |
| run: ls -R artifacts/ | |
| - name: Python Semantic Release | |
| id: semantic | |
| uses: python-semantic-release/python-semantic-release@v10.5.3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| root_options: "-vv" | |
| - name: Upload binaries to release | |
| if: steps.semantic.outputs.released == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION=${{ steps.semantic.outputs.version }} | |
| gh release upload v${VERSION} \ | |
| artifacts/check_netscaler-linux/check_netscaler-linux \ | |
| artifacts/check_netscaler-linux/check_netscaler-linux.sha256sum \ | |
| artifacts/check_netscaler.exe/check_netscaler.exe \ | |
| artifacts/check_netscaler.exe/check_netscaler.exe.sha256sum \ | |
| artifacts/check_netscaler-macos/check_netscaler-macos \ | |
| artifacts/check_netscaler-macos/check_netscaler-macos.sha256sum \ | |
| --clobber | |
| publish-testpypi: | |
| name: Publish to TestPyPI | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: needs.release.outputs.released == 'true' | |
| continue-on-error: true | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/project/check_netscaler/ | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: v${{ needs.release.outputs.version }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.9' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: python -m build | |
| - name: Publish to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| skip-existing: true | |
| publish-pypi: | |
| name: Publish to PyPI | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: needs.release.outputs.released == 'true' && always() | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/check_netscaler/ | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: v${{ needs.release.outputs.version }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.9' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: python -m build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |