mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-12-15 11:07:14 +00:00
Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
caf0cab7a6 | ||
|
|
7c238111e6 | ||
|
|
3eca4c2715 | ||
|
|
aee2e918ee | ||
|
|
4ffb6d766c | ||
|
|
e779db7426 | ||
|
|
cb1ce8a914 | ||
|
|
cf7bbf8f13 | ||
|
|
2e657c127d | ||
|
|
a7e15805d2 | ||
|
|
2a578ce17f | ||
|
|
6f467a02b3 | ||
|
|
d2242d1901 | ||
|
|
5552ab3709 | ||
|
|
3e4fe09ab3 | ||
|
|
56f89d8124 | ||
|
|
3b9817b1bf | ||
|
|
cf841c25e2 | ||
|
|
864c48a352 | ||
|
|
64311bdf43 | ||
|
|
59604e6118 | ||
|
|
260f4a22de | ||
|
|
273d3782a2 | ||
|
|
ed0a39790e | ||
|
|
2d11fcb2c1 | ||
|
|
a714a3589c | ||
|
|
59ca521371 | ||
|
|
f3bcaebff5 | ||
|
|
10d8740fc2 | ||
|
|
f731690a1d | ||
|
|
77c28f02b3 | ||
|
|
00c695b84c | ||
|
|
2422c84f47 | ||
|
|
680950fd0f | ||
|
|
c9aa747934 | ||
|
|
97dc6041e9 | ||
|
|
c11f8674f8 | ||
|
|
023eb7875f | ||
|
|
315da29189 | ||
|
|
4cda7d7332 | ||
|
|
8114e5e81b | ||
|
|
7ee921e18a | ||
|
|
8c3a35e468 | ||
|
|
abac0ce7b0 | ||
|
|
03e245b158 | ||
|
|
aeb46491c7 | ||
|
|
dbb680fbd2 | ||
|
|
8de9ba90a2 | ||
|
|
118bd876d2 | ||
|
|
adcf5c892e | ||
|
|
0c326cbd51 | ||
|
|
8205eab75b | ||
|
|
ce0062aac7 | ||
|
|
8e09161b4b | ||
|
|
bf2778f5d6 | ||
|
|
223591d242 | ||
|
|
79fb68ebfe | ||
|
|
9f1f1fece2 | ||
|
|
6343f7c79b | ||
|
|
bfea2a2a76 | ||
|
|
8d65000ec9 | ||
|
|
4456fa154a | ||
|
|
8af341e206 | ||
|
|
6beca84284 | ||
|
|
6dfebec6dd | ||
|
|
756f81db94 | ||
|
|
8e854494e0 | ||
|
|
d70817ce85 | ||
|
|
49df72dfcf | ||
|
|
89ebbb66d2 | ||
|
|
b463f5b8ca | ||
|
|
417c97acee | ||
|
|
4beb0eca42 | ||
|
|
428055c3da | ||
|
|
20d812c7a3 | ||
|
|
d9a2b6b6fa | ||
|
|
606b0d67da | ||
|
|
67736b0f01 | ||
|
|
fc672aa0a3 | ||
|
|
79643936e1 |
@@ -1,4 +0,0 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
jest.config.js
|
||||
@@ -1,61 +0,0 @@
|
||||
{
|
||||
"plugins": ["jest", "@typescript-eslint"],
|
||||
"extends": ["plugin:github/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 9,
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"rules": {
|
||||
"no-shadow": "off",
|
||||
"@typescript-eslint/no-shadow": ["error"],
|
||||
"i18n-text/no-en": "off",
|
||||
"eslint-comments/no-use": "off",
|
||||
"import/no-namespace": "off",
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"@typescript-eslint/explicit-member-accessibility": [
|
||||
"error",
|
||||
{ "accessibility": "no-public" }
|
||||
],
|
||||
"@typescript-eslint/no-require-imports": "error",
|
||||
"@typescript-eslint/array-type": "error",
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
"@typescript-eslint/ban-ts-comment": "error",
|
||||
"camelcase": "off",
|
||||
"@typescript-eslint/consistent-type-assertions": "error",
|
||||
"@typescript-eslint/explicit-function-return-type": [
|
||||
"error",
|
||||
{ "allowExpressions": true }
|
||||
],
|
||||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||
"@typescript-eslint/no-array-constructor": "error",
|
||||
"@typescript-eslint/no-empty-interface": "error",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-extraneous-class": "error",
|
||||
"@typescript-eslint/no-for-in-array": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
"@typescript-eslint/no-namespace": "error",
|
||||
"@typescript-eslint/no-non-null-assertion": "warn",
|
||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||
"@typescript-eslint/no-useless-constructor": "error",
|
||||
"@typescript-eslint/no-var-requires": "error",
|
||||
"@typescript-eslint/prefer-for-of": "warn",
|
||||
"@typescript-eslint/prefer-function-type": "warn",
|
||||
"@typescript-eslint/prefer-includes": "error",
|
||||
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
||||
"@typescript-eslint/promise-function-async": "error",
|
||||
"@typescript-eslint/require-array-sort-compare": "error",
|
||||
"@typescript-eslint/restrict-plus-operands": "error",
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"@typescript-eslint/unbound-method": "error"
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"jest/globals": true
|
||||
}
|
||||
}
|
||||
4
.github/workflows/check-dist.yml
vendored
4
.github/workflows/check-dist.yml
vendored
@@ -9,11 +9,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
90
.github/workflows/test-cache.yml
vendored
90
.github/workflows/test-cache.yml
vendored
@@ -48,8 +48,48 @@ jobs:
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
|
||||
test-setup-cache-dependency-glob:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup with cache
|
||||
uses: ./
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: |
|
||||
__tests__/fixtures/uv-project/uv.lock
|
||||
**/pyproject.toml
|
||||
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
test-restore-cache-dependency-glob:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test-setup-cache-dependency-glob
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Change pyproject.toml
|
||||
run: |
|
||||
echo '[tool.uv]' >> __tests__/fixtures/uv-project/pyproject.toml
|
||||
echo 'dev-dependencies = []' >> __tests__/fixtures/uv-project/pyproject.toml
|
||||
- name: Restore with cache
|
||||
id: restore
|
||||
uses: ./
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: |
|
||||
__tests__/fixtures/uv-project/uv.lock
|
||||
**/pyproject.toml
|
||||
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}
|
||||
- name: Cache was not hit
|
||||
run: |
|
||||
if [ "$CACHE_HIT" == "true" ]; then
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
|
||||
|
||||
test-setup-cache-local:
|
||||
runs-on: oracle-aarch64
|
||||
runs-on: selfhosted-ubuntu-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup with cache
|
||||
@@ -61,7 +101,7 @@ jobs:
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
test-restore-cache-local:
|
||||
runs-on: oracle-aarch64
|
||||
runs-on: selfhosted-ubuntu-arm64
|
||||
needs: test-setup-cache-local
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -81,3 +121,49 @@ jobs:
|
||||
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
|
||||
prepare-tilde-expansion-tests:
|
||||
runs-on: selfhosted-ubuntu-arm64
|
||||
steps:
|
||||
- name: Create cache directory
|
||||
run: mkdir -p ~/uv-cache
|
||||
shell: bash
|
||||
- name: Create cache dependency glob file
|
||||
run: touch ~/uv-cache.glob
|
||||
shell: bash
|
||||
|
||||
test-tilde-expansion-cache-local-path:
|
||||
needs: prepare-tilde-expansion-tests
|
||||
runs-on: selfhosted-ubuntu-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup with cache
|
||||
uses: ./
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-local-path: ~/uv-cache/cache-local-path
|
||||
|
||||
test-tilde-expansion-cache-dependency-glob:
|
||||
needs: prepare-tilde-expansion-tests
|
||||
runs-on: selfhosted-ubuntu-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup with cache
|
||||
uses: ./
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-local-path: ~/uv-cache/cache-dependency-glob
|
||||
cache-dependency-glob: "~/uv-cache.glob"
|
||||
|
||||
cleanup-tilde-expansion-tests:
|
||||
needs:
|
||||
- test-tilde-expansion-cache-local-path
|
||||
- test-tilde-expansion-cache-dependency-glob
|
||||
runs-on: selfhosted-ubuntu-arm64
|
||||
steps:
|
||||
- name: Remove cache directory
|
||||
run: rm -rf ~/uv-cache
|
||||
shell: bash
|
||||
- name: Remove cache dependency glob file
|
||||
run: rm -f ~/uv-cache.glob
|
||||
shell: bash
|
||||
|
||||
2
.github/workflows/test-windows.yml
vendored
2
.github/workflows/test-windows.yml
vendored
@@ -23,7 +23,5 @@ jobs:
|
||||
}
|
||||
- name: Setup uv
|
||||
uses: ./
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: uv sync
|
||||
working-directory: __tests__\fixtures\uv-project
|
||||
|
||||
87
.github/workflows/test.yml
vendored
87
.github/workflows/test.yml
vendored
@@ -11,10 +11,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, macos-14, oracle-aarch64]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
@@ -24,46 +21,65 @@ jobs:
|
||||
npm install
|
||||
- run: |
|
||||
npm run all
|
||||
- name: Make sure no changes from linters are detected
|
||||
run: |
|
||||
git diff --exit-code
|
||||
test-default-version:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, macos-14, oracle-aarch64]
|
||||
os: [ubuntu-latest, macos-latest, macos-14, selfhosted-ubuntu-arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install default version
|
||||
uses: ./
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
test-specific-version:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, macos-14, oracle-aarch64]
|
||||
uv-version: ["latest", "0.3.0", "0.3.2"]
|
||||
os: [ubuntu-latest, macos-latest, macos-14, selfhosted-ubuntu-arm64]
|
||||
uv-version: ["latest", "0.3.0", "0.3.2", "0.3", "0.3.x", ">=0.3.0"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install version ${{ matrix.uv-version }}
|
||||
uses: ./
|
||||
with:
|
||||
version: ${{ matrix.uv-version }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
test-semver-range:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, selfhosted-ubuntu-arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install version 0.3
|
||||
id: setup-uv
|
||||
uses: ./
|
||||
with:
|
||||
version: "0.3"
|
||||
- name: Correct version gets installed
|
||||
run: |
|
||||
if [ "$UV_VERSION" != "0.3.5" ]; then
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
UV_VERSION: ${{ steps.setup-uv.outputs.uv-version }}
|
||||
test-checksum:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, oracle-aarch64]
|
||||
os: [ubuntu-latest, selfhosted-ubuntu-arm64]
|
||||
checksum:
|
||||
["4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd"]
|
||||
exclude:
|
||||
- os: oracle-aarch64
|
||||
- os: selfhosted-ubuntu-arm64
|
||||
checksum: "4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd"
|
||||
include:
|
||||
- os: oracle-aarch64
|
||||
- os: selfhosted-ubuntu-arm64
|
||||
checksum: "e11b01402ab645392c7ad6044db63d37e4fd1e745e015306993b07695ea5f9f8"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -72,16 +88,16 @@ jobs:
|
||||
with:
|
||||
version: "0.3.2"
|
||||
checksum: ${{ matrix.checksum }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
test-without-github-token:
|
||||
test-with-explicit-token:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install default version
|
||||
uses: ./
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
|
||||
test-uvx:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -89,3 +105,42 @@ jobs:
|
||||
- name: Install default version
|
||||
uses: ./
|
||||
- run: uvx ruff --version
|
||||
test-tool-install:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
[
|
||||
ubuntu-latest,
|
||||
macos-latest,
|
||||
macos-14,
|
||||
windows-latest,
|
||||
selfhosted-ubuntu-arm64,
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install default version
|
||||
uses: ./
|
||||
- run: uv tool install ruff
|
||||
- run: ruff --version
|
||||
|
||||
test-tilde-expansion-tool-dirs:
|
||||
runs-on: selfhosted-ubuntu-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup with cache
|
||||
uses: ./
|
||||
with:
|
||||
tool-bin-dir: "~/tool-bin-dir"
|
||||
tool-dir: "~/tool-dir"
|
||||
- name: "Check if tool dirs are expanded"
|
||||
run: |
|
||||
if ! echo "$PATH" | grep -q "/home/ubuntu/tool-bin-dir"; then
|
||||
echo "PATH does not contain /home/ubuntu/tool-bin-dir: $PATH"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$UV_TOOL_DIR" != "/home/ubuntu/tool-dir" ]; then
|
||||
echo "UV_TOOL_DIR does not contain /home/ubuntu/tool-dir: $UV_TOOL_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
2
.github/workflows/update-known-checksums.yml
vendored
2
.github/workflows/update-known-checksums.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
src/download/checksum/known-checksums.ts ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: npm install && npm run all
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@4320041ed380b20e97d388d56a7fb4f9b8c20e79 # v7.0.0
|
||||
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
|
||||
with:
|
||||
commit-message: "chore: update known checksums"
|
||||
title:
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -96,4 +96,7 @@ Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
__tests__/runner/*
|
||||
lib/**/*
|
||||
lib/**/*
|
||||
|
||||
# Idea IDEs (PyCharm, WebStorm, IntelliJ, etc)
|
||||
.idea/
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"trailingComma": "all",
|
||||
"proseWrap": "always"
|
||||
}
|
||||
207
README.md
207
README.md
@@ -11,13 +11,17 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
|
||||
## Contents
|
||||
|
||||
- [Usage](#usage)
|
||||
- [Install specific version](#install-specific-version)
|
||||
- [Install latest version](#install-latest-version)
|
||||
- [Install the latest version (default)](#install-the-latest-version-default)
|
||||
- [Install a specific version](#install-a-specific-version)
|
||||
- [Install a version by supplying a semver range](#install-a-version-by-supplying-a-semver-range)
|
||||
- [Validate checksum](#validate-checksum)
|
||||
- [Enable Caching](#enable-caching)
|
||||
- [Local cache path](#local-cache-path)
|
||||
- [Cache dependency glob](#cache-dependency-glob)
|
||||
- [API rate limit](#api-rate-limit)
|
||||
- [Local cache path](#local-cache-path)
|
||||
- [GitHub authentication token](#github-authentication-token)
|
||||
- [UV_TOOL_DIR](#uv_tool_dir)
|
||||
- [UV_TOOL_BIN_DIR](#uv_tool_bin_dir)
|
||||
- [Tilde Expansion](#tilde-expansion)
|
||||
- [How it works](#how-it-works)
|
||||
- [FAQ](#faq)
|
||||
|
||||
@@ -27,7 +31,7 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of uv
|
||||
uses: astral-sh/setup-uv@v1
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
version: "latest"
|
||||
```
|
||||
@@ -45,20 +49,39 @@ For an example workflow, see
|
||||
|
||||
```yaml
|
||||
- name: Install a specific version of uv
|
||||
uses: astral-sh/setup-uv@v1
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
version: "0.4.4"
|
||||
```
|
||||
|
||||
### Install a version by supplying a semver range
|
||||
|
||||
You can also specify a [semver range](https://github.com/npm/node-semver?tab=readme-ov-file#ranges)
|
||||
to install the latest version that satisfies the range.
|
||||
|
||||
```yaml
|
||||
- name: Install a semver range of uv
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
version: ">=0.4.0"
|
||||
```
|
||||
|
||||
```yaml
|
||||
- name: Pinning a minor version of uv
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
version: "0.4.x"
|
||||
```
|
||||
|
||||
### Validate checksum
|
||||
|
||||
You can also specify a checksum to validate the downloaded file. Checksums up to the default version
|
||||
are automatically verified by this action. The sha265 hashes can be found on the
|
||||
are automatically verified by this action. The sha256 hashes can be found on the
|
||||
[releases page](https://github.com/astral-sh/uv/releases) of the uv repo.
|
||||
|
||||
```yaml
|
||||
- name: Install a specific version and validate the checksum
|
||||
uses: astral-sh/setup-uv@v1
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
version: "0.3.1"
|
||||
checksum: "e11b01402ab645392c7ad6044db63d37e4fd1e745e015306993b07695ea5f9f8"
|
||||
@@ -67,15 +90,19 @@ are automatically verified by this action. The sha265 hashes can be found on the
|
||||
### Enable caching
|
||||
|
||||
If you enable caching, the [uv cache](https://docs.astral.sh/uv/concepts/cache/) will be cached to
|
||||
the GitHub Actions Cache. This can speed up runs that reuse the cache by several minutes. The cache
|
||||
will always be reused on self-hosted runners.
|
||||
the GitHub Actions Cache. This can speed up runs that reuse the cache by several minutes.
|
||||
|
||||
> [!TIP]
|
||||
>
|
||||
> On self-hosted runners this is usually not needed since the cache generated by uv on the runner's
|
||||
> filesystem is not removed after a run. For more details see [Local cache path](#local-cache-path).
|
||||
|
||||
You can optionally define a custom cache key suffix.
|
||||
|
||||
```yaml
|
||||
- name: Enable caching and define a custom cache key suffix
|
||||
id: setup-uv
|
||||
uses: astral-sh/setup-uv@v1
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-suffix: "optional-suffix"
|
||||
@@ -90,51 +117,155 @@ use it in subsequent steps. For example, to use the cache in the above case:
|
||||
run: echo "Cache was restored"
|
||||
```
|
||||
|
||||
#### Local cache path
|
||||
|
||||
If you want to save the cache to a local path other than the default path (`/tmp/setup-uv-cache`),
|
||||
specify the path with the `cache-local-path` input.
|
||||
|
||||
```yaml
|
||||
- name: Define a custom uv cache path
|
||||
uses: astral-sh/setup-uv@v1
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-local-path: "/path/to/cache"
|
||||
```
|
||||
|
||||
#### Cache dependency glob
|
||||
|
||||
If you want to control when the cache is invalidated, specify a glob pattern with the
|
||||
`cache-dependency-glob` input. The cache will be invalidated if any file matching the glob pattern
|
||||
changes. The glob matches files relative to the repository root.
|
||||
changes. If you use relative paths, the glob matches files relative to the repository root.
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> The default is `**/uv.lock`.
|
||||
|
||||
```yaml
|
||||
- name: Define a cache dependency glob
|
||||
uses: astral-sh/setup-uv@v1
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
cache-dependency-glob: "**/requirements*.txt"
|
||||
```
|
||||
|
||||
```yaml
|
||||
- name: Define a cache dependency glob
|
||||
uses: astral-sh/setup-uv@v1
|
||||
- name: Define a list of cache dependency globs
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "**requirements*.txt"
|
||||
cache-dependency-glob: |
|
||||
**/requirements*.txt
|
||||
**/pyproject.toml
|
||||
```
|
||||
|
||||
### API rate limit
|
||||
```yaml
|
||||
- name: Define an absolute cache dependency glob
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "/tmp/my-folder/requirements*.txt"
|
||||
```
|
||||
|
||||
To avoid hitting the `API rate limit exceeded` error, supply a GitHub token via the `github-token`
|
||||
```yaml
|
||||
- name: Never invalidate the cache
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: ""
|
||||
```
|
||||
|
||||
### Local cache path
|
||||
|
||||
This action controls where uv stores its cache on the runner's filesystem by setting `UV_CACHE_DIR`.
|
||||
It defaults to `setup-uv-cache` in the `TMP` dir, `D:\a\_temp\uv-tool-dir` on Windows and
|
||||
`/tmp/setup-uv-cache` on Linux/macOS. You can change the default by specifying the path with the
|
||||
`cache-local-path` input.
|
||||
|
||||
```yaml
|
||||
- name: Define a custom uv cache path
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
cache-local-path: "/path/to/cache"
|
||||
```
|
||||
|
||||
### Disable cache pruning
|
||||
|
||||
By default, the uv cache is pruned after every run, removing pre-built wheels, but retaining any
|
||||
wheels that were built from source. On GitHub-hosted runners, it's typically faster to omit those
|
||||
pre-built wheels from the cache (and instead re-download them from the registry on each run).
|
||||
However, on self-hosted or local runners, preserving the cache may be more efficient. See
|
||||
the[documentation](https://docs.astral.sh/uv/concepts/cache/#caching-in-continuous-integration) for
|
||||
more.
|
||||
|
||||
If you want to persist the entire cache across runs, disable cache pruning with the `prune-cache`
|
||||
input.
|
||||
|
||||
```yaml
|
||||
- name: Install uv and supply a GitHub token
|
||||
uses: astral-sh/setup-uv@v1
|
||||
- name: Don't prune the cache before saving it
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
enable-cache: true
|
||||
prune-cache: false
|
||||
```
|
||||
|
||||
### GitHub authentication token
|
||||
|
||||
This action uses the GitHub API to fetch the uv release artifacts. To avoid hitting the GitHub API
|
||||
rate limit too quickly, an authentication token can be provided via the `github-token` input. By
|
||||
default, the `GITHUB_TOKEN` secret is used, which is automatically provided by GitHub Actions.
|
||||
|
||||
If the default
|
||||
[permissions for the GitHub token](https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#permissions-for-the-github_token)
|
||||
are not sufficient, you can provide a custom GitHub token with the necessary permissions.
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of uv with a custom GitHub token
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### UV_TOOL_DIR
|
||||
|
||||
On Windows `UV_TOOL_DIR` is set to `uv-tool-dir` in the `TMP` dir (e.g. `D:\a\_temp\uv-tool-dir`).
|
||||
On GitHub hosted runners this is on the much faster `D:` drive.
|
||||
|
||||
On all other platforms the tool environments are placed in the
|
||||
[default location](https://docs.astral.sh/uv/concepts/tools/#tools-directory).
|
||||
|
||||
If you want to change this behaviour (especially on self-hosted runners) you can use the `tool-dir`
|
||||
input:
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of uv with a custom tool dir
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
tool-dir: "/path/to/tool/dir"
|
||||
```
|
||||
|
||||
### UV_TOOL_BIN_DIR
|
||||
|
||||
On Windows `UV_TOOL_BIN_DIR` is set to `uv-tool-bin-dir` in the `TMP` dir (e.g.
|
||||
`D:\a\_temp\uv-tool-bin-dir`). On GitHub hosted runners this is on the much faster `D:` drive. This
|
||||
path is also automatically added to the PATH.
|
||||
|
||||
On all other platforms the tool binaries get installed to the
|
||||
[default location](https://docs.astral.sh/uv/concepts/tools/#the-bin-directory).
|
||||
|
||||
If you want to change this behaviour (especially on self-hosted runners) you can use the
|
||||
`tool-bin-dir` input:
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of uv with a custom tool bin dir
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
tool-bin-dir: "/path/to/tool-bin/dir"
|
||||
```
|
||||
|
||||
### Tilde Expansion
|
||||
|
||||
This action supports expanding the `~` character to the user's home directory for the following inputs:
|
||||
|
||||
- `cache-local-path`
|
||||
- `tool-dir`
|
||||
- `tool-bin-dir`
|
||||
- `cache-dependency-glob`
|
||||
|
||||
```yaml
|
||||
- name: Expand the tilde character
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
cache-local-path: "~/path/to/cache"
|
||||
tool-dir: "~/path/to/tool/dir"
|
||||
tool-bin-dir: "~/path/to/tool-bin/dir"
|
||||
cache-dependency-glob: "~/my-cache-buster"
|
||||
```
|
||||
|
||||
## How it works
|
||||
@@ -161,7 +292,7 @@ For example:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@main
|
||||
- name: Install the latest version of uv
|
||||
uses: astral-sh/setup-uv@v1
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
enable-cache: true
|
||||
- name: Test
|
||||
@@ -173,7 +304,7 @@ To install a specific version of Python, use
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of uv
|
||||
uses: astral-sh/setup-uv@v1
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
enable-cache: true
|
||||
- name: Install Python 3.12
|
||||
@@ -192,7 +323,7 @@ output:
|
||||
uses: actions/checkout@main
|
||||
- name: Install the default version of uv
|
||||
id: setup-uv
|
||||
uses: astral-sh/setup-uv@v1
|
||||
uses: astral-sh/setup-uv@v3
|
||||
- name: Print the installed version
|
||||
run: echo "Installed uv version is ${{ steps.setup-uv.outputs.uv-version }}"
|
||||
```
|
||||
|
||||
27
action.yml
27
action.yml
@@ -1,6 +1,7 @@
|
||||
name: "Python setup uv"
|
||||
description: "Set up your GitHub Actions workflow with a specific version of uv"
|
||||
author: "eifinger"
|
||||
name: "astral-sh/setup-uv"
|
||||
description:
|
||||
"Set up your GitHub Actions workflow with a specific version of uv."
|
||||
author: "astral-sh"
|
||||
inputs:
|
||||
version:
|
||||
description: "The version of uv to install"
|
||||
@@ -13,20 +14,30 @@ inputs:
|
||||
"Used to increase the rate limit when retrieving versions and downloading
|
||||
uv."
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
enable-cache:
|
||||
description: "Enable caching of the uv cache"
|
||||
default: "false"
|
||||
cache-dependency-glob:
|
||||
description:
|
||||
'Glob pattern to match files relative to the repository root to control
|
||||
the cache. e.g. "uv.lock"'
|
||||
required: false
|
||||
"Glob pattern to match files relative to the repository root to control
|
||||
the cache."
|
||||
default: "**/uv.lock"
|
||||
cache-suffix:
|
||||
description: "Suffix for the cache key"
|
||||
required: false
|
||||
cache-local-path:
|
||||
description: "Local path to store the cache."
|
||||
default: "/tmp/setup-uv-cache"
|
||||
default: ""
|
||||
prune-cache:
|
||||
description: "Prune cache before saving."
|
||||
default: true
|
||||
tool-dir:
|
||||
description: "Custom path to set UV_TOOL_DIR to."
|
||||
required: false
|
||||
tool-bin-dir:
|
||||
description: "Custom path to set UV_TOOL_BIN_DIR to."
|
||||
required: false
|
||||
outputs:
|
||||
uv-version:
|
||||
description: "The installed uv version. Useful when using latest."
|
||||
@@ -39,4 +50,4 @@ runs:
|
||||
post-if: success()
|
||||
branding:
|
||||
icon: "package"
|
||||
color: "blue"
|
||||
color: "black"
|
||||
|
||||
31
biome.json
Normal file
31
biome.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
|
||||
"vcs": {
|
||||
"enabled": true,
|
||||
"clientKind": "git",
|
||||
"useIgnoreFile": false
|
||||
},
|
||||
"files": {
|
||||
"ignoreUnknown": false,
|
||||
"ignore": ["dist", "lib", "node_modules"]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "space"
|
||||
},
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true
|
||||
}
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"quoteStyle": "double",
|
||||
"trailingCommas": "all"
|
||||
}
|
||||
}
|
||||
}
|
||||
3982
dist/save-cache/index.js
generated
vendored
3982
dist/save-cache/index.js
generated
vendored
File diff suppressed because one or more lines are too long
1
dist/save-cache/index.js.map
generated
vendored
1
dist/save-cache/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
1
dist/save-cache/sourcemap-register.js
generated
vendored
1
dist/save-cache/sourcemap-register.js
generated
vendored
File diff suppressed because one or more lines are too long
453
dist/setup/37.index.js
generated
vendored
453
dist/setup/37.index.js
generated
vendored
@@ -1,453 +0,0 @@
|
||||
"use strict";
|
||||
exports.id = 37;
|
||||
exports.ids = [37];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 4037:
|
||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "toFormData": () => (/* binding */ toFormData)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2777);
|
||||
/* harmony import */ var formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8010);
|
||||
|
||||
|
||||
|
||||
let s = 0;
|
||||
const S = {
|
||||
START_BOUNDARY: s++,
|
||||
HEADER_FIELD_START: s++,
|
||||
HEADER_FIELD: s++,
|
||||
HEADER_VALUE_START: s++,
|
||||
HEADER_VALUE: s++,
|
||||
HEADER_VALUE_ALMOST_DONE: s++,
|
||||
HEADERS_ALMOST_DONE: s++,
|
||||
PART_DATA_START: s++,
|
||||
PART_DATA: s++,
|
||||
END: s++
|
||||
};
|
||||
|
||||
let f = 1;
|
||||
const F = {
|
||||
PART_BOUNDARY: f,
|
||||
LAST_BOUNDARY: f *= 2
|
||||
};
|
||||
|
||||
const LF = 10;
|
||||
const CR = 13;
|
||||
const SPACE = 32;
|
||||
const HYPHEN = 45;
|
||||
const COLON = 58;
|
||||
const A = 97;
|
||||
const Z = 122;
|
||||
|
||||
const lower = c => c | 0x20;
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
class MultipartParser {
|
||||
/**
|
||||
* @param {string} boundary
|
||||
*/
|
||||
constructor(boundary) {
|
||||
this.index = 0;
|
||||
this.flags = 0;
|
||||
|
||||
this.onHeaderEnd = noop;
|
||||
this.onHeaderField = noop;
|
||||
this.onHeadersEnd = noop;
|
||||
this.onHeaderValue = noop;
|
||||
this.onPartBegin = noop;
|
||||
this.onPartData = noop;
|
||||
this.onPartEnd = noop;
|
||||
|
||||
this.boundaryChars = {};
|
||||
|
||||
boundary = '\r\n--' + boundary;
|
||||
const ui8a = new Uint8Array(boundary.length);
|
||||
for (let i = 0; i < boundary.length; i++) {
|
||||
ui8a[i] = boundary.charCodeAt(i);
|
||||
this.boundaryChars[ui8a[i]] = true;
|
||||
}
|
||||
|
||||
this.boundary = ui8a;
|
||||
this.lookbehind = new Uint8Array(this.boundary.length + 8);
|
||||
this.state = S.START_BOUNDARY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
*/
|
||||
write(data) {
|
||||
let i = 0;
|
||||
const length_ = data.length;
|
||||
let previousIndex = this.index;
|
||||
let {lookbehind, boundary, boundaryChars, index, state, flags} = this;
|
||||
const boundaryLength = this.boundary.length;
|
||||
const boundaryEnd = boundaryLength - 1;
|
||||
const bufferLength = data.length;
|
||||
let c;
|
||||
let cl;
|
||||
|
||||
const mark = name => {
|
||||
this[name + 'Mark'] = i;
|
||||
};
|
||||
|
||||
const clear = name => {
|
||||
delete this[name + 'Mark'];
|
||||
};
|
||||
|
||||
const callback = (callbackSymbol, start, end, ui8a) => {
|
||||
if (start === undefined || start !== end) {
|
||||
this[callbackSymbol](ui8a && ui8a.subarray(start, end));
|
||||
}
|
||||
};
|
||||
|
||||
const dataCallback = (name, clear) => {
|
||||
const markSymbol = name + 'Mark';
|
||||
if (!(markSymbol in this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clear) {
|
||||
callback(name, this[markSymbol], i, data);
|
||||
delete this[markSymbol];
|
||||
} else {
|
||||
callback(name, this[markSymbol], data.length, data);
|
||||
this[markSymbol] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
for (i = 0; i < length_; i++) {
|
||||
c = data[i];
|
||||
|
||||
switch (state) {
|
||||
case S.START_BOUNDARY:
|
||||
if (index === boundary.length - 2) {
|
||||
if (c === HYPHEN) {
|
||||
flags |= F.LAST_BOUNDARY;
|
||||
} else if (c !== CR) {
|
||||
return;
|
||||
}
|
||||
|
||||
index++;
|
||||
break;
|
||||
} else if (index - 1 === boundary.length - 2) {
|
||||
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
|
||||
state = S.END;
|
||||
flags = 0;
|
||||
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
|
||||
index = 0;
|
||||
callback('onPartBegin');
|
||||
state = S.HEADER_FIELD_START;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (c !== boundary[index + 2]) {
|
||||
index = -2;
|
||||
}
|
||||
|
||||
if (c === boundary[index + 2]) {
|
||||
index++;
|
||||
}
|
||||
|
||||
break;
|
||||
case S.HEADER_FIELD_START:
|
||||
state = S.HEADER_FIELD;
|
||||
mark('onHeaderField');
|
||||
index = 0;
|
||||
// falls through
|
||||
case S.HEADER_FIELD:
|
||||
if (c === CR) {
|
||||
clear('onHeaderField');
|
||||
state = S.HEADERS_ALMOST_DONE;
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
if (c === HYPHEN) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (c === COLON) {
|
||||
if (index === 1) {
|
||||
// empty header field
|
||||
return;
|
||||
}
|
||||
|
||||
dataCallback('onHeaderField', true);
|
||||
state = S.HEADER_VALUE_START;
|
||||
break;
|
||||
}
|
||||
|
||||
cl = lower(c);
|
||||
if (cl < A || cl > Z) {
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
case S.HEADER_VALUE_START:
|
||||
if (c === SPACE) {
|
||||
break;
|
||||
}
|
||||
|
||||
mark('onHeaderValue');
|
||||
state = S.HEADER_VALUE;
|
||||
// falls through
|
||||
case S.HEADER_VALUE:
|
||||
if (c === CR) {
|
||||
dataCallback('onHeaderValue', true);
|
||||
callback('onHeaderEnd');
|
||||
state = S.HEADER_VALUE_ALMOST_DONE;
|
||||
}
|
||||
|
||||
break;
|
||||
case S.HEADER_VALUE_ALMOST_DONE:
|
||||
if (c !== LF) {
|
||||
return;
|
||||
}
|
||||
|
||||
state = S.HEADER_FIELD_START;
|
||||
break;
|
||||
case S.HEADERS_ALMOST_DONE:
|
||||
if (c !== LF) {
|
||||
return;
|
||||
}
|
||||
|
||||
callback('onHeadersEnd');
|
||||
state = S.PART_DATA_START;
|
||||
break;
|
||||
case S.PART_DATA_START:
|
||||
state = S.PART_DATA;
|
||||
mark('onPartData');
|
||||
// falls through
|
||||
case S.PART_DATA:
|
||||
previousIndex = index;
|
||||
|
||||
if (index === 0) {
|
||||
// boyer-moore derrived algorithm to safely skip non-boundary data
|
||||
i += boundaryEnd;
|
||||
while (i < bufferLength && !(data[i] in boundaryChars)) {
|
||||
i += boundaryLength;
|
||||
}
|
||||
|
||||
i -= boundaryEnd;
|
||||
c = data[i];
|
||||
}
|
||||
|
||||
if (index < boundary.length) {
|
||||
if (boundary[index] === c) {
|
||||
if (index === 0) {
|
||||
dataCallback('onPartData', true);
|
||||
}
|
||||
|
||||
index++;
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
} else if (index === boundary.length) {
|
||||
index++;
|
||||
if (c === CR) {
|
||||
// CR = part boundary
|
||||
flags |= F.PART_BOUNDARY;
|
||||
} else if (c === HYPHEN) {
|
||||
// HYPHEN = end boundary
|
||||
flags |= F.LAST_BOUNDARY;
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
} else if (index - 1 === boundary.length) {
|
||||
if (flags & F.PART_BOUNDARY) {
|
||||
index = 0;
|
||||
if (c === LF) {
|
||||
// unset the PART_BOUNDARY flag
|
||||
flags &= ~F.PART_BOUNDARY;
|
||||
callback('onPartEnd');
|
||||
callback('onPartBegin');
|
||||
state = S.HEADER_FIELD_START;
|
||||
break;
|
||||
}
|
||||
} else if (flags & F.LAST_BOUNDARY) {
|
||||
if (c === HYPHEN) {
|
||||
callback('onPartEnd');
|
||||
state = S.END;
|
||||
flags = 0;
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (index > 0) {
|
||||
// when matching a possible boundary, keep a lookbehind reference
|
||||
// in case it turns out to be a false lead
|
||||
lookbehind[index - 1] = c;
|
||||
} else if (previousIndex > 0) {
|
||||
// if our boundary turned out to be rubbish, the captured lookbehind
|
||||
// belongs to partData
|
||||
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
|
||||
callback('onPartData', 0, previousIndex, _lookbehind);
|
||||
previousIndex = 0;
|
||||
mark('onPartData');
|
||||
|
||||
// reconsider the current character even so it interrupted the sequence
|
||||
// it could be the beginning of a new sequence
|
||||
i--;
|
||||
}
|
||||
|
||||
break;
|
||||
case S.END:
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unexpected state entered: ${state}`);
|
||||
}
|
||||
}
|
||||
|
||||
dataCallback('onHeaderField');
|
||||
dataCallback('onHeaderValue');
|
||||
dataCallback('onPartData');
|
||||
|
||||
// Update properties for the next call
|
||||
this.index = index;
|
||||
this.state = state;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
end() {
|
||||
if ((this.state === S.HEADER_FIELD_START && this.index === 0) ||
|
||||
(this.state === S.PART_DATA && this.index === this.boundary.length)) {
|
||||
this.onPartEnd();
|
||||
} else if (this.state !== S.END) {
|
||||
throw new Error('MultipartParser.end(): stream ended unexpectedly');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _fileName(headerValue) {
|
||||
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
||||
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
|
||||
if (!m) {
|
||||
return;
|
||||
}
|
||||
|
||||
const match = m[2] || m[3] || '';
|
||||
let filename = match.slice(match.lastIndexOf('\\') + 1);
|
||||
filename = filename.replace(/%22/g, '"');
|
||||
filename = filename.replace(/&#(\d{4});/g, (m, code) => {
|
||||
return String.fromCharCode(code);
|
||||
});
|
||||
return filename;
|
||||
}
|
||||
|
||||
async function toFormData(Body, ct) {
|
||||
if (!/multipart/i.test(ct)) {
|
||||
throw new TypeError('Failed to fetch');
|
||||
}
|
||||
|
||||
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
||||
|
||||
if (!m) {
|
||||
throw new TypeError('no or bad content-type header, no multipart boundary');
|
||||
}
|
||||
|
||||
const parser = new MultipartParser(m[1] || m[2]);
|
||||
|
||||
let headerField;
|
||||
let headerValue;
|
||||
let entryValue;
|
||||
let entryName;
|
||||
let contentType;
|
||||
let filename;
|
||||
const entryChunks = [];
|
||||
const formData = new formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__/* .FormData */ .Ct();
|
||||
|
||||
const onPartData = ui8a => {
|
||||
entryValue += decoder.decode(ui8a, {stream: true});
|
||||
};
|
||||
|
||||
const appendToFile = ui8a => {
|
||||
entryChunks.push(ui8a);
|
||||
};
|
||||
|
||||
const appendFileToFormData = () => {
|
||||
const file = new fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__/* .File */ .$B(entryChunks, filename, {type: contentType});
|
||||
formData.append(entryName, file);
|
||||
};
|
||||
|
||||
const appendEntryToFormData = () => {
|
||||
formData.append(entryName, entryValue);
|
||||
};
|
||||
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
decoder.decode();
|
||||
|
||||
parser.onPartBegin = function () {
|
||||
parser.onPartData = onPartData;
|
||||
parser.onPartEnd = appendEntryToFormData;
|
||||
|
||||
headerField = '';
|
||||
headerValue = '';
|
||||
entryValue = '';
|
||||
entryName = '';
|
||||
contentType = '';
|
||||
filename = null;
|
||||
entryChunks.length = 0;
|
||||
};
|
||||
|
||||
parser.onHeaderField = function (ui8a) {
|
||||
headerField += decoder.decode(ui8a, {stream: true});
|
||||
};
|
||||
|
||||
parser.onHeaderValue = function (ui8a) {
|
||||
headerValue += decoder.decode(ui8a, {stream: true});
|
||||
};
|
||||
|
||||
parser.onHeaderEnd = function () {
|
||||
headerValue += decoder.decode();
|
||||
headerField = headerField.toLowerCase();
|
||||
|
||||
if (headerField === 'content-disposition') {
|
||||
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
||||
const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
||||
|
||||
if (m) {
|
||||
entryName = m[2] || m[3] || '';
|
||||
}
|
||||
|
||||
filename = _fileName(headerValue);
|
||||
|
||||
if (filename) {
|
||||
parser.onPartData = appendToFile;
|
||||
parser.onPartEnd = appendFileToFormData;
|
||||
}
|
||||
} else if (headerField === 'content-type') {
|
||||
contentType = headerValue;
|
||||
}
|
||||
|
||||
headerValue = '';
|
||||
headerField = '';
|
||||
};
|
||||
|
||||
for await (const chunk of Body) {
|
||||
parser.write(chunk);
|
||||
}
|
||||
|
||||
parser.end();
|
||||
|
||||
return formData;
|
||||
}
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
//# sourceMappingURL=37.index.js.map
|
||||
1
dist/setup/37.index.js.map
generated
vendored
1
dist/setup/37.index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
8797
dist/setup/index.js
generated
vendored
8797
dist/setup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
1
dist/setup/index.js.map
generated
vendored
1
dist/setup/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
1056
dist/setup/licenses.txt
generated
vendored
1056
dist/setup/licenses.txt
generated
vendored
File diff suppressed because it is too large
Load Diff
1
dist/setup/sourcemap-register.js
generated
vendored
1
dist/setup/sourcemap-register.js
generated
vendored
File diff suppressed because one or more lines are too long
35031
dist/update-checksums/index.js
generated
vendored
35031
dist/update-checksums/index.js
generated
vendored
File diff suppressed because one or more lines are too long
1
dist/update-checksums/index.js.map
generated
vendored
1
dist/update-checksums/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
1
dist/update-checksums/sourcemap-register.js
generated
vendored
1
dist/update-checksums/sourcemap-register.js
generated
vendored
File diff suppressed because one or more lines are too long
34791
dist/update-default-version/index.js
generated
vendored
34791
dist/update-default-version/index.js
generated
vendored
File diff suppressed because one or more lines are too long
1
dist/update-default-version/index.js.map
generated
vendored
1
dist/update-default-version/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
1
dist/update-default-version/sourcemap-register.js
generated
vendored
1
dist/update-default-version/sourcemap-register.js
generated
vendored
File diff suppressed because one or more lines are too long
2522
dist/update-known-checksums/index.js
generated
vendored
2522
dist/update-known-checksums/index.js
generated
vendored
File diff suppressed because one or more lines are too long
5993
package-lock.json
generated
5993
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@@ -6,9 +6,9 @@
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"format": "prettier --write .",
|
||||
"format-check": "prettier --check .",
|
||||
"lint": "eslint src/**/*.ts --fix",
|
||||
"format": "biome format --fix",
|
||||
"format-check": "biome format",
|
||||
"lint": "biome lint --fix",
|
||||
"package": "ncc build -o dist/setup src/setup-uv.ts && ncc build -o dist/save-cache src/save-cache.ts && ncc build -o dist/update-known-checksums src/update-known-checksums.ts",
|
||||
"test": "jest",
|
||||
"act": "act pull_request -W .github/workflows/test.yml --container-architecture linux/amd64 -s GITHUB_TOKEN=\"$(gh auth token)\"",
|
||||
@@ -19,17 +19,12 @@
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/astral-sh/setup-uv.git"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
"python",
|
||||
"setup",
|
||||
"uv"
|
||||
],
|
||||
"keywords": ["actions", "python", "setup", "uv"],
|
||||
"author": "@eifinger",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^3.2.4",
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/cache": "^3.3.0",
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@actions/glob": "^0.5.0",
|
||||
@@ -38,20 +33,13 @@
|
||||
"@octokit/rest": "^21.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.5.4",
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/node": "^22.9.1",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-github": "^5.0.1",
|
||||
"eslint-plugin-import": "^2.30.0",
|
||||
"eslint-plugin-jest": "^28.8.3",
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"jest": "^29.7.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "^3.3.3",
|
||||
"ts-jest": "^29.2.5",
|
||||
"typescript": "^5.5.4"
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
|
||||
11
src/cache/restore-cache.ts
vendored
11
src/cache/restore-cache.ts
vendored
@@ -1,13 +1,12 @@
|
||||
import * as cache from "@actions/cache";
|
||||
import * as glob from "@actions/glob";
|
||||
import * as core from "@actions/core";
|
||||
import path from "path";
|
||||
import {
|
||||
cacheDependencyGlob,
|
||||
cacheLocalPath,
|
||||
cacheSuffix,
|
||||
} from "../utils/inputs";
|
||||
import { getArch, getPlatform } from "../utils/platforms";
|
||||
import { hashFiles } from "../hash/hash-files";
|
||||
|
||||
export const STATE_CACHE_KEY = "cache-key";
|
||||
export const STATE_CACHE_MATCHED_KEY = "cache-matched-key";
|
||||
@@ -37,11 +36,13 @@ export async function restoreCache(version: string): Promise<void> {
|
||||
async function computeKeys(version: string): Promise<string> {
|
||||
let cacheDependencyPathHash = "-";
|
||||
if (cacheDependencyGlob !== "") {
|
||||
const fullCacheDependencyGlob = `${process.env["GITHUB_WORKSPACE"]}${path.sep}${cacheDependencyGlob}`;
|
||||
cacheDependencyPathHash += await glob.hashFiles(fullCacheDependencyGlob);
|
||||
core.info(
|
||||
`Searching files using cache dependency glob: ${cacheDependencyGlob.split("\n").join(",")}`,
|
||||
);
|
||||
cacheDependencyPathHash += await hashFiles(cacheDependencyGlob, true);
|
||||
if (cacheDependencyPathHash === "-") {
|
||||
throw new Error(
|
||||
`No file in ${process.cwd()} matched to [${cacheDependencyGlob}], make sure you have checked out the target repository`,
|
||||
`No file in ${process.cwd()} matched to [${cacheDependencyGlob.split("\n").join(",")}], make sure you have checked out the target repository`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as fs from "fs";
|
||||
import * as crypto from "crypto";
|
||||
import * as fs from "node:fs";
|
||||
import * as crypto from "node:crypto";
|
||||
|
||||
import * as core from "@actions/core";
|
||||
import { KNOWN_CHECKSUMS } from "./known-checksums";
|
||||
import { Architecture, Platform } from "../../utils/platforms";
|
||||
import type { Architecture, Platform } from "../../utils/platforms";
|
||||
|
||||
export async function validateChecksum(
|
||||
checkSum: string | undefined,
|
||||
@@ -12,11 +12,11 @@ export async function validateChecksum(
|
||||
platform: Platform,
|
||||
version: string,
|
||||
): Promise<void> {
|
||||
let isValid = true;
|
||||
let isValid: boolean | undefined = undefined;
|
||||
if (checkSum !== undefined && checkSum !== "") {
|
||||
isValid = await validateFileCheckSum(downloadPath, checkSum);
|
||||
} else {
|
||||
core.debug(`Checksum not provided. Checking known checksums.`);
|
||||
core.debug("Checksum not provided. Checking known checksums.");
|
||||
const key = `${arch}-${platform}-${version}`;
|
||||
if (key in KNOWN_CHECKSUMS) {
|
||||
const knownChecksum = KNOWN_CHECKSUMS[`${arch}-${platform}-${version}`];
|
||||
@@ -27,10 +27,12 @@ export async function validateChecksum(
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
if (isValid === false) {
|
||||
throw new Error(`Checksum for ${downloadPath} did not match ${checkSum}.`);
|
||||
}
|
||||
core.debug(`Checksum for ${downloadPath} is valid.`);
|
||||
if (isValid === true) {
|
||||
core.debug(`Checksum for ${downloadPath} is valid.`);
|
||||
}
|
||||
}
|
||||
|
||||
async function validateFileCheckSum(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import { promises as fs } from "fs";
|
||||
import { promises as fs } from "node:fs";
|
||||
import * as tc from "@actions/tool-cache";
|
||||
export async function updateChecksums(
|
||||
filePath: string,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import * as core from "@actions/core";
|
||||
import * as tc from "@actions/tool-cache";
|
||||
import * as exec from "@actions/exec";
|
||||
import * as path from "path";
|
||||
import { Architecture, Platform } from "../utils/platforms";
|
||||
import * as path from "node:path";
|
||||
import { promises as fs } from "node:fs";
|
||||
import type { Architecture, Platform } from "../utils/platforms";
|
||||
import { validateChecksum } from "./checksum/checksum";
|
||||
import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/utils";
|
||||
import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants";
|
||||
|
||||
export async function downloadLatest(
|
||||
platform: Platform,
|
||||
@@ -13,12 +14,11 @@ export async function downloadLatest(
|
||||
githubToken: string | undefined,
|
||||
): Promise<{ cachedToolDir: string; version: string }> {
|
||||
const artifact = `uv-${arch}-${platform}`;
|
||||
let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${artifact}`;
|
||||
let extension = ".tar.gz";
|
||||
if (platform === "pc-windows-msvc") {
|
||||
downloadUrl += ".zip";
|
||||
} else {
|
||||
downloadUrl += ".tar.gz";
|
||||
extension = ".zip";
|
||||
}
|
||||
const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${artifact}${extension}`;
|
||||
core.info(`Downloading uv from "${downloadUrl}" ...`);
|
||||
|
||||
const downloadPath = await tc.downloadTool(
|
||||
@@ -29,7 +29,9 @@ export async function downloadLatest(
|
||||
let uvExecutablePath: string;
|
||||
let uvDir: string;
|
||||
if (platform === "pc-windows-msvc") {
|
||||
uvDir = await tc.extractZip(downloadPath);
|
||||
const fullPathWithExtension = `${downloadPath}${extension}`;
|
||||
await fs.copyFile(downloadPath, fullPathWithExtension);
|
||||
uvDir = await tc.extractZip(fullPathWithExtension);
|
||||
// On windows extracting the zip does not create an intermediate directory
|
||||
uvExecutablePath = path.join(uvDir, "uv.exe");
|
||||
} else {
|
||||
@@ -67,5 +69,5 @@ async function getVersion(uvExecutablePath: string): Promise<string> {
|
||||
};
|
||||
await exec.exec(uvExecutablePath, execArgs, options);
|
||||
const parts = output.split(" ");
|
||||
return parts[1];
|
||||
return parts[1].trim();
|
||||
}
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
import * as core from "@actions/core";
|
||||
import * as tc from "@actions/tool-cache";
|
||||
import * as path from "path";
|
||||
import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/utils";
|
||||
import { Architecture, Platform } from "../utils/platforms";
|
||||
import * as path from "node:path";
|
||||
import { promises as fs } from "node:fs";
|
||||
import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants";
|
||||
import type { Architecture, Platform } from "../utils/platforms";
|
||||
import { validateChecksum } from "./checksum/checksum";
|
||||
import * as github from "@actions/github";
|
||||
|
||||
export function tryGetFromToolCache(
|
||||
arch: Architecture,
|
||||
version: string,
|
||||
): string | undefined {
|
||||
): { version: string; installedPath: string | undefined } {
|
||||
core.debug(`Trying to get uv from tool cache for ${version}...`);
|
||||
const cachedVersions = tc.findAllVersions(TOOL_CACHE_NAME, arch);
|
||||
core.debug(`Cached versions: ${cachedVersions}`);
|
||||
return tc.find(TOOL_CACHE_NAME, version, arch);
|
||||
let resolvedVersion = tc.evaluateVersions(cachedVersions, version);
|
||||
if (resolvedVersion === "") {
|
||||
resolvedVersion = version;
|
||||
}
|
||||
const installedPath = tc.find(TOOL_CACHE_NAME, resolvedVersion, arch);
|
||||
return { version: resolvedVersion, installedPath };
|
||||
}
|
||||
|
||||
export async function downloadVersion(
|
||||
@@ -20,15 +27,15 @@ export async function downloadVersion(
|
||||
arch: Architecture,
|
||||
version: string,
|
||||
checkSum: string | undefined,
|
||||
githubToken: string | undefined,
|
||||
): Promise<string> {
|
||||
githubToken: string,
|
||||
): Promise<{ version: string; cachedToolDir: string }> {
|
||||
const resolvedVersion = await resolveVersion(version, githubToken);
|
||||
const artifact = `uv-${arch}-${platform}`;
|
||||
let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${version}/${artifact}`;
|
||||
let extension = ".tar.gz";
|
||||
if (platform === "pc-windows-msvc") {
|
||||
downloadUrl += ".zip";
|
||||
} else {
|
||||
downloadUrl += ".tar.gz";
|
||||
extension = ".zip";
|
||||
}
|
||||
const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${resolvedVersion}/${artifact}${extension}`;
|
||||
core.info(`Downloading uv from "${downloadUrl}" ...`);
|
||||
|
||||
const downloadPath = await tc.downloadTool(
|
||||
@@ -36,16 +43,55 @@ export async function downloadVersion(
|
||||
undefined,
|
||||
githubToken,
|
||||
);
|
||||
await validateChecksum(checkSum, downloadPath, arch, platform, version);
|
||||
await validateChecksum(
|
||||
checkSum,
|
||||
downloadPath,
|
||||
arch,
|
||||
platform,
|
||||
resolvedVersion,
|
||||
);
|
||||
|
||||
let uvDir: string;
|
||||
if (platform === "pc-windows-msvc") {
|
||||
uvDir = await tc.extractZip(downloadPath);
|
||||
const fullPathWithExtension = `${downloadPath}${extension}`;
|
||||
await fs.copyFile(downloadPath, fullPathWithExtension);
|
||||
uvDir = await tc.extractZip(fullPathWithExtension);
|
||||
// On windows extracting the zip does not create an intermediate directory
|
||||
} else {
|
||||
const extractedDir = await tc.extractTar(downloadPath);
|
||||
uvDir = path.join(extractedDir, artifact);
|
||||
}
|
||||
|
||||
return await tc.cacheDir(uvDir, TOOL_CACHE_NAME, version, arch);
|
||||
const cachedToolDir = await tc.cacheDir(
|
||||
uvDir,
|
||||
TOOL_CACHE_NAME,
|
||||
resolvedVersion,
|
||||
arch,
|
||||
);
|
||||
return { version: resolvedVersion, cachedToolDir };
|
||||
}
|
||||
|
||||
async function resolveVersion(
|
||||
version: string,
|
||||
githubToken: string,
|
||||
): Promise<string> {
|
||||
if (tc.isExplicitVersion(version)) {
|
||||
core.debug(`Version ${version} is an explicit version.`);
|
||||
return version;
|
||||
}
|
||||
const availableVersions = await getAvailableVersions(githubToken);
|
||||
const resolvedVersion = tc.evaluateVersions(availableVersions, version);
|
||||
if (resolvedVersion === "") {
|
||||
throw new Error(`No version found for ${version}`);
|
||||
}
|
||||
return resolvedVersion;
|
||||
}
|
||||
|
||||
async function getAvailableVersions(githubToken: string): Promise<string[]> {
|
||||
const octokit = github.getOctokit(githubToken);
|
||||
|
||||
const response = await octokit.paginate(octokit.rest.repos.listReleases, {
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
});
|
||||
return response.map((release) => release.tag_name);
|
||||
}
|
||||
|
||||
48
src/hash/hash-files.ts
Normal file
48
src/hash/hash-files.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import * as crypto from "node:crypto";
|
||||
import * as core from "@actions/core";
|
||||
import * as fs from "node:fs";
|
||||
import * as stream from "node:stream";
|
||||
import * as util from "node:util";
|
||||
import { create } from "@actions/glob";
|
||||
|
||||
/**
|
||||
* Hashes files matching the given glob pattern.
|
||||
*
|
||||
* Copied from https://github.com/actions/toolkit/blob/20ed2908f19538e9dfb66d8083f1171c0a50a87c/packages/glob/src/internal-hash-files.ts#L9-L49
|
||||
* But supports hashing files outside the GITHUB_WORKSPACE.
|
||||
* @param pattern The glob pattern to match files.
|
||||
* @param verbose Whether to log the files being hashed.
|
||||
*/
|
||||
export async function hashFiles(
|
||||
pattern: string,
|
||||
verbose = false,
|
||||
): Promise<string> {
|
||||
const globber = await create(pattern);
|
||||
let hasMatch = false;
|
||||
const writeDelegate = verbose ? core.info : core.debug;
|
||||
const result = crypto.createHash("sha256");
|
||||
let count = 0;
|
||||
for await (const file of globber.globGenerator()) {
|
||||
writeDelegate(file);
|
||||
if (fs.statSync(file).isDirectory()) {
|
||||
writeDelegate(`Skip directory '${file}'.`);
|
||||
continue;
|
||||
}
|
||||
const hash = crypto.createHash("sha256");
|
||||
const pipeline = util.promisify(stream.pipeline);
|
||||
await pipeline(fs.createReadStream(file), hash);
|
||||
result.write(hash.digest());
|
||||
count++;
|
||||
if (!hasMatch) {
|
||||
hasMatch = true;
|
||||
}
|
||||
}
|
||||
result.end();
|
||||
|
||||
if (hasMatch) {
|
||||
writeDelegate(`Found ${count} files to hash.`);
|
||||
return result.digest("hex");
|
||||
}
|
||||
writeDelegate("No matches found for glob");
|
||||
return "";
|
||||
}
|
||||
@@ -5,7 +5,11 @@ import {
|
||||
STATE_CACHE_MATCHED_KEY,
|
||||
STATE_CACHE_KEY,
|
||||
} from "./cache/restore-cache";
|
||||
import { cacheLocalPath, enableCache } from "./utils/inputs";
|
||||
import {
|
||||
cacheLocalPath,
|
||||
enableCache,
|
||||
pruneCache as shouldPruneCache,
|
||||
} from "./utils/inputs";
|
||||
|
||||
export async function run(): Promise<void> {
|
||||
try {
|
||||
@@ -26,12 +30,15 @@ async function saveCache(): Promise<void> {
|
||||
if (!cacheKey) {
|
||||
core.warning("Error retrieving cache key from state.");
|
||||
return;
|
||||
} else if (matchedKey === cacheKey) {
|
||||
}
|
||||
if (matchedKey === cacheKey) {
|
||||
core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`);
|
||||
return;
|
||||
}
|
||||
|
||||
await pruneCache();
|
||||
if (shouldPruneCache) {
|
||||
await pruneCache();
|
||||
}
|
||||
|
||||
core.info(`Saving cache path: ${cacheLocalPath}`);
|
||||
await cache.saveCache([cacheLocalPath], cacheKey);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as core from "@actions/core";
|
||||
import * as path from "path";
|
||||
import * as path from "node:path";
|
||||
import {
|
||||
downloadVersion,
|
||||
tryGetFromToolCache,
|
||||
@@ -8,16 +8,18 @@ import { restoreCache } from "./cache/restore-cache";
|
||||
|
||||
import { downloadLatest } from "./download/download-latest";
|
||||
import {
|
||||
Architecture,
|
||||
type Architecture,
|
||||
getArch,
|
||||
getPlatform,
|
||||
Platform,
|
||||
type Platform,
|
||||
} from "./utils/platforms";
|
||||
import {
|
||||
cacheLocalPath,
|
||||
checkSum,
|
||||
enableCache,
|
||||
githubToken,
|
||||
toolBinDir,
|
||||
toolDir,
|
||||
version,
|
||||
} from "./utils/inputs";
|
||||
|
||||
@@ -41,8 +43,10 @@ async function run(): Promise<void> {
|
||||
);
|
||||
|
||||
addUvToPath(setupResult.uvDir);
|
||||
core.setOutput("uv-version", version);
|
||||
core.info(`Successfully installed uv version ${version}`);
|
||||
addToolBinToPath();
|
||||
setToolDir();
|
||||
core.setOutput("uv-version", setupResult.version);
|
||||
core.info(`Successfully installed uv version ${setupResult.version}`);
|
||||
|
||||
addMatchers();
|
||||
setCacheDir(cacheLocalPath);
|
||||
@@ -50,10 +54,10 @@ async function run(): Promise<void> {
|
||||
if (enableCache) {
|
||||
await restoreCache(setupResult.version);
|
||||
}
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
core.setFailed((err as Error).message);
|
||||
}
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
async function setupUv(
|
||||
@@ -61,29 +65,37 @@ async function setupUv(
|
||||
arch: Architecture,
|
||||
versionInput: string,
|
||||
checkSum: string | undefined,
|
||||
githubToken: string | undefined,
|
||||
githubToken: string,
|
||||
): Promise<{ uvDir: string; version: string }> {
|
||||
let installedPath: string | undefined;
|
||||
let cachedToolDir: string;
|
||||
let version: string;
|
||||
if (versionInput === "latest") {
|
||||
const result = await downloadLatest(platform, arch, checkSum, githubToken);
|
||||
version = result.version;
|
||||
cachedToolDir = result.cachedToolDir;
|
||||
const latestResult = await downloadLatest(
|
||||
platform,
|
||||
arch,
|
||||
checkSum,
|
||||
githubToken,
|
||||
);
|
||||
version = latestResult.version;
|
||||
cachedToolDir = latestResult.cachedToolDir;
|
||||
} else {
|
||||
version = versionInput;
|
||||
installedPath = tryGetFromToolCache(arch, versionInput);
|
||||
const toolCacheResult = tryGetFromToolCache(arch, versionInput);
|
||||
version = toolCacheResult.version;
|
||||
installedPath = toolCacheResult.installedPath;
|
||||
if (installedPath) {
|
||||
core.info(`Found uv in tool-cache for ${versionInput}`);
|
||||
return { uvDir: installedPath, version };
|
||||
}
|
||||
cachedToolDir = await downloadVersion(
|
||||
const versionResult = await downloadVersion(
|
||||
platform,
|
||||
arch,
|
||||
versionInput,
|
||||
checkSum,
|
||||
githubToken,
|
||||
);
|
||||
cachedToolDir = versionResult.cachedToolDir;
|
||||
version = versionResult.version;
|
||||
}
|
||||
|
||||
return { uvDir: cachedToolDir, version };
|
||||
@@ -94,6 +106,33 @@ function addUvToPath(cachedPath: string): void {
|
||||
core.info(`Added ${cachedPath} to the path`);
|
||||
}
|
||||
|
||||
function addToolBinToPath(): void {
|
||||
if (toolBinDir !== undefined) {
|
||||
core.exportVariable("UV_TOOL_BIN_DIR", toolBinDir);
|
||||
core.info(`Set UV_TOOL_BIN_DIR to ${toolBinDir}`);
|
||||
core.addPath(toolBinDir);
|
||||
core.info(`Added ${toolBinDir} to the path`);
|
||||
} else {
|
||||
if (process.env.XDG_BIN_HOME !== undefined) {
|
||||
core.addPath(process.env.XDG_BIN_HOME);
|
||||
core.info(`Added ${process.env.XDG_BIN_HOME} to the path`);
|
||||
} else if (process.env.XDG_DATA_HOME !== undefined) {
|
||||
core.addPath(`${process.env.XDG_DATA_HOME}/../bin`);
|
||||
core.info(`Added ${process.env.XDG_DATA_HOME}/../bin to the path`);
|
||||
} else {
|
||||
core.addPath(`${process.env.HOME}/.local/bin`);
|
||||
core.info(`Added ${process.env.HOME}/.local/bin to the path`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setToolDir(): void {
|
||||
if (toolDir !== undefined) {
|
||||
core.exportVariable("UV_TOOL_DIR", toolDir);
|
||||
core.info(`Set UV_TOOL_DIR to ${toolDir}`);
|
||||
}
|
||||
}
|
||||
|
||||
function setCacheDir(cacheLocalPath: string): void {
|
||||
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
|
||||
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as github from "@actions/github";
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import { OWNER, REPO } from "./utils/utils";
|
||||
import { OWNER, REPO } from "./utils/constants";
|
||||
import * as semver from "semver";
|
||||
|
||||
import { updateChecksums } from "./download/checksum/update-known-checksums";
|
||||
|
||||
@@ -1,9 +1,65 @@
|
||||
import * as core from "@actions/core";
|
||||
import path from "node:path";
|
||||
|
||||
export const version = core.getInput("version");
|
||||
export const checkSum = core.getInput("checksum");
|
||||
export const enableCache = core.getInput("enable-cache") === "true";
|
||||
export const cacheSuffix = core.getInput("cache-suffix") || "";
|
||||
export const cacheLocalPath = core.getInput("cache-local-path");
|
||||
export const githubToken = core.getInput("github-token");
|
||||
export const cacheLocalPath = getCacheLocalPath();
|
||||
export const cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
||||
export const pruneCache = core.getInput("prune-cache") === "true";
|
||||
export const toolBinDir = getToolBinDir();
|
||||
export const toolDir = getToolDir();
|
||||
export const githubToken = core.getInput("github-token");
|
||||
|
||||
function getToolBinDir(): string | undefined {
|
||||
const toolBinDirInput = core.getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
return expandTilde(toolBinDirInput);
|
||||
}
|
||||
if (process.platform === "win32") {
|
||||
if (process.env.RUNNER_TEMP !== undefined) {
|
||||
return `${process.env.RUNNER_TEMP}${path.sep}uv-tool-bin-dir`;
|
||||
}
|
||||
throw Error(
|
||||
"Could not determine UV_TOOL_BIN_DIR. Please make sure RUNNER_TEMP is set or provide the tool-bin-dir input",
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getToolDir(): string | undefined {
|
||||
const toolDirInput = core.getInput("tool-dir");
|
||||
if (toolDirInput !== "") {
|
||||
return expandTilde(toolDirInput);
|
||||
}
|
||||
if (process.platform === "win32") {
|
||||
if (process.env.RUNNER_TEMP !== undefined) {
|
||||
return `${process.env.RUNNER_TEMP}${path.sep}uv-tool-dir`;
|
||||
}
|
||||
throw Error(
|
||||
"Could not determine UV_TOOL_DIR. Please make sure RUNNER_TEMP is set or provide the tool-dir input",
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getCacheLocalPath(): string {
|
||||
const cacheLocalPathInput = core.getInput("cache-local-path");
|
||||
if (cacheLocalPathInput !== "") {
|
||||
return expandTilde(cacheLocalPathInput);
|
||||
}
|
||||
if (process.env.RUNNER_TEMP !== undefined) {
|
||||
return `${process.env.RUNNER_TEMP}${path.sep}setup-uv-cache`;
|
||||
}
|
||||
throw Error(
|
||||
"Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input",
|
||||
);
|
||||
}
|
||||
|
||||
function expandTilde(input: string): string {
|
||||
if (input.startsWith("~")) {
|
||||
return `${process.env.HOME}${input.substring(1)}`;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user