From 44e9eccf2101afda13179be5c44fb1dad086f46d Mon Sep 17 00:00:00 2001 From: "Justin B. Kinney" Date: Wed, 29 Jan 2025 14:33:53 -0500 Subject: [PATCH] Created workflow.yml to include both tests and publishing to pypi or testpypi. --- .github/workflows/tests.yml | 33 -------------- .github/workflows/workflow.yml | 78 ++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 51c7067..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Run Tests - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - - steps: - - uses: actions/checkout@v4 - - - 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 . - pip install pytest - - - name: Configure matplotlib backend - run: | - mkdir -p $HOME/.config/matplotlib - echo "backend: Agg" > $HOME/.config/matplotlib/matplotlibrc - - - name: Run tests - run: | - python -c "import logomaker; logomaker.run_tests()" diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..fc84921 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,78 @@ +name: Build, Test and Publish + +on: + push: # Run on all pushes + pull_request: # Run on all PRs + +jobs: + test: + name: Run Python Tests + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] + + steps: + - uses: actions/checkout@v4 + + - 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 . + pip install pytest + + - name: Configure matplotlib backend + run: | + mkdir -p $HOME/.config/matplotlib + echo "backend: Agg" > $HOME/.config/matplotlib/matplotlibrc + + - name: Run tests + run: | + python -c "import logomaker; logomaker.run_tests()" + + publish: + name: Build and Publish + needs: [test] + runs-on: ubuntu-latest + # Run publish job it's a tag push starting with v or test + # Use v* tags (e.g., v1.0.0) for PyPI releases (must be on master branch) + # Use test* tags (e.g., test1.0.0) for TestPyPI releases + if: (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/test')) + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - 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 + if: github.ref == 'refs/heads/master' && startsWith(github.ref, 'refs/tags/v') + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: twine upload dist/* + + - name: Publish to TestPyPI + if: startsWith(github.ref, 'refs/tags/test') + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} + TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ + run: twine upload dist/* + + \ No newline at end of file