Update CI workflow to exclude Python 3.10 #67
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: Tag and publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| # Remove line 65 to enable automated semantic version bumps. | |
| # Change line 71 from "if: false" to "if: true" to enable PyPI publishing. | |
| # Requires that svc-aindscicomp be added as an admin to repo. | |
| jobs: | |
| update_badges: | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ env.DEFAULT_BRANCH }} | |
| fetch-depth: 0 | |
| #token: ${{ secrets.SERVICE_TOKEN }} | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install -e . --group dev --no-cache-dir | |
| - name: Get interrogate values and Update README.md | |
| run: | | |
| set -euo pipefail | |
| if ! interrogate_out="$(interrogate . 2>/dev/null)"; then | |
| echo "interrogate failed under this Python version; skipping interrogate badge update." | |
| exit 0 | |
| fi | |
| interrogate_val="$(printf "%s" "$interrogate_out" | grep -o 'actual: [0-9]*\.[0-9]*' | awk '{print $2}' || true)" | |
| if [[ -z "${interrogate_val:-}" ]]; then | |
| echo "Could not parse interrogate output; skipping interrogate badge update." | |
| exit 0 | |
| fi | |
| interrogate_badge=$(grep '^\!\[Interrogate\]' README.md | sed -n 's/.*\(interrogate-[^)]*\).*/\1/p' || true) | |
| if [[ -z "${interrogate_badge:-}" ]]; then | |
| echo "Interrogate badge not found in README.md; skipping." | |
| exit 0 | |
| fi | |
| if (( $(echo "$interrogate_val >= 90.00" | bc -l) )); then | |
| new_interrogate_badge="interrogate-$interrogate_val%25-brightgreen" | |
| elif (( $(echo "$interrogate_val < 80.00" | bc -l) )); then | |
| new_interrogate_badge="interrogate-$interrogate_val%25-red" | |
| else | |
| new_interrogate_badge="interrogate-$interrogate_val%25-yellow" | |
| fi | |
| sed -i "s/$interrogate_badge/$new_interrogate_badge/g" README.md | |
| - name: Get Coverage values and Update README.md | |
| run: | | |
| set -euo pipefail | |
| coverage run -m unittest discover | |
| coverage_val=$(coverage report | grep "^TOTAL" | grep -o '[0-9]\+%' | grep -o '[0-9]\+') | |
| coverage_badge=$(grep '^\!\[Coverage\]' README.md | sed -n 's/.*\(coverage-[^)]*\).*/\1/p' || true) | |
| if [[ -z "${coverage_badge:-}" ]]; then | |
| echo "Coverage badge not found in README.md; skipping." | |
| exit 0 | |
| fi | |
| if (( $(echo "$coverage_val >= 90.00" | bc -l) )); then | |
| new_coverage_badge="coverage-$coverage_val%25-brightgreen" | |
| elif (( $(echo "$coverage_val < 80.00" | bc -l) )); then | |
| new_coverage_badge="coverage-$coverage_val%25-red" | |
| else | |
| new_coverage_badge="coverage-$coverage_val%25-yellow" | |
| fi | |
| sed -i "s/$coverage_badge/$new_coverage_badge/g" README.md | |
| - name: Commit changes | |
| uses: EndBug/add-and-commit@v9 | |
| with: | |
| default_author: github_actions | |
| message: "ci: update badges [skip actions]" | |
| add: '["README.md"]' | |
| tag: | |
| needs: update_badges | |
| if: ${{github.event.repository.name == 'aind-library-template'}} | |
| uses: AllenNeuralDynamics/aind-github-actions/.github/workflows/tag.yml@main | |
| secrets: | |
| SERVICE_TOKEN: ${{ secrets.SERVICE_TOKEN }} | |
| publish: | |
| needs: tag | |
| if: false | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Pull latest changes | |
| run: git pull origin main | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade setuptools wheel twine build | |
| python -m build | |
| twine check dist/* | |
| - name: Publish on PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.AIND_PYPI_TOKEN }} |