2
2
3
3
Set up your GitHub Actions workflow with a specific version of [ uv] ( https://docs.astral.sh/uv/ ) .
4
4
5
- - Install a version of uv and add it to the path
5
+ - Install a version of uv and add it to PATH
6
6
- Cache the installed version of uv to speed up consecutive runs on self-hosted runners
7
7
- Register problem matchers for error output
8
- - Optional: Cache the uv cache
9
- - Optional: Verify the checksum of the downloaded uv executable
8
+ - ( Optional) Persist the uv's cache in the GitHub Actions Cache
9
+ - ( Optional) Verify the checksum of the downloaded uv executable
10
10
11
11
## Contents
12
12
@@ -26,33 +26,26 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
26
26
Example workflow in a real world project can be found
27
27
[ here] ( https://github.com/eifinger/hass-weenect/blob/main/.github/workflows/ci.yml )
28
28
29
- ### Install specific version
30
-
31
- You can also specify a specific version of uv
29
+ ### Install the latest version (default)
32
30
33
31
``` yaml
34
- - name : Install a specific version
32
+ - name : Install the latest version of uv
35
33
uses : astral-sh/setup-uv@v1
36
34
with :
37
- version : " 0.4.4 "
35
+ version : " latest "
38
36
` ` `
39
37
40
- ### Install latest version
38
+ > [!TIP] Using ` latest` requires that uv download the executable on every run, which incurs a cost
39
+ > (especially on self-hosted runners). As an alternative, consider pinning the version to a specific
40
+ > release.
41
41
42
- By default this action installs the version defined as ` default` in `action.yml`. This gets
43
- automatically updated in a new release of this action when a new version of uv is released. If you
44
- don't want to wait for a new release of this action you can use `version : latest`.
45
-
46
- > [!WARNING]
47
- > Using the `latest` version means that the uv executable gets downloaded every single time instead
48
- > of loaded from the tools cache. This can take up to 20s depending on the download speed. This does
49
- > not affect the uv cache.
42
+ # ## Install a specific version
50
43
51
44
` ` ` yaml
52
- - name: Install a specific version
45
+ - name: Install a specific version of uv
53
46
uses: astral-sh/setup-uv@v1
54
47
with:
55
- version: "latest "
48
+ version: "0.4.4 "
56
49
` ` `
57
50
58
51
# ## Validate checksum
@@ -71,9 +64,9 @@ are automatically verified by this action. The sha265 hashes can be found on the
71
64
72
65
# ## Enable caching
73
66
74
- If you enable caching the [uv cache](https://docs.astral.sh/uv/concepts/cache/) will be cached to
75
- the GitHub Actions Cache. This can speed up runs which can reuse the cache by several minutes. The
76
- cache will always be reused on self-hosted runners.
67
+ If you enable caching, the [uv cache](https://docs.astral.sh/uv/concepts/cache/) will be cached to
68
+ the GitHub Actions Cache. This can speed up runs that reuse the cache by several minutes. The cache
69
+ will always be reused on self-hosted runners.
77
70
78
71
You can optionally define a custom cache key suffix.
79
72
@@ -86,8 +79,8 @@ You can optionally define a custom cache key suffix.
86
79
cache-suffix: "optional-suffix"
87
80
` ` `
88
81
89
- When the cache was successfully restored the output `cache-hit` will be set to `true` and you can
90
- use it in subsequent steps. For the example above you can use it like this :
82
+ When the cache was successfully restored, the output `cache-hit` will be set to `true` and you can
83
+ use it in subsequent steps. For example, to use the cache in the above case :
91
84
92
85
` ` ` yaml
93
86
- name: Do something if the cache was restored
@@ -97,8 +90,8 @@ use it in subsequent steps. For the example above you can use it like this:
97
90
98
91
# ### Local cache path
99
92
100
- If you want to save the cache to a local path other than the default path (`/tmp/setup-uv-cache`)
101
- you can specify the path with the `cache-local-path` input.
93
+ If you want to save the cache to a local path other than the default path (`/tmp/setup-uv-cache`),
94
+ specify the path with the `cache-local-path` input.
102
95
103
96
` ` ` yaml
104
97
- name: Define a custom uv cache path
@@ -110,7 +103,7 @@ you can specify the path with the `cache-local-path` input.
110
103
111
104
# ### Cache dependency glob
112
105
113
- If you want to control when the cache is invalidated you can specify a glob pattern with the
106
+ If you want to control when the cache is invalidated, specify a glob pattern with the
114
107
` cache-dependency-glob` input. The cache will be invalidated if any file matching the glob pattern
115
108
changes. The glob matches files relative to the repository root.
116
109
@@ -132,8 +125,8 @@ changes. The glob matches files relative to the repository root.
132
125
133
126
# ## API rate limit
134
127
135
- To avoid hitting the error `API rate limit exceeded` you can supply a GitHub token with the
136
- ` github-token ` input.
128
+ To avoid hitting the error `API rate limit exceeded`, supply a GitHub token with the `github-token`
129
+ input.
137
130
138
131
` ` ` yaml
139
132
- name: Install uv and supply a GitHub token
@@ -144,20 +137,21 @@ To avoid hitting the error `API rate limit exceeded` you can supply a GitHub tok
144
137
145
138
# # How it works
146
139
147
- This action downloads uv from the releases of the [uv repo](https://github.com/astral-sh/uv) and
148
- uses the [GitHub Actions Toolkit](https://github.com/actions/toolkit) to cache it as a tool to speed
149
- up consecutive runs on self-hosted runners.
140
+ This action downloads uv from the uv repo's official
141
+ [GitHub Releases](https://github.com/astral-sh/uv) and uses the
142
+ [GitHub Actions Toolkit](https://github.com/actions/toolkit) to cache it as a tool to speed up
143
+ consecutive runs on self-hosted runners.
150
144
151
- The installed version of uv is then added to the runner path so other steps can just use it by
152
- calling `uv`.
145
+ The installed version of uv is then added to the runner path, enabling subsequent steps to invoke it
146
+ by name ( `uv`) .
153
147
154
148
# # FAQ
155
149
156
150
# ## Do I still need actions/setup-python when using this action?
157
151
158
152
No! This action was modelled as a drop-in replacement for `actions/setup-python` when using uv.
159
153
160
- A simple example workflow could look like this :
154
+ For example :
161
155
162
156
` ` ` yaml
163
157
- name: Checkout the repository
@@ -170,7 +164,7 @@ A simple example workflow could look like this:
170
164
run: uv run --frozen pytest
171
165
` ` `
172
166
173
- If you want to have a specific python version installed you can use the command
167
+ To install a specific version of Python, use
174
168
[`uv python install`](https://docs.astral.sh/uv/guides/install-python/) :
175
169
176
170
` ` ` yaml
@@ -184,12 +178,10 @@ If you want to have a specific python version installed you can use the command
184
178
185
179
# ## What is the default version?
186
180
187
- By default, this action installs the version defined as `default` in `action.yml`. When a new
188
- release of uv is published this triggers an automatic release of this action with the new version as
189
- ` default` .
181
+ By default, this action installs the latest version of uv.
190
182
191
- If you have to know the version installed for other steps of your workflow you can use the
192
- `uv-version` output :
183
+ If you require the installed version in subsequent steps of your workflow, use the `uv-version`
184
+ output :
193
185
194
186
` ` ` yaml
195
187
- name: Checkout the repository
0 commit comments