Update Github action v3 #56
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests & Publishes to PyPI | ||
on: | ||
release: | ||
types: [published] | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- "*" | ||
env: | ||
PROJECT_NAME: intelelm | ||
DIST_PATH: dist | ||
CACHE_KEY: requirements-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} | ||
Check failure on line 16 in .github/workflows/publish-package.yaml GitHub Actions / Tests & Publishes to PyPIInvalid workflow file
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 9 | ||
submodules: false | ||
- name: Set Up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Cache Dependencies | ||
uses: actions/cache@v1 | ||
id: cache-dependencies | ||
with: | ||
path: deps | ||
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 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 Tools | ||
if: matrix.python-version == 3.11 | ||
run: pip install --upgrade twine setuptools wheel | ||
- name: Build Distribution Package | ||
if: matrix.python-version == 3.11 | ||
run: python setup.py sdist bdist_wheel | ||
- name: Upload Distribution Package | ||
if: matrix.python-version == 3.11 | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist-package-${{ matrix.python-version }} | ||
path: ${{ env.DIST_PATH }} | ||
publish: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: github.event_name == 'release' | ||
steps: | ||
- name: Download Distribution Artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist-package-3.11 | ||
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 To PyPI | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.pypi_password }} |