Skip to content

Commit

Permalink
Merge pull request #145 from blacklanternsecurity/dev
Browse files Browse the repository at this point in the history
Dev -> Main (dependabot)
  • Loading branch information
liquidsec authored Nov 8, 2024
2 parents dce3c4f + b92163f commit 861a80c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ updates:
directory: "/"
schedule:
interval: "daily"
target-branch: "main"
target-branch: "dev"
open-pull-requests-limit: 10
60 changes: 48 additions & 12 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- name: flake8
run: |
flake8 --select F,E722 --ignore F403,F405,F541
test:
runs-on: ubuntu-latest
steps:
Expand All @@ -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:
Expand All @@ -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 }}"
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down

0 comments on commit 861a80c

Please sign in to comment.