Skip to content

Commit

Permalink
Always use api.github.com (#191)
Browse files Browse the repository at this point in the history
The octokit client would default to the URL of enterprise instances and
then not be able to find the uv repo.

Closes: #188
  • Loading branch information
eifinger authored Dec 11, 2024
1 parent 884a30e commit 3460fe1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
7 changes: 4 additions & 3 deletions dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions dist/update-known-checksums/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/download/download-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import * as core from "@actions/core";
import * as tc from "@actions/tool-cache";
import * as path from "node:path";
import { promises as fs } from "node:fs";
import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants";
import {
GITHUB_COM_API,
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";
Expand Down Expand Up @@ -91,7 +96,7 @@ export async function resolveVersion(
}

async function getAvailableVersions(githubToken: string): Promise<string[]> {
const octokit = github.getOctokit(githubToken);
const octokit = github.getOctokit(githubToken, { baseUrl: GITHUB_COM_API });

const response = await octokit.paginate(octokit.rest.repos.listReleases, {
owner: OWNER,
Expand All @@ -101,7 +106,7 @@ async function getAvailableVersions(githubToken: string): Promise<string[]> {
}

async function getLatestVersion(githubToken: string) {
const octokit = github.getOctokit(githubToken);
const octokit = github.getOctokit(githubToken, { baseUrl: GITHUB_COM_API });

const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({
owner: OWNER,
Expand Down
4 changes: 2 additions & 2 deletions src/update-known-checksums.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as github from "@actions/github";
import * as core from "@actions/core";

import { OWNER, REPO } from "./utils/constants";
import { GITHUB_COM_API, OWNER, REPO } from "./utils/constants";
import * as semver from "semver";

import { updateChecksums } from "./download/checksum/update-known-checksums";
Expand All @@ -10,7 +10,7 @@ async function run(): Promise<void> {
const checksumFilePath = process.argv.slice(2)[0];
const github_token = process.argv.slice(2)[1];

const octokit = github.getOctokit(github_token);
const octokit = github.getOctokit(github_token, { baseUrl: GITHUB_COM_API });

const response = await octokit.paginate(octokit.rest.repos.listReleases, {
owner: OWNER,
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const REPO = "uv";
export const OWNER = "astral-sh";
export const TOOL_CACHE_NAME = "uv";
export const GITHUB_COM_API = "https://api.github.com";

0 comments on commit 3460fe1

Please sign in to comment.