Revert "use the @file mechanism of octokit-5"

This reverts commit e5e4b800aa.
This commit is contained in:
Gabor Greif
2023-01-31 20:23:19 +01:00
parent 9927d3f5ec
commit af306bddfe
2 changed files with 27 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import * as fs from 'fs'
import {Octokit} from '@octokit/core'
import {Endpoints} from '@octokit/types'
import * as core from '@actions/core'
@@ -59,6 +60,14 @@ async function upload_to_release(
overwrite: boolean,
octokit: ReturnType<(typeof github)['getOctokit']>
): Promise<undefined | string> {
const stat = fs.statSync(file)
if (!stat.isFile()) {
core.debug(`Skipping ${file}, since its not a file`)
return
}
const file_size = stat.size
const file_bytes = fs.readFileSync(file).toString('binary')
// Check for duplicates.
const assets: RepoAssetsResp = await octokit.paginate(repoAssets, {
...repo(),
@@ -88,8 +97,13 @@ async function upload_to_release(
const uploaded_asset: UploadAssetResp = await octokit.request(uploadAssets, {
...repo(),
release_id: release.data.id,
url: release.data.upload_url,
name: asset_name,
data: '@' + file
data: file_bytes,
headers: {
'content-type': 'binary/octet-stream',
'content-length': file_size
}
})
return uploaded_asset.data.browser_download_url
}