Skip to content

Commit

Permalink
Merge pull request #48 from JRubics/poetry_install_options
Browse files Browse the repository at this point in the history
Add options
  • Loading branch information
JRubics committed Feb 4, 2024
2 parents dffe3ac + 819b60e commit 7100bd0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 24 deletions.
49 changes: 37 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,22 @@ The Password to log in into a repository where the package will be uploaded if u
By default, poetry's build command outputs two formats: **wheel** and **sdist**. If you intend to use
only one of them, you may specify that with the `build_format` parameter.

### `ignore_dev_requirements`
### `poetry_install_options`

This will instruct poetry **not** to install any developer requirements. this may lead to an overall quicker experience.
Adds possibility to pass options to "poetry install" command. Examples:
- `--without dev`
- `--only-root`
- `--sync`

Check the full list [here](https://python-poetry.org/docs/cli/#options-2).

### `poetry_publish_options`

Adds possibility to pass options to "poetry publish" command. Examples:
- `--dry-run`
- `--build`

Check the full list [here](https://python-poetry.org/docs/cli/#options-8).

### `allow_poetry_pre_release`

Expand All @@ -61,36 +74,48 @@ An optional space-separated list of poetry plugins to be installed before buildi
An optional subdirectory path if poetry package doesn't reside in the main workflow directory


**Note:** `ignore_dev_requirements` command is deprecated in version 2.0. Use `poetry_install_options: --without dev` instead

## Example usage

The following will build and publish the python package to the PyPI using the last version of python and poetry. Specify the python package version and dependencies in `pyproject.toml` in the root directory of your project.

```yaml
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.17
uses: JRubics/poetry-publish@v2.0
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
```
Python and poetry versions can be specified in inputs as well as the build_format, allow_poetry_pre_release and ignore_dev_requirements.
Python and poetry versions can be specified in inputs as well as the build_format and allow_poetry_pre_release.
```yaml
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.17
uses: JRubics/poetry-publish@v2.0
with:
python_version: "3.7.1"
poetry_version: "==1.0.5" # (PIP version specifier syntax)
pypi_token: ${{ secrets.PYPI_TOKEN }}
build_format: "sdist"
allow_poetry_pre_release: "yes"
ignore_dev_requirements: "yes"
```
Poetry options for install and publish commands can be specified through poetry_install_options and poetry_publish_options.
```yaml
- name: Build and publish to pypi
uses: JRubics/[email protected]
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
poetry_install_options: "--sync --no-root"
poetry_publish_options: "--dry-run"
```
Repository can be changed to TestPyPI or a private wheels repo by specifying repository_name and repository_url.
```yaml
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.17
uses: JRubics/poetry-publish@v2.0
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
repository_name: "testpypi"
Expand All @@ -101,7 +126,7 @@ Repository authentication can be changed to http-basic authentification by speci
```yaml
- name: Build and publish to private Python package repository
uses: JRubics/poetry-publish@v1.17
uses: JRubics/poetry-publish@v2.0
with:
repository_name: "foo"
repository_url: "https://foo.bar/simple/"
Expand All @@ -113,7 +138,7 @@ Extra debian packages can be installed before building the python package. This
```yaml
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.17
uses: JRubics/poetry-publish@v2.0
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
extra_build_dependency_packages: "capnproto libzmq3-dev"
Expand All @@ -123,7 +148,7 @@ Poetry plugins can be added by specifying plugins input
```yaml
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.17
uses: JRubics/poetry-publish@v2.0
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
plugins: "poetry-dynamic-versioning[plugin]"
Expand All @@ -133,7 +158,7 @@ Poetry package can be built from a subdirectory. It should be specified as packa
```yaml
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.17
uses: JRubics/poetry-publish@v2.0
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
package_directory: "subdirectory"
Expand All @@ -155,7 +180,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.17
uses: JRubics/poetry-publish@v2.0
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
```
12 changes: 8 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ inputs:
build_format:
description: 'The build format to be used, either "sdist" or "wheel"'
required: false
ignore_dev_requirements:
description: "Install project without developer requirements."
poetry_install_options:
description: 'Adds possibility to pass options to "poetry install" command'
required: false
allow_poetry_pre_release:
description: "Allow usage of poetry pre-release and development versions"
Expand All @@ -47,20 +47,24 @@ inputs:
description: "An optional subdirectory path if poetry package doesn't reside in the main workflow directory"
required: false
default: "."
poetry_publish_options:
description: 'Adds possibility to pass options to "poetry publish" command'
required: false
runs:
using: "docker"
image: "docker://jrubics/poetry-publish:v1.17"
image: "docker://jrubics/poetry-publish:v2.0"
args:
- ${{ inputs.python_version }}
- ${{ inputs.poetry_version }}
- ${{ inputs.pypi_token }}
- ${{ inputs.repository_name}}
- ${{ inputs.repository_url }}
- ${{ inputs.build_format }}
- ${{ inputs.ignore_dev_requirements }}
- ${{ inputs.poetry_install_options }}
- ${{ inputs.allow_poetry_pre_release }}
- ${{ inputs.repository_username }}
- ${{ inputs.repository_password }}
- ${{ inputs.extra_build_dependency_packages }}
- ${{ inputs.plugins }}
- ${{ inputs.package_directory }}
- ${{ inputs.poetry_publish_options }}
12 changes: 4 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ if [ -n "${12}" ]; then
poetry self add ${12}
fi

if [ -z $7 ]; then
poetry install
else
poetry install --no-dev
fi
poetry install ${7}

if [ -z $6 ]; then
poetry build
Expand All @@ -46,14 +42,14 @@ fi

if [ -z $4 ] || [ -z $5 ]; then
poetry config pypi-token.pypi $3
poetry publish
poetry publish ${14}
else
if [ -z $9 ] || [ -z ${10} ]; then
poetry config pypi-token.$4 $3
poetry config repositories.$4 $5
poetry publish --repository $4
poetry publish --repository $4 ${14}
else
poetry config repositories.$4 $5
poetry publish --repository $4 --username $9 --password ${10}
poetry publish --repository $4 --username $9 --password ${10} ${14}
fi
fi

0 comments on commit 7100bd0

Please sign in to comment.