actions/upload-release-asset
live627 opened this issue · 1 comments
live627 commented
According to actions/upload-release-asset#78, https://github.com/actions/upload-release-asset seems to bee removed from the marketplace, sadly. There is https://github.com/shogo82148/actions-upload-release-asset now, but I think doing a new github-script upon new release would be best.
try {
// Get authenticated GitHub client (Ocktokit): https://github.com/actions/toolkit/tree/master/packages/github#usage
const github = new GitHub(process.env.GITHUB_TOKEN);
// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
const uploadUrl = core.getInput('upload_url', { required: true });
const assetPath = core.getInput('asset_path', { required: true });
const assetName = core.getInput('asset_name', { required: true });
const assetContentType = core.getInput('asset_content_type', { required: true });
// Determine content-length for header to upload asset
const contentLength = filePath => fs.statSync(filePath).size;
// Setup headers for API call, see Octokit Documentation: https://octokit.github.io/rest.js/#octokit-routes-repos-upload-release-asset for more information
const headers = { 'content-type': assetContentType, 'content-length': contentLength(assetPath) };
// Upload a release asset
// API Documentation: https://developer.github.com/v3/repos/releases/#upload-a-release-asset
// Octokit Documentation: https://octokit.github.io/rest.js/#octokit-routes-repos-upload-release-asset
const uploadAssetResponse = await github.repos.uploadReleaseAsset({
url: uploadUrl,
headers,
name: assetName,
file: fs.readFileSync(assetPath)
});
// Get the browser_download_url for the uploaded release asset from the response
const {
data: { browser_download_url: browserDownloadUrl }
} = uploadAssetResponse;
// Set the output variable for use by other actions: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
core.setOutput('browser_download_url', browserDownloadUrl);
} catch (error) {
core.setFailed(error.message);
}