diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 705dc37..4b19293 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,5 +4,5 @@ updates: directory: "/" schedule: interval: "daily" - target-branch: "main" + target-branch: "dev" open-pull-requests-limit: 10 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 19c5cef..6419c6e 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -31,6 +31,7 @@ jobs: - name: flake8 run: | flake8 --select F,E722 --ignore F403,F405,F541 + test: runs-on: ubuntu-latest steps: @@ -57,12 +58,11 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} files: ./cov.xml verbose: true - + publish: runs-on: ubuntu-latest needs: test if: github.event_name == 'push' && github.ref == 'refs/heads/main' - continue-on-error: true steps: - uses: actions/checkout@v3 with: @@ -76,20 +76,56 @@ jobs: python -m pip install --upgrade pip pip install poetry build poetry self add "poetry-dynamic-versioning[plugin]" - - name: Build Pypi package - if: github.ref == 'refs/heads/main' + + - name: Get current version from Poetry + id: get_version + run: | + VERSION=$(poetry version --short) + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Fetch latest tag + run: | + git fetch --tags + LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + + - name: Retrieve and strip "v" prefix if present + run: | + # Retrieve and strip "v" prefix if present + CURRENT_VERSION="${{ env.VERSION }}" + LATEST_VERSION="${{ env.LATEST_TAG }}" + CURRENT_VERSION="${CURRENT_VERSION#v}" + LATEST_VERSION="${LATEST_VERSION#v}" + + # Extract major.minor for comparison + CURRENT_MAJOR_MINOR=$(echo "$CURRENT_VERSION" | cut -d '.' -f 1-2) + LATEST_MAJOR_MINOR=$(echo "$LATEST_VERSION" | cut -d '.' -f 1-2) + + # Compare versions + if [ "$CURRENT_MAJOR_MINOR" == "$LATEST_MAJOR_MINOR" ]; then + echo "VERSION_CHANGE=false" >> $GITHUB_ENV + else + echo "VERSION_CHANGE=true" >> $GITHUB_ENV + fi + shell: bash + env: + VERSION: ${{ env.VERSION }} # dynamically passed VERSION variable + LATEST_TAG: ${{ env.LATEST_TAG }} # dynamically passed LATEST_TAG variable + + - name: Build PyPi package + if: github.ref == 'refs/heads/main' && env.VERSION_CHANGE == 'true' run: python -m build - - name: Publish Pypi package - if: github.ref == 'refs/heads/main' + + - name: Publish PyPi package + if: github.ref == 'refs/heads/main' && env.VERSION_CHANGE == 'true' uses: pypa/gh-action-pypi-publish@release/v1.5 with: password: ${{ secrets.PYPI_API_TOKEN }} - - name: Get current version from Poetry - id: get_version - run: echo "::set-output name=VERSION::$(poetry version --short)" - - name: Create Git tag + + - name: Tag the release if major or minor version changed + if: github.ref == 'refs/heads/main' && env.VERSION_CHANGE == 'true' run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git tag -a "$(echo ${{ steps.get_version.outputs.VERSION }})" -m "Release ${{ steps.get_version.outputs.VERSION }}" - git push origin "$(echo ${{ steps.get_version.outputs.VERSION }})" + git tag -a "${{ env.VERSION }}" -m "Release ${{ env.VERSION }}" + git push origin "refs/tags/${{ env.VERSION }}" diff --git a/poetry.lock b/poetry.lock index 0294f27..0d72a72 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1260,21 +1260,21 @@ dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments [[package]] name = "pytest-cov" -version = "4.1.0" +version = "6.0.0" description = "Pytest plugin for measuring coverage." optional = false -python-versions = ">=3.7" +python-versions = ">=3.9" files = [ - {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, - {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, + {file = "pytest-cov-6.0.0.tar.gz", hash = "sha256:fde0b595ca248bb8e2d76f020b465f3b107c9632e6a1d1705f17834c89dcadc0"}, + {file = "pytest_cov-6.0.0-py3-none-any.whl", hash = "sha256:eee6f1b9e61008bd34975a4d5bab25801eb31898b032dd55addc93e96fcaaa35"}, ] [package.dependencies] -coverage = {version = ">=5.2.1", extras = ["toml"]} +coverage = {version = ">=7.5", extras = ["toml"]} pytest = ">=4.6" [package.extras] -testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] +testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] [[package]] name = "pytest-mock" @@ -1712,4 +1712,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "25a2bc86e354f2731f4ddb30dac7255db97fa52a5ce2415dda717b62106f219e" +content-hash = "4ba30698f4b8d42f6768cd8b4f9438272947260ae9765e1af3300dcf3ffd13f9" diff --git a/pyproject.toml b/pyproject.toml index 8c113d3..29a7644 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" [tool.poetry.dev-dependencies] requests-mock = "^1.10.0" pytest = "^8.3.3" -pytest-cov = "^4.0.0" +pytest-cov = "^6.0.0" mock = "^4.0.3" pytest-mock = "^3.10.0" poetry-dynamic-versioning = {extras = ["plugin"], version = "^0.21.1"}