Skip to content

Commit c1fbb92

Browse files
authored
feat: use .tool-versions file if available (#9)
1 parent 2968c86 commit c1fbb92

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ If the comment body is `/poe lint`, the action will run `poe lint`.
6060
- The action sets up Python 3.11 and installs dependencies using [uv](https://github.com/astral-sh/uv).
6161
- Your project should have a poe task named `install` which will run before any other requested command.
6262
- The `github-token` input is required for committing changes and posting comments.
63+
- Optional: If a `.tool-versions` file exists in the root of your repository, this action will automatically use it to determine the versions of `poetry`, `python`, and `uv`, provided matching entries are found. (See below.)
64+
65+
## Tool Versions
66+
67+
This action will attempt to use a `.tool-versions` file in your repo, if one esists. This behavior is powered by the [marocchino/tool-versions-action](https://github.com/marocchino/tool-versions-action). No additional configuration is required to enable this feature.
68+
69+
If a `.tool-versions` file does not exist, or doesn't have versions specified, we will try with the following defaults:
70+
71+
- `uv` - Default to latest version.
72+
- `poetry` - Default to latest version.
73+
- `python` - Default to version 3.11.
6374

6475
## Sample Workflows
6576

action.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,36 @@ runs:
116116
repository: ${{ steps.pr-info.outputs.repo }}
117117
token: ${{ inputs.github-token }}
118118

119+
- name: Fetch tool versions
120+
id: tool-versions
121+
continue-on-error: true
122+
uses: marocchino/tool-versions-action@v1
123+
119124
- name: Set up Python
120125
uses: actions/setup-python@v5
121126
with:
122-
python-version: '3.11'
127+
# Use the provided Python version or the default one
128+
python-version: ${{ steps.tool-versions.outputs.python || '3.11' }}
123129

124130
- name: Install uv
125131
uses: astral-sh/setup-uv@v5
126132
with:
127-
python-version: '3.11'
133+
# Set up the provided version or the latest if not specified
134+
version: ${{ steps.tool-versions.outputs.uv | 'latest' }}
135+
# Use the provided Python version or the default one
136+
python-version: ${{ steps.tool-versions.outputs.python || '3.11' }}
128137

129138
- name: Install Poetry
130139
uses: Gr1N/setup-poetry@v9
131140
with:
132-
poetry-version: "2.1.2"
141+
# Set up the provided version or the latest if not specified
142+
poetry-version: ${{ steps.tool-versions.outputs.poetry || '' }}
133143

134144
- name: Install poethepoet
135145
shell: bash
146+
# Currently, we just install the latest version of poethepoet.
147+
# This should be fine (for now) since Poe changes are generally
148+
# backward compatible.
136149
run: uv tool install poethepoet
137150

138151
- name: Install dependencies

0 commit comments

Comments
 (0)