mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-12-17 01:47:07 +00:00
Compare commits
10 Commits
always-fal
...
inline-dis
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6120bf3e89 | ||
|
|
04c950a723 | ||
|
|
d02c4c2d68 | ||
|
|
a4fd982317 | ||
|
|
a05a582c56 | ||
|
|
0e855c90d0 | ||
|
|
d8a276f11f | ||
|
|
59ae1ec55b | ||
|
|
f94ec6bedd | ||
|
|
0313224678 |
0
.git-blame-ignore-revs
Normal file
0
.git-blame-ignore-revs
Normal file
49
.github/workflows/check-dist.yml
vendored
49
.github/workflows/check-dist.yml
vendored
@@ -1,49 +0,0 @@
|
||||
# `dist/index.js` is a special file in Actions.
|
||||
# When you reference an action with `uses:` in a workflow,
|
||||
# `index.js` is the code that will run.
|
||||
# For our project, we generate this file through a build process from other source files.
|
||||
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||
name: Check dist/
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js 20
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Rebuild the dist/ directory
|
||||
run: |
|
||||
npm run build
|
||||
npm run package
|
||||
|
||||
- name: Compare the expected and actual dist/ directories
|
||||
run: |
|
||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff --text -v
|
||||
exit 1
|
||||
fi
|
||||
id: diff
|
||||
|
||||
# If index.js was different than expected, upload the expected version as an artifact
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
9
.github/workflows/codeql-analysis.yml
vendored
9
.github/workflows/codeql-analysis.yml
vendored
@@ -12,13 +12,14 @@
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [main]
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "31 7 * * 3"
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
|
||||
2
.github/workflows/release-drafter.yml
vendored
2
.github/workflows/release-drafter.yml
vendored
@@ -3,10 +3,10 @@ name: Release Drafter
|
||||
|
||||
# yamllint disable-line rule:truthy
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update_release_draft:
|
||||
|
||||
3
.github/workflows/test-cache-windows.yml
vendored
3
.github/workflows/test-cache-windows.yml
vendored
@@ -1,6 +1,9 @@
|
||||
name: "test-cache-windows"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
3
.github/workflows/test-cache.yml
vendored
3
.github/workflows/test-cache.yml
vendored
@@ -1,6 +1,9 @@
|
||||
name: "test-cache"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
3
.github/workflows/test-windows.yml
vendored
3
.github/workflows/test-windows.yml
vendored
@@ -1,6 +1,9 @@
|
||||
name: "test-windows"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -1,6 +1,9 @@
|
||||
name: "test"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
@@ -10,10 +13,12 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Actionlint
|
||||
uses: eifinger/actionlint-action@23c85443d840cd73bbecb9cddfc933cc21649a38 # v1.9.1
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
@@ -23,7 +28,7 @@ jobs:
|
||||
npm run all
|
||||
- name: Make sure no changes from linters are detected
|
||||
run: |
|
||||
git diff --exit-code
|
||||
git diff --exit-code || (echo "::error::Please run 'npm run all' to fix the issues" && exit 1)
|
||||
test-default-version:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@@ -218,6 +223,5 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install latest version
|
||||
uses: ./
|
||||
- run: apk add python3
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
|
||||
2
.github/workflows/update-known-checksums.yml
vendored
2
.github/workflows/update-known-checksums.yml
vendored
@@ -19,7 +19,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@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # v7.0.7
|
||||
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
||||
with:
|
||||
commit-message: "chore: update known checksums"
|
||||
title:
|
||||
|
||||
32
.github/workflows/update-major-minor-tags.yml
vendored
32
.github/workflows/update-major-minor-tags.yml
vendored
@@ -1,7 +1,6 @@
|
||||
---
|
||||
name: Update Major Minor Tags
|
||||
|
||||
# yamllint disable-line rule:truthy
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
@@ -15,5 +14,32 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run Update semver
|
||||
uses: haya14busa/action-update-semver@v1.2.1
|
||||
- name: Update Major Minor Tags
|
||||
run: |
|
||||
set -x
|
||||
|
||||
cd "${GITHUB_WORKSPACE}" || exit
|
||||
|
||||
# Set up variables.
|
||||
TAG="${GITHUB_REF#refs/tags/}" # v1.2.3
|
||||
MINOR="${TAG%.*}" # v1.2
|
||||
MAJOR="${MINOR%.*}" # v1
|
||||
|
||||
if [ "${GITHUB_REF}" = "${TAG}" ]; then
|
||||
echo "This workflow is not triggered by tag push: GITHUB_REF=${GITHUB_REF}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MESSAGE="Release ${TAG}"
|
||||
|
||||
# Set up Git.
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
|
||||
# Update MAJOR/MINOR tag
|
||||
git tag -fa "${MAJOR}" -m "${MESSAGE}"
|
||||
git tag -fa "${MINOR}" -m "${MESSAGE}"
|
||||
|
||||
# Push
|
||||
git push --force origin "${MINOR}"
|
||||
git push --force origin "${MAJOR}"
|
||||
|
||||
21
README.md
21
README.md
@@ -279,6 +279,20 @@ If you want to ignore this, set the `ignore-nothing-to-cache` input to `true`.
|
||||
ignore-nothing-to-cache: true
|
||||
```
|
||||
|
||||
### Ignore empty workdir
|
||||
|
||||
By default, the action will warn if the workdir is empty, because this is usually the case when
|
||||
`actions/checkout` is configured to run after `setup-uv`, which is not supported.
|
||||
|
||||
If you want to ignore this, set the `ignore-empty-workdir` input to `true`.
|
||||
|
||||
```yaml
|
||||
- name: Ignore empty workdir
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
ignore-empty-workdir: true
|
||||
```
|
||||
|
||||
### GitHub authentication token
|
||||
|
||||
This action uses the GitHub API to fetch the uv release artifacts. To avoid hitting the GitHub API
|
||||
@@ -447,6 +461,13 @@ The reason for the warning is, that we have to way to know if this is the first
|
||||
cache key or the user accidentally misconfigured the [cache-dependency-glob](#cache-dependency-glob)
|
||||
or [cache-suffix](#enable-caching) and the cache never gets used.
|
||||
|
||||
### Do I have to run `actions/checkout` before or after `setup-uv`?
|
||||
|
||||
Some workflows need uv but do not need to access the repository content.
|
||||
|
||||
But **if** you need to access the repository content, you have run `actions/checkout` before running `setup-uv`.
|
||||
Running `actions/checkout` after `setup-uv` **is not supported**.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
`setup-uv` was initially written and published by [Kevin Stillhammer](https://github.com/eifinger)
|
||||
|
||||
@@ -45,6 +45,9 @@ inputs:
|
||||
ignore-nothing-to-cache:
|
||||
description: "Ignore when nothing is found to cache."
|
||||
default: "false"
|
||||
ignore-empty-workdir:
|
||||
description: "Ignore when the working directory is empty."
|
||||
default: "false"
|
||||
tool-dir:
|
||||
description: "Custom path to set UV_TOOL_DIR to."
|
||||
required: false
|
||||
|
||||
47308
dist/save-cache/index.js
generated
vendored
47308
dist/save-cache/index.js
generated
vendored
File diff suppressed because one or more lines are too long
59182
dist/setup/index.js
generated
vendored
59182
dist/setup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
54389
dist/update-known-checksums/index.js
generated
vendored
54389
dist/update-known-checksums/index.js
generated
vendored
File diff suppressed because one or more lines are too long
833
package-lock.json
generated
833
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@@ -23,25 +23,26 @@
|
||||
"author": "@eifinger",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^4.0.0",
|
||||
"@actions/cache": "^4.0.2",
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/glob": "^0.5.0",
|
||||
"@actions/io": "^1.1.3",
|
||||
"@actions/tool-cache": "^2.0.2",
|
||||
"@octokit/core": "^6.1.3",
|
||||
"@octokit/plugin-paginate-rest": "^11.4.0",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^13.3.0",
|
||||
"@octokit/core": "^6.1.4",
|
||||
"@octokit/plugin-paginate-rest": "^11.4.3",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^13.3.1",
|
||||
"undici": "^7.5.0",
|
||||
"smol-toml": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/node": "^22.12.0",
|
||||
"@types/node": "^22.13.10",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"jest": "^29.7.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"ts-jest": "^29.2.5",
|
||||
"typescript": "^5.7.3"
|
||||
"ts-jest": "^29.2.6",
|
||||
"typescript": "^5.8.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,107 @@
|
||||
// AUTOGENERATED_DO_NOT_EDIT
|
||||
export const KNOWN_CHECKSUMS: { [key: string]: string } = {
|
||||
"aarch64-apple-darwin-0.6.6":
|
||||
"d0fb047593122746c7529960f8efd5d7d10d2cb230302f71158e9765ad37727b",
|
||||
"aarch64-pc-windows-msvc-0.6.6":
|
||||
"6bb6d5a28e8a181fd5b0046778b97a75c3ec1c5117a058e1961e0f6df9ee2925",
|
||||
"aarch64-unknown-linux-gnu-0.6.6":
|
||||
"37a543598cdb7d8fc9b74e6b1fe1fdf8b9a279c6137c7ff8396a88f69ec7a43c",
|
||||
"aarch64-unknown-linux-musl-0.6.6":
|
||||
"1f11c12ccfb693a6928c097c6b2ae3caa8e073744661795a6c96c5ffa9358f24",
|
||||
"arm-unknown-linux-musleabihf-0.6.6":
|
||||
"6cbd68ca3cef4a9a2f0f5c53492d47596494c82df8f1017df144c37a39d13294",
|
||||
"armv7-unknown-linux-gnueabihf-0.6.6":
|
||||
"97c71ad1f443182b3594ef671624e23f8f7960cb84badbbbda38598457845f83",
|
||||
"armv7-unknown-linux-musleabihf-0.6.6":
|
||||
"bee1941d59c8703fa143e186db1f335324b1922f38201cd52bfdfe1b29062987",
|
||||
"i686-pc-windows-msvc-0.6.6":
|
||||
"2231f24bfe6b8729427a5ecccf0339c5feacf96309f62da51c5077f4cfe8954e",
|
||||
"i686-unknown-linux-gnu-0.6.6":
|
||||
"16667b429a57ee917b10093e81e52956e4c19f9fd73d05dd87c3cbc27779ac7e",
|
||||
"i686-unknown-linux-musl-0.6.6":
|
||||
"96fab088198ef251facccfdf3850139720249f673c937cf6cc21642f54f19894",
|
||||
"powerpc64-unknown-linux-gnu-0.6.6":
|
||||
"564d1207601cdb3a3684f7d3ac31bf40436ac6912df7de340216b30a2e94ca44",
|
||||
"powerpc64le-unknown-linux-gnu-0.6.6":
|
||||
"c2aa7d2686b1f5943a562488153141f9690acfa59d6fdb01a2272019dc4f94dd",
|
||||
"s390x-unknown-linux-gnu-0.6.6":
|
||||
"fe7a1425620325b6063bf8b5c008846bc0ef7c867e7a155049adf5d9c356db2d",
|
||||
"x86_64-apple-darwin-0.6.6":
|
||||
"c584b85e81df8d8ae8142876b80ae977e41c6bba14c57cc1061b6a87f361ad2e",
|
||||
"x86_64-pc-windows-msvc-0.6.6":
|
||||
"72d7866fac1a9f5e895ec632a0b8a98ea59627cb2c3b8e68af4fec899ee4b43b",
|
||||
"x86_64-unknown-linux-gnu-0.6.6":
|
||||
"4c3426c4919d9f44633ab9884827fa1ad64ad8d993516d636eb955a3835c4a8c",
|
||||
"x86_64-unknown-linux-musl-0.6.6":
|
||||
"bcc30541d54156d434a74d6070a44c333263edc65ea423d3039cb8112ed78c95",
|
||||
"aarch64-apple-darwin-0.6.5":
|
||||
"4952c6275778fbc7e5cf6b5739ffd944c47063134d6ea43a7037b0a028ef771e",
|
||||
"aarch64-pc-windows-msvc-0.6.5":
|
||||
"2af20abb3a289d57ae6a8f34ec9f6a60276947fdfb80de6d7304a1b49242cc64",
|
||||
"aarch64-unknown-linux-gnu-0.6.5":
|
||||
"ebf0707ab949b948ad14250ed93f968fec954e20d12ce6bc9fce74b0ce7e4900",
|
||||
"aarch64-unknown-linux-musl-0.6.5":
|
||||
"8e3eae9802c443f87f7519518c9900a323e95a54e47f89433452287d9d2e9d13",
|
||||
"arm-unknown-linux-musleabihf-0.6.5":
|
||||
"85caa3c874d98ae5cb981d13e127602c2063d69874b8fd18ca0d1083805a04b1",
|
||||
"armv7-unknown-linux-gnueabihf-0.6.5":
|
||||
"184051f8cceccaafee109787f5c8f5788ed6e619ad65edc98779a96b3a8782c2",
|
||||
"armv7-unknown-linux-musleabihf-0.6.5":
|
||||
"86c7f7dcd0197c131ecce8f3c34807470753c145e1570cec5f0836e34481af9d",
|
||||
"i686-pc-windows-msvc-0.6.5":
|
||||
"65dac0af6d2f143736e83fe17f5b52546686fa000fb2f1f89dbb26d1c96183db",
|
||||
"i686-unknown-linux-gnu-0.6.5":
|
||||
"beb346c6a869d6e742de8a797fa7c2a489c6cbc3127387e08a9106a944f56dc2",
|
||||
"i686-unknown-linux-musl-0.6.5":
|
||||
"5a254d1f0dc92e00c3f2a9c97f27a1adb1261f841e08f1ed3e4f03dcf45b7c12",
|
||||
"powerpc64-unknown-linux-gnu-0.6.5":
|
||||
"1f8fd8dde91258380dbcd4b9fc65f15a7dc3af6cfffefb9a4f99d32c4c67436d",
|
||||
"powerpc64le-unknown-linux-gnu-0.6.5":
|
||||
"d2b6e19ca7ecd8d7e0d1ddced965aa91a3c822d07a7f7657743945245c1f627a",
|
||||
"s390x-unknown-linux-gnu-0.6.5":
|
||||
"43a3e39f19fd5d098bb8c896b6c0f99a146253c271d78409cf31c2f55f2763d0",
|
||||
"x86_64-apple-darwin-0.6.5":
|
||||
"d336d862694e1c36afea55eb15f5df02aa77c04a168b781df515d641e23285f0",
|
||||
"x86_64-pc-windows-msvc-0.6.5":
|
||||
"a3e9f0913189c38b804bf6bb3d348af305a8ceabc690be92b6e111245a821640",
|
||||
"x86_64-unknown-linux-gnu-0.6.5":
|
||||
"8fc9895719a1291ecd193cb86f9282ff3649cef797d29eacc74c4f573aab1e2f",
|
||||
"x86_64-unknown-linux-musl-0.6.5":
|
||||
"ed4830b7b6293b9413618970b84dad7bc9245f4a7dfa741f943afdb647c196c4",
|
||||
"aarch64-apple-darwin-0.6.4":
|
||||
"1497302e13b33188d6ea4b255520e72f4b9ca9a2c5e9ad30b7bc919e5a0b1071",
|
||||
"aarch64-pc-windows-msvc-0.6.4":
|
||||
"92d18fec3da41dd759ff5c05074445def51d30a325cee0e94d4539fbaabae795",
|
||||
"aarch64-unknown-linux-gnu-0.6.4":
|
||||
"4c78928aa92170bb1c68245da3a5ce0c051e185b7cb6356c33909f94f033ae84",
|
||||
"aarch64-unknown-linux-musl-0.6.4":
|
||||
"fec5583459f22a26eab91aa32cb922cdb7bd72826b3e23c6c164c3814126f462",
|
||||
"arm-unknown-linux-musleabihf-0.6.4":
|
||||
"e9e1ef68e6b316b47a5ee48a48e5b28898a351fb588f0944666b004fa5baed2c",
|
||||
"armv7-unknown-linux-gnueabihf-0.6.4":
|
||||
"65df00771f9d4928853ecb5a627745edc829af3ee1339171c2f53f2afa935323",
|
||||
"armv7-unknown-linux-musleabihf-0.6.4":
|
||||
"f963d53f99ddcf5281b79545cf905dc66a6b25a4a5dcdefaecefd42a63710b88",
|
||||
"i686-pc-windows-msvc-0.6.4":
|
||||
"ecdb47abb3fc29511a2adc9df0407fe604371c6518cd2861235c8aa178928941",
|
||||
"i686-unknown-linux-gnu-0.6.4":
|
||||
"7e8c9c6d1b1c9f43eb50a634742f03c34d87a94d8155d2602f1f23c2c6cbfc22",
|
||||
"i686-unknown-linux-musl-0.6.4":
|
||||
"f3985d87a510c1fded1c8de25c6e70bcc2039e587f17efc5ab328b20c956b224",
|
||||
"powerpc64-unknown-linux-gnu-0.6.4":
|
||||
"81d3430b221d57070af86cdd868d766316266515fa49aa61c660ff1d61e5fa78",
|
||||
"powerpc64le-unknown-linux-gnu-0.6.4":
|
||||
"c8aba58a91854645ee41deeb9b0223c5218231c4d03b5b9cbe17f2ddd2f62358",
|
||||
"s390x-unknown-linux-gnu-0.6.4":
|
||||
"a73197566e1b706a6ca0427556b6d4732185eb6d621f0730d70c165ee5b1395e",
|
||||
"x86_64-apple-darwin-0.6.4":
|
||||
"af09c768697edd009ac1af66eaea35bbd29f145bd9c2c02b8f93309e23670b4f",
|
||||
"x86_64-pc-windows-msvc-0.6.4":
|
||||
"4526b772f5d9b0afdd61a780ab649730d125e0a56348daa7463ee44c0c5e5762",
|
||||
"x86_64-unknown-linux-gnu-0.6.4":
|
||||
"ed38cde84d822c1878c484e560e28c157a1c025204151efa60aa46831500f4d6",
|
||||
"x86_64-unknown-linux-musl-0.6.4":
|
||||
"1b04edff73d7d7f837b9d6a36a556fe2feb59cc9f747c4fcd01f76c886dd3579",
|
||||
"aarch64-apple-darwin-0.6.3":
|
||||
"51b84818bbfe08358a298ba3389c6d448d3ddc0f2601a2d63c5a62cb7b704062",
|
||||
"aarch64-pc-windows-msvc-0.6.3":
|
||||
|
||||
@@ -5,11 +5,7 @@ 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 { Octokit } from "@octokit/core";
|
||||
import { paginateRest } from "@octokit/plugin-paginate-rest";
|
||||
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
|
||||
|
||||
const PaginatingOctokit = Octokit.plugin(paginateRest, restEndpointMethods);
|
||||
import { Octokit } from "../utils/octokit";
|
||||
|
||||
export function tryGetFromToolCache(
|
||||
arch: Architecture,
|
||||
@@ -98,7 +94,7 @@ export async function resolveVersion(
|
||||
|
||||
async function getAvailableVersions(githubToken: string): Promise<string[]> {
|
||||
try {
|
||||
const octokit = new PaginatingOctokit({
|
||||
const octokit = new Octokit({
|
||||
auth: githubToken,
|
||||
});
|
||||
return await getReleaseTagNames(octokit);
|
||||
@@ -107,7 +103,7 @@ async function getAvailableVersions(githubToken: string): Promise<string[]> {
|
||||
core.info(
|
||||
"No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.",
|
||||
);
|
||||
const octokit = new PaginatingOctokit();
|
||||
const octokit = new Octokit();
|
||||
return await getReleaseTagNames(octokit);
|
||||
}
|
||||
throw err;
|
||||
@@ -115,7 +111,7 @@ async function getAvailableVersions(githubToken: string): Promise<string[]> {
|
||||
}
|
||||
|
||||
async function getReleaseTagNames(
|
||||
octokit: InstanceType<typeof PaginatingOctokit>,
|
||||
octokit: InstanceType<typeof Octokit>,
|
||||
): Promise<string[]> {
|
||||
const response = await octokit.paginate(octokit.rest.repos.listReleases, {
|
||||
owner: OWNER,
|
||||
@@ -126,7 +122,7 @@ async function getReleaseTagNames(
|
||||
|
||||
async function getLatestVersion(githubToken: string) {
|
||||
core.debug("Getting latest version...");
|
||||
const octokit = new PaginatingOctokit({
|
||||
const octokit = new Octokit({
|
||||
auth: githubToken,
|
||||
});
|
||||
|
||||
@@ -134,15 +130,14 @@ async function getLatestVersion(githubToken: string) {
|
||||
try {
|
||||
latestRelease = await getLatestRelease(octokit);
|
||||
} catch (err) {
|
||||
if ((err as Error).message.includes("Bad credentials")) {
|
||||
core.info(
|
||||
"No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.",
|
||||
);
|
||||
const octokit = new PaginatingOctokit();
|
||||
latestRelease = await getLatestRelease(octokit);
|
||||
} else {
|
||||
throw err;
|
||||
core.info(
|
||||
"No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.",
|
||||
);
|
||||
if (err instanceof Error) {
|
||||
core.debug(err.message);
|
||||
}
|
||||
const octokit = new Octokit();
|
||||
latestRelease = await getLatestRelease(octokit);
|
||||
}
|
||||
|
||||
if (!latestRelease) {
|
||||
@@ -152,9 +147,7 @@ async function getLatestVersion(githubToken: string) {
|
||||
return latestRelease.tag_name;
|
||||
}
|
||||
|
||||
async function getLatestRelease(
|
||||
octokit: InstanceType<typeof PaginatingOctokit>,
|
||||
) {
|
||||
async function getLatestRelease(octokit: InstanceType<typeof Octokit>) {
|
||||
const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
import {
|
||||
cacheLocalPath,
|
||||
checkSum,
|
||||
ignoreEmptyWorkdir,
|
||||
enableCache,
|
||||
githubToken,
|
||||
pyProjectFile,
|
||||
@@ -30,6 +31,7 @@ import fs from "node:fs";
|
||||
import { getUvVersionFromConfigFile } from "./utils/pyproject";
|
||||
|
||||
async function run(): Promise<void> {
|
||||
detectEmptyWorkdir();
|
||||
const platform = await getPlatform();
|
||||
const arch = getArch();
|
||||
|
||||
@@ -61,6 +63,20 @@ async function run(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
function detectEmptyWorkdir(): void {
|
||||
if (fs.readdirSync(".").length === 0) {
|
||||
if (ignoreEmptyWorkdir) {
|
||||
core.info(
|
||||
"Empty workdir detected. Ignoring because ignore-empty-workdir is enabled",
|
||||
);
|
||||
} else {
|
||||
core.warning(
|
||||
"Empty workdir detected. This may cause unexpected behavior. You can enable ignore-empty-workdir to mute this warning.",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function setupUv(
|
||||
platform: Platform,
|
||||
arch: Architecture,
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
import * as semver from "semver";
|
||||
import * as core from "@actions/core";
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { paginateRest } from "@octokit/plugin-paginate-rest";
|
||||
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
|
||||
import { Octokit } from "./utils/octokit";
|
||||
|
||||
import { OWNER, REPO } from "./utils/constants";
|
||||
|
||||
import { updateChecksums } from "./download/checksum/update-known-checksums";
|
||||
|
||||
const PaginatingOctokit = Octokit.plugin(paginateRest, restEndpointMethods);
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const checksumFilePath = process.argv.slice(2)[0];
|
||||
const github_token = process.argv.slice(2)[1];
|
||||
|
||||
const octokit = new PaginatingOctokit({
|
||||
const octokit = new Octokit({
|
||||
auth: github_token,
|
||||
});
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ export const cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
||||
export const pruneCache = core.getInput("prune-cache") === "true";
|
||||
export const ignoreNothingToCache =
|
||||
core.getInput("ignore-nothing-to-cache") === "true";
|
||||
export const ignoreEmptyWorkdir =
|
||||
core.getInput("ignore-empty-workdir") === "true";
|
||||
export const toolBinDir = getToolBinDir();
|
||||
export const toolDir = getToolDir();
|
||||
export const githubToken = core.getInput("github-token");
|
||||
|
||||
58
src/utils/octokit.ts
Normal file
58
src/utils/octokit.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { Octokit as Core } from "@octokit/core";
|
||||
import type {
|
||||
Constructor,
|
||||
OctokitOptions,
|
||||
} from "@octokit/core/dist-types/types";
|
||||
import {
|
||||
paginateRest,
|
||||
type PaginateInterface,
|
||||
} from "@octokit/plugin-paginate-rest";
|
||||
import { legacyRestEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
|
||||
import { fetch as undiciFetch, ProxyAgent, type RequestInit } from "undici";
|
||||
|
||||
export type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods";
|
||||
|
||||
const DEFAULTS = {
|
||||
baseUrl: "https://api.github.com",
|
||||
userAgent: "setup-uv",
|
||||
};
|
||||
|
||||
export function getProxyAgent() {
|
||||
const httpProxy = process.env.HTTP_PROXY || process.env.http_prox;
|
||||
if (httpProxy) {
|
||||
return new ProxyAgent(httpProxy);
|
||||
}
|
||||
|
||||
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
|
||||
if (httpsProxy) {
|
||||
return new ProxyAgent(httpsProxy);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export const customFetch = async (url: string, opts: RequestInit) =>
|
||||
await undiciFetch(url, {
|
||||
dispatcher: getProxyAgent(),
|
||||
...opts,
|
||||
});
|
||||
|
||||
export const Octokit: typeof Core &
|
||||
Constructor<
|
||||
{
|
||||
paginate: PaginateInterface;
|
||||
} & ReturnType<typeof legacyRestEndpointMethods>
|
||||
> = Core.plugin(paginateRest, legacyRestEndpointMethods).defaults(
|
||||
function buildDefaults(options: OctokitOptions): OctokitOptions {
|
||||
return {
|
||||
...DEFAULTS,
|
||||
...options,
|
||||
request: {
|
||||
fetch: customFetch,
|
||||
...options.request,
|
||||
},
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export type Octokit = InstanceType<typeof Octokit>;
|
||||
Reference in New Issue
Block a user