From aad58ebbc0b0ceb55106a1805c6b50209b5c8796 Mon Sep 17 00:00:00 2001 From: Walter Mwaniki Date: Tue, 15 Oct 2024 12:29:16 -0700 Subject: [PATCH] Update tag_and_publish.yml --- .github/workflows/tag_and_publish.yml | 128 +++++++++++++------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/.github/workflows/tag_and_publish.yml b/.github/workflows/tag_and_publish.yml index 4cdc0e3..d726e01 100644 --- a/.github/workflows/tag_and_publish.yml +++ b/.github/workflows/tag_and_publish.yml @@ -1,65 +1,65 @@ -# name: Tag and publish -# on: -# push: -# branches: -# - main -## Remove line 61 to enable automated semantic version bumps. -## Change line 67 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@v3 -# with: -# ref: ${{ env.DEFAULT_BRANCH }} -# fetch-depth: 0 -# token: ${{ secrets.SERVICE_TOKEN }} -# - name: Set up Python 3.8 -# uses: actions/setup-python@v3 -# with: -# python-version: 3.8 -# - name: Install dependencies -# run: | -# python -m pip install -e .[dev] --no-cache-dir -# - name: Get Python version and Update README.md -# run: | -# python_version=$(grep "requires-python" pyproject.toml | grep -o ">=[^\"]*") -# python_badge=$(grep -o 'python-[^)]*' README.md) -# new_python_badge="python-$python_version-blue?logo=python" -# sed -i "s/$python_badge/$new_python_badge/g" README.md -# - name: Get interrogate values and Update README.md -# run: | -# interrogate_val=$(interrogate . | grep -o 'actual: [0-9]*\.[0-9]*' | awk '{print $2}') -# interrogate_badge=$(grep -o 'interrogate-[^)]*' README.md) -# 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: | -# coverage run -m unittest discover -# coverage_val=$(coverage report | grep "^TOTAL" | grep -o '[0-9]\+%' | grep -o '[0-9]\+') -# coverage_badge=$(grep -o "coverage-[^?]*" README.md) -# 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"]' +name: Tag and publish +on: + push: + branches: + - main +# Remove line 61 to enable automated semantic version bumps. +# Change line 67 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@v3 + with: + ref: ${{ env.DEFAULT_BRANCH }} + fetch-depth: 0 + token: ${{ secrets.SERVICE_TOKEN }} + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: 3.11 + - name: Install dependencies + run: | + python -m pip install -e .[dev] --no-cache-dir + - name: Get Python version and Update README.md + run: | + python_version=$(grep "requires-python" pyproject.toml | grep -o ">=[^\"]*") + python_badge=$(grep -o 'python-[^)]*' README.md) + new_python_badge="python-$python_version-blue?logo=python" + sed -i "s/$python_badge/$new_python_badge/g" README.md + - name: Get interrogate values and Update README.md + run: | + interrogate_val=$(interrogate . | grep -o 'actual: [0-9]*\.[0-9]*' | awk '{print $2}') + interrogate_badge=$(grep -o 'interrogate-[^)]*' README.md) + 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: | + coverage run -m unittest discover + coverage_val=$(coverage report | grep "^TOTAL" | grep -o '[0-9]\+%' | grep -o '[0-9]\+') + coverage_badge=$(grep -o "coverage-[^?]*" README.md) + 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'}} @@ -74,10 +74,10 @@ # - uses: actions/checkout@v3 # - name: Pull latest changes # run: git pull origin main -# - name: Set up Python 3.8 +# - name: Set up Python 3.11 # uses: actions/setup-python@v2 # with: -# python-version: 3.8 +# python-version: 3.11 # - name: Install dependencies # run: | # pip install --upgrade setuptools wheel twine build