Skip to content

Commit

Permalink
Try another fix 'Cannot access 'octokit' before initialization' in pi…
Browse files Browse the repository at this point in the history
…peline
  • Loading branch information
Exidex committed Jun 15, 2024
1 parent bffae9c commit 9563d03
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions js/build/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ program.command('build-macos')

await program.parseAsync(process.argv);

const repo = { owner: 'project-gauntlet', repo: 'gauntlet' };

async function doBuild(arch: string) {
console.log("Building Gauntlet...")

Expand Down Expand Up @@ -105,12 +103,12 @@ async function undraftRelease(projectRoot: string) {
const version = await readVersion(projectRoot)

const response = await octokit.rest.repos.getReleaseByTag({
...repo,
...getGithubRepo(),
tag: `v${version}`,
});

await octokit.rest.repos.updateRelease({
...repo,
...getGithubRepo(),
release_id: response.data.id,
origin: response.data.upload_url,
draft: false
Expand Down Expand Up @@ -364,7 +362,7 @@ async function createRelease(newVersion: number, releaseNotes: string) {
console.log("Creating github release...")

await octokit.rest.repos.createRelease({
...repo,
...getGithubRepo(),
tag_name: `v${newVersion}`,
target_commitish: 'main',
name: `v${newVersion}`,
Expand All @@ -379,15 +377,15 @@ async function addFileToRelease(projectRoot: string, filePath: string, fileName:
const octokit = getOctokit();

const response = await octokit.rest.repos.getReleaseByTag({
...repo,
...getGithubRepo(),
tag: `v${version}`,
});

const fileBuffer = await readFile(filePath);

console.log("Uploading executable as github release asset...")
await octokit.rest.repos.uploadReleaseAsset({
...repo,
...getGithubRepo(),
release_id: response.data.id,
origin: response.data.upload_url,
name: fileName,
Expand All @@ -403,6 +401,12 @@ function getOctokit() {
auth: process.env.GITHUB_TOKEN,
})
}
function getGithubRepo() {
return {
owner: 'project-gauntlet',
repo: 'gauntlet',
}
}

async function readVersion(projectRoot: string): Promise<number> {
const versionFilePath = path.join(projectRoot, "VERSION");
Expand Down

0 comments on commit 9563d03

Please sign in to comment.