Test and Publish #26
This file contains hidden or 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: Test and Publish | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: # Allows you to run this manually for testing | |
| jobs: | |
| # PHASE 1: Run Tests | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.9"] # later i'll add "3.8", "3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install .[test] # Installs your package + optional test deps | |
| pip install pytest | |
| - name: Run Pytest with Coverage | |
| run: pytest --cov=clb | |
| # PHASE 2: Build and Upload (Only runs if 'test' passes) | |
| deploy: | |
| needs: test # This is the magic line that stops the publish if tests fail | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install build tools | |
| run: pip install build twine | |
| - name: Build Wheel and Source Dist | |
| run: python -m build | |
| - name: Publish to GitHub Packages | |
| env: | |
| TWINE_USERNAME: ${{ github.actor }} | |
| TWINE_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
| #TWINE_REPOSITORY_URL: https://pypi.pkg.github.com/${{ github.repository_owner }}/ | |
| #TWINE_REPOSITORY_URL: https://pypi.pkg.github.com/jPleyte/command-line-bio | |
| TWINE_REPOSITORY_URL: https://pypi.pkg.github.com/jPleyte/command-line-bio/legacy/ | |
| run: | | |
| echo "Showing variables" | |
| echo "USER=${TWINE_USERNAME}" | |
| echo "PWD=${TWINE_PASSWORD}" | |
| echo "TWINE_REPOSITORY_URL=$TWINE_REPOSITORY_URL" | |
| twine upload --verbose --repository-url $TWINE_REPOSITORY_URL dist/* |