diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index f92d92e..01ff3a9 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -12,6 +12,8 @@ on: env: PROJECT_NAME: intelelm + DIST_PATH: dist + CACHE_KEY: requirements-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} jobs: build: @@ -19,82 +21,70 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] - + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v1 + - name: Checkout Code + uses: actions/checkout@v1 with: fetch-depth: 9 submodules: false - - - name: Use Python ${{ matrix.python-version }} + - name: Set Up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 with: python-version: ${{ matrix.python-version }} - - - uses: actions/cache@v1 - id: depcache + - name: Cache Dependencies + uses: actions/cache@v1 + id: cache-dependencies with: path: deps - key: requirements-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} - - - name: Download dependencies - if: steps.depcache.outputs.cache-hit != 'true' - run: | - pip download --dest=deps -r requirements.txt - - - name: Install dependencies - run: | - pip install -U --no-index --find-links=deps deps/* - - - name: Run tests + key: ${{ env.CACHE_KEY }} + - name: Download Dependencies + if: steps.cache-dependencies.outputs.cache-hit != 'true' + run: pip download --dest=deps -r requirements.txt + - name: Install Dependencies + run: pip install -U --no-index --find-links=deps deps/* + - name: Run Tests and Lint run: | pytest --doctest-modules --junitxml=junit/pytest-results-${{ matrix.python-version }}.xml --cov=$PROJECT_NAME --cov-report=xml tests/ flake8 tests/ - - - name: Upload pytest test results - uses: actions/upload-artifact@master + - name: Upload Pytest Results + uses: actions/upload-artifact@v3 with: name: pytest-results-${{ matrix.python-version }} path: junit/pytest-results-${{ matrix.python-version }}.xml if: always() - - - name: Install distribution dependencies + - name: Install Distribution Tools + if: matrix.python-version == 3.11 run: pip install --upgrade twine setuptools wheel + - name: Build Distribution Package if: matrix.python-version == 3.11 - - - name: Create distribution package run: python setup.py sdist bdist_wheel + - name: Upload Distribution Package if: matrix.python-version == 3.11 - - - name: Upload distribution package - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: dist-package-${{ matrix.python-version }} - path: dist - if: matrix.python-version == 3.11 + path: ${{ env.DIST_PATH }} publish: runs-on: ubuntu-latest needs: build if: github.event_name == 'release' steps: - - name: Download a distribution artifact - uses: actions/download-artifact@v2 + - name: Download Distribution Artifact + uses: actions/download-artifact@v3 with: name: dist-package-3.11 - path: dist - - - name: Publish distribution 📦 to Test PyPI + path: ${{ env.DIST_PATH }} + - name: Publish To Test PyPI uses: pypa/gh-action-pypi-publish@master with: skip_existing: true user: __token__ password: ${{ secrets.test_pypi_password }} repository_url: https://test.pypi.org/legacy/ - - - name: Publish distribution 📦 to PyPI + - name: Publish To PyPI uses: pypa/gh-action-pypi-publish@master with: user: __token__ - password: ${{ secrets.pypi_password }} + password: ${{ secrets.pypi_password }} \ No newline at end of file