Skip to content

Commit b75ff7d

Browse files
authored
Add input version-file (#486)
Closes: #411
1 parent c893ac1 commit b75ff7d

File tree

13 files changed

+369
-136
lines changed

13 files changed

+369
-136
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,22 @@ jobs:
155155
exit 1
156156
fi
157157
158+
test-version-file-version:
159+
runs-on: ubuntu-latest
160+
steps:
161+
- uses: actions/checkout@v4
162+
- name: Install from requirements file
163+
id: setup-uv
164+
uses: ./
165+
with:
166+
version-file: "__tests__/fixtures/uv-in-requirements-txt-project/requirements.txt"
167+
- name: Correct version gets installed
168+
run: |
169+
if [ "$(uv --version)" != "uv 0.6.17" ]; then
170+
echo "Wrong uv version: $(uv --version)"
171+
exit 1
172+
fi
173+
158174
test-checksum:
159175
runs-on: ${{ matrix.inputs.os }}
160176
strategy:
@@ -561,6 +577,7 @@ jobs:
561577
- test-pyproject-file-version
562578
- test-malformed-pyproject-file-fallback
563579
- test-uv-file-version
580+
- test-version-file-version
564581
- test-checksum
565582
- test-with-explicit-token
566583
- test-uvx

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
1515
- [Install the latest version](#install-the-latest-version)
1616
- [Install a specific version](#install-a-specific-version)
1717
- [Install a version by supplying a semver range or pep440 specifier](#install-a-version-by-supplying-a-semver-range-or-pep440-specifier)
18+
- [Install a version defined in a requirements or config file](#install-a-version-defined-in-a-requirements-or-config-file)
1819
- [Python version](#python-version)
1920
- [Activate environment](#activate-environment)
2021
- [Working directory](#working-directory)
@@ -92,6 +93,19 @@ to install the latest version that satisfies the range.
9293
version: ">=0.4.25,<0.5"
9394
```
9495

96+
### Install a version defined in a requirements or config file
97+
98+
You can use the `version-file` input to specify a file that contains the version of uv to install.
99+
This can either be a `pyproject.toml` or `uv.toml` file which defines a `required-version` or
100+
uv defined as a dependency in `pyproject.toml` or `requirements.txt`.
101+
102+
```yaml
103+
- name: Install uv based on the version defined in pyproject.toml
104+
uses: astral-sh/setup-uv@v6
105+
with:
106+
version-file: "pyproject.toml"
107+
```
108+
95109
### Python version
96110

97111
You can use the input `python-version` to set the environment variable `UV_PYTHON` for the rest of your workflow
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello world")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uv==0.6.17

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ inputs:
66
version:
77
description: "The version of uv to install e.g., `0.5.0` Defaults to the version in pyproject.toml or 'latest'."
88
default: ""
9+
version-file:
10+
description: "Path to a file containing the version of uv to install. Defaults to searching for uv.toml and if not found pyproject.toml."
11+
default: ""
912
python-version:
1013
description: "The version of Python to set UV_PYTHON to"
1114
required: false

dist/save-cache/index.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)