Skip to content

Commit

Permalink
updating ci-cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnnnnnnnnnnnn committed Aug 24, 2024
1 parent bf83d9f commit 11ca6d8
Showing 1 changed file with 71 additions and 61 deletions.
132 changes: 71 additions & 61 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ jobs:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch flake8 pytest
pip install .
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run tests
run: pytest
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch flake8 pytest
pip install .
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run tests
run: pytest

publish-test:
needs: build
Expand All @@ -40,34 +40,35 @@ jobs:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Clean up dist folder
run: rm -rf dist/
- name: Extract version from pyproject.toml
id: extract_version
run: echo "VERSION=$(grep '^version =' pyproject.toml | sed -E 's/.*version = \"([^\"]+)\"/\\1/')" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Verify installation from TestPyPI
run: |
python -m venv test-env
. test-env/bin/activate
pip install --index-url https://test.pypi.org/simple/ etekcity_esf551_ble==$VERSION
python -c "from etekcity_esf551_ble import EtekcitySmartFitnessScale, WeightUnit; print(EtekcitySmartFitnessScale, WeightUnit)"
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Clean up dist folder
run: rm -rf dist/
- name: Extract version from pyproject.toml
id: extract_version
run: echo "VERSION=$(grep '^version =' pyproject.toml | sed -E 's/.*version = \"([^\"]+)\"/\\1/')" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Publish to TestPyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TESTPYPI_API_TOKEN }}
run: |
twine upload --repository testpypi dist/*
- name: Verify installation from TestPyPI
run: |
python -m venv test-env
. test-env/bin/activate
pip install --index-url https://test.pypi.org/simple/ etekcity_esf551_ble==$VERSION
python -c "from etekcity_esf551_ble import EtekcitySmartFitnessScale, WeightUnit; print(EtekcitySmartFitnessScale, WeightUnit)"
publish-prod:
needs: [build, publish-test]
runs-on: ubuntu-latest
Expand All @@ -76,20 +77,29 @@ jobs:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Clean up dist folder
run: rm -rf dist/
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Clean up dist folder
run: rm -rf dist/
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*
- name: Upload Release Assets
uses: actions/upload-release-asset@v3
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dist/*
asset_name: ${{ github.ref_name }}-package
asset_content_type: application/zip

0 comments on commit 11ca6d8

Please sign in to comment.