Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
package

GitHub Action

Setup Poetry

v3

Setup Poetry

package

Setup Poetry

Set up your GitHub Actions workflow with a specific version of Poetry

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Setup Poetry

uses: Gr1N/setup-poetry@v3

Learn more about this action in Gr1N/setup-poetry

Choose a version

setup-poetry

Build Status

This action sets up a Poetry for use in actions by installing a version of Poetry and adding to PATH. The action will fail if no matching versions are found.

This action supports versions of:

  • Python >=3.6;
  • Poetry >=1.0.

Usage

See action.yml.

Install latest available version of Poetry

steps:
  - uses: actions/checkout@v2
  - uses: actions/setup-python@v1
    with:
      python-version: 3.8
  - uses: Gr1N/setup-poetry@v3
  - run: poetry --version

Exact version of Poetry to install, using SemVer's version syntax

steps:
  - uses: actions/checkout@v2
  - uses: actions/setup-python@v1
    with:
      python-version: 3.8
  - uses: Gr1N/setup-poetry@v3
    with:
      poetry-version: 1.0.0
  - run: poetry --version

Allow to install prerelease versions of Poetry

steps:
  - uses: actions/checkout@v2
  - uses: actions/setup-python@v1
    with:
      python-version: 3.8
  - uses: Gr1N/setup-poetry@v3
    with:
      poetry-preview: true
  - run: poetry --version

Cache dependencies to speed up workflows

steps:
  - uses: actions/checkout@v2
  - uses: actions/setup-python@v1
    with:
      python-version: 3.8
  - uses: Gr1N/setup-poetry@v3
  - uses: actions/cache@v1
    with:
      path: ~/.cache/pypoetry/virtualenvs
      key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
      restore-keys: |
        ${{ runner.os }}-poetry-
  - run: poetry --version

Configure Poetry using environment variables

Poetry can be configured using environment variables and in case of CI/CD it can be a preferred way for you.

A full list of available settings can be found at official documentation.

steps:
  - uses: actions/checkout@v2
  - uses: actions/setup-python@v1
    with:
      python-version: 3.8
  - uses: Gr1N/setup-poetry@v3
  - run: poetry --version
    env:
      POETRY_VIRTUALENVS_PATH: /path/to/virtualenvs/directory
      POETRY_HTTP_BASIC_MY_REPOSITORY_PASSWORD: secret

Contributing

Feel free to submit any PR you want, they are always welcome.

License

setup-poetry is licensed under the MIT license. See the license file for details.