Skip to content

Merge remote-tracking branch 'origin/main' #208

Merge remote-tracking branch 'origin/main'

Merge remote-tracking branch 'origin/main' #208

name: Kodexa CLI Python Package
on:
push:
paths:
- '**'
- '!docs/**'
- '!.github/**'
jobs:
build:
name: Package & Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Run image
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.3.2"
- name: Increment version
run: |
BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///')
VERSION=$(poetry version --short)
MINOR_PATCH_PART=$(echo $VERSION | awk -F '.' '{print $1"."$2}')
PATCH_PART=$(echo $VERSION | awk -F '.' '{print substr($NF,1,1)}')
if [[ $BRANCH_NAME == "fix"* || $BRANCH_NAME == "bugs"* ]]; then
NEW_LATEST_PATCH_PART=$((PATCH_PART+1))b${GITHUB_RUN_ID}
elif [[ $BRANCH_NAME == "feature"* ]]; then
NEW_LATEST_PATCH_PART=$((PATCH_PART+1))a${GITHUB_RUN_ID}
elif [[ $BRANCH_NAME == "test"* ]]; then
NEW_LATEST_PATCH_PART=$((PATCH_PART+1))rc${GITHUB_RUN_ID}
elif [[ $BRANCH_NAME == "main"* ]]; then
poetry version patch
VERSION=$(poetry version --short)
MINOR_PATCH_PART=${VERSION#*.}
LAST_VERSION_PART_PREFIX=${MINOR_PATCH_PART%??}
PATCH_PART=${LAST_VERSION_PART_PREFIX%.*}
NEW_LATEST_PATCH_PART=${PATCH_PART}${GITHUB_RUN_ID}
else
echo "Invalid branch name"
exit 1
fi
NEW_VERSION=${VERSION%.*}.${NEW_LATEST_PATCH_PART}
echo $NEW_VERSION
echo "::set-output name=version::$NEW_VERSION"
echo "::set-output name=versionType::Release"
poetry version $NEW_VERSION --no-ansi
- name: Install dependencies
run: poetry install
- name: Lint with flake8
run: |
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
yes | poetry run mypy --install-types kodexa_cli || true
- name: Test with pytest
run: |
poetry run pytest
- name: Build Package
run: |
poetry build
- name: Publish a Python distribution to PyPI
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish