Skip to content

Commit

Permalink
Update Github action v3
Browse files Browse the repository at this point in the history
  • Loading branch information
thieu1995 committed Oct 9, 2024
1 parent 2e25b96 commit 57fe78a
Showing 1 changed file with 30 additions and 40 deletions.
70 changes: 30 additions & 40 deletions .github/workflows/publish-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,89 +12,79 @@ on:

env:
PROJECT_NAME: intelelm
DIST_PATH: dist
CACHE_KEY: requirements-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}

jobs:
build:
runs-on: ubuntu-latest
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 }}

0 comments on commit 57fe78a

Please sign in to comment.