diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 60080c5..1c51945 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,7 +9,6 @@ on: types: [published] jobs: - build: runs-on: ubuntu-latest strategy: @@ -18,24 +17,28 @@ jobs: steps: - uses: actions/checkout@v3 + + - name: Cache pip + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 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: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest + + - name: Run tox + run: tox publish-test: needs: build @@ -47,22 +50,26 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.12' + - 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@release/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 + pip install --index-url https://test.pypi.org/simple/ etekcity_esf551_ble python -c "from etekcity_esf551_ble import EtekcitySmartFitnessScale, WeightUnit; print(EtekcitySmartFitnessScale, WeightUnit)" publish-prod: @@ -75,12 +82,15 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.12' + - 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@release/v1 with: