From ec8e23c6705c894391a849d856b6648dd66d732b Mon Sep 17 00:00:00 2001 From: Rick Lupton Date: Mon, 13 Mar 2023 14:38:07 +0000 Subject: [PATCH] Add github action to publish package on new release --- .github/workflows/publish.yml | 46 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 11 ++++++--- 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..1ccac07 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,46 @@ +# This workflow will publish new releases after running tests + +name: Publish Python package + +on: + release: + types: [created] + +jobs: + tests: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ["3.10", "3.11"] + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v3 + - name: Install poetry + run: pipx install poetry + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'poetry' + - run: poetry install + - run: poetry run pytest tests + + publish: + runs-on: ubuntu-latest + needs: [tests] + steps: + - uses: actions/checkout@v3 + - name: Install poetry + run: pipx install poetry + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'poetry' + - run: poetry install + - run: poetry build + - name: Publish + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} + run: poetry publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0259043..d0e34d8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,14 +10,19 @@ on: jobs: tests: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ["3.10", "3.11"] + os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v3 - name: Install poetry run: pipx install poetry - - uses: actions/setup-python@v4 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: ${{ matrix.python-version }} cache: 'poetry' - run: poetry install - run: poetry run pytest tests