Skip to content

Commit a5c75f7

Browse files
committed
fix: use @octokit/request
1 parent ae10c4d commit a5c75f7

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

deps.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export * as colors from "jsr:@std/fmt@1.0.3/colors";
22
export * as semver from "jsr:@std/semver@1.0.3";
3-
export { Octokit } from "npm:@octokit/core@6.1.2";
4-
export { restEndpointMethods } from "npm:@octokit/plugin-rest-endpoint-methods@13.2.6";
3+
export { request } from "npm:@octokit/request@9.1.3";
54
export { default as parseRepo } from "npm:parse-repo@1.0.4";
65
export { run } from "jsr:@hugojosefson/run-simple@2.3.7";
76
export { assert } from "jsr:@std/assert@1.0.8";

github.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Octokit, restEndpointMethods } from "./deps.ts";
1+
import { request } from "./deps.ts";
22
import git from "./git.ts";
33

44
export interface Commits {
@@ -50,23 +50,24 @@ export default {
5050
async release(nextVer: string, commits: Commits): Promise<string> {
5151
const { owner, repo } = await git.repoInfo();
5252

53-
const restOctokit = Octokit.plugin(restEndpointMethods);
54-
const octokit = new restOctokit({
55-
auth: Deno.env.get("GITHUB_TOKEN"),
56-
});
53+
// Get the GitHub token from environment variables
54+
const token = Deno.env.get("GITHUB_TOKEN");
55+
if (!token) {
56+
throw new Error("GITHUB_TOKEN environment variable is not set.");
57+
}
5758

58-
const res = await octokit.rest.repos.createRelease({
59+
// Create a new release using the 'request' function
60+
const res = await request("POST /repos/{owner}/{repo}/releases", {
61+
headers: {
62+
authorization: `token ${token}`,
63+
},
5964
owner,
6065
repo,
6166
name: nextVer,
6267
tag_name: nextVer,
6368
body: generateNotes(nextVer, commits),
6469
});
6570

66-
if (res.status !== 201) {
67-
throw new Error(`GitHub release failed: ${res.status}`);
68-
}
69-
7071
return res.data.html_url;
7172
},
7273
};

0 commit comments

Comments
 (0)