Skip to content

Actually use the GITHUB_TOKEN (oops) #18

Actually use the GITHUB_TOKEN (oops)

Actually use the GITHUB_TOKEN (oops) #18

Workflow file for this run

name: build
on: [push, pull_request]
env:
# color output for Pytest
PYTEST_ADDOPTS: "--color=yes"
PY_COLORS: 1
permissions:
contents: read
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Set Poetry cache
uses: actions/cache@v3
id: poetry-cache
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
- name: Upgrade Pip
run: python -m pip install --upgrade pip
- name: Install Poetry
run: python -m pip install poetry
- name: Install dependencies
run: |
poetry run pip install --upgrade pip
poetry install
- name: Run tests
run: poetry run pytest
deploy:
name: Deploy
environment: Deployment
needs: [test]
runs-on: ubuntu-latest
if: ${{ github.ref=='refs/heads/main' && github.event_name!='pull_request' }}
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Check release
id: check_release
run: |
python -m pip install poetry
python -m pip install --pre --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ autopub[github]
echo "##[set-output name=release;]$(autopub check)"
- name: Publish
if: ${{ steps.check_release.outputs.release=='' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
autopub prepare
autopub commit
poetry build
autopub githubrelease
poetry publish -u __token__ -p $PYPI_PASSWORD