parent
70509f8754
commit
47577dd30c
@ -1,65 +1,77 @@ |
|||||||
import { Octokit } from 'octokit' |
import { Octokit } from 'octokit' |
||||||
|
import * as fs from 'fs' |
||||||
|
import * as path from 'path' |
||||||
|
|
||||||
const owner = 'bunsenstraat' |
const owner = 'bunsenstraat' |
||||||
const repo = 'remix-desktop' |
const repo = 'remix-desktop' |
||||||
const headers = { |
const headers = { |
||||||
'X-GitHub-Api-Version': '2022-11-28' |
'X-GitHub-Api-Version': '2022-11-28' |
||||||
} |
} |
||||||
|
|
||||||
const octokit = new Octokit({ |
const octokit = new Octokit({ |
||||||
auth: process.env.GH_TOKEN |
auth: process.env.GH_TOKEN |
||||||
}) |
}) |
||||||
|
|
||||||
|
|
||||||
async function getAllReleases() { |
async function getAllReleases() { |
||||||
const releases = await octokit.request('GET /repos/{owner}/{repo}/releases', { |
const releases = await octokit.request('GET /repos/{owner}/{repo}/releases', { |
||||||
owner: owner, |
owner: owner, |
||||||
repo: repo, |
repo: repo, |
||||||
headers: headers |
headers: headers |
||||||
}) |
}) |
||||||
return releases.data |
return releases.data |
||||||
} |
} |
||||||
|
|
||||||
async function getVersionFromPackageJson() { |
async function getVersionFromPackageJson() { |
||||||
const packageJson = require(__dirname + '/../../../apps/remixdesktop/package.json') |
// ignore ts error
|
||||||
return packageJson.version |
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const packageJson = require(__dirname + '/../../../apps/remixdesktop/package.json') |
||||||
|
return packageJson.version |
||||||
} |
} |
||||||
|
|
||||||
async function getReleaseByTag(tag_name: string) { |
async function getReleaseByTag(tag_name: string) { |
||||||
const releases = await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', { |
const releases = await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', { |
||||||
owner: owner, |
owner: owner, |
||||||
repo: repo, |
repo: repo, |
||||||
tag: tag_name, |
tag: tag_name, |
||||||
headers: headers |
headers: headers |
||||||
}) |
}) |
||||||
return releases.data |
return releases.data |
||||||
} |
} |
||||||
|
|
||||||
async function getReleaseAssets(release_id: number) { |
async function getReleaseAssets(release_id: number) { |
||||||
const assets = await octokit.request('GET /repos/{owner}/{repo}/releases/{release_id}/assets', { |
const assets = await octokit.request('GET /repos/{owner}/{repo}/releases/{release_id}/assets', { |
||||||
owner: owner, |
owner: owner, |
||||||
repo: repo, |
repo: repo, |
||||||
release_id: release_id, |
release_id: release_id, |
||||||
headers: headers |
headers: headers |
||||||
}) |
}) |
||||||
|
|
||||||
for (const asset of assets.data) { |
for (const asset of assets.data) { |
||||||
console.log(asset.name) |
console.log(asset.name) |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
|
async function readReleaseFilesFromLocalDirectory() { |
||||||
|
const directoryPath = path.join(__dirname, '../../../release') |
||||||
|
const files = fs.readdirSync(directoryPath) |
||||||
|
console.log(files) |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
async function main() { |
async function main() { |
||||||
const version = await getVersionFromPackageJson() |
const version = await getVersionFromPackageJson() |
||||||
console.log(version) |
console.log(version) |
||||||
const release = await getReleaseByTag('v' + version) |
const release = await getReleaseByTag('v' + version) |
||||||
console.log(release) |
console.log(release) |
||||||
if(!release.draft) { |
if (!release.draft) { |
||||||
console.log('Release is not a draft') |
console.log('Release is not a draft') |
||||||
return |
return |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
main() |
//main()
|
||||||
|
readReleaseFilesFromLocalDirectory() |
||||||
console.log(process.env.GH_TOKEN) |
console.log(process.env.GH_TOKEN) |
||||||
//getReleaseAssets()
|
//getReleaseAssets()
|
Loading…
Reference in new issue