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 25, 2024
1 parent d35a3c8 commit 47f5baf
Showing 1 changed file with 7 additions and 42 deletions.
49 changes: 7 additions & 42 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,49 +32,8 @@ jobs:
- name: Run tests
run: pytest

publish-test:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
permissions:
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: |
python -m pip install --upgrade pip
pip install toml
VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
echo "VERSION=$VERSION" >> $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]
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
permissions:
Expand All @@ -100,6 +59,12 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*
- name: Verify installation from PyPI
run: |
python -m venv test-env
. test-env/bin/activate
pip install etekcity_esf551_ble==$VERSION
python -c "from etekcity_esf551_ble import EtekcitySmartFitnessScale, WeightUnit; print(EtekcitySmartFitnessScale, WeightUnit)"
- name: Upload Release Assets
uses: actions/upload-release-asset@v3
with:
Expand Down

0 comments on commit 47f5baf

Please sign in to comment.