remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/apps/remix-ide/ci/update_desktop_release_asse...

77 lines
1.8 KiB

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