-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,51 @@ | ||
try { | ||
const createResponse = await github.rest.repos.createRelease({ | ||
generate_release_notes: true, | ||
name: process.env.RELEASE_NAME, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
prerelease: false, | ||
tag_name: process.env.RELEASE_TAG, | ||
body: require('fs').readFileSync('${{ github.workspace }}/release/release-body.md', 'utf8'), | ||
target_commitish: '${{ github.ref_name }}' | ||
}); | ||
async function createRelease({github, context, core}, workspacePath, refName) { | ||
|
||
const files = | ||
[ | ||
{ name: 'OdbDesign-Linux-x64.zip', contentType: 'application/zip' }, | ||
{ name: 'OdbDesign-Linux-x64.zip.sha256sum', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-Linux-x64.zip.asc', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-Windows-x64.zip', contentType: 'application/zip' }, | ||
{ name: 'OdbDesign-Windows-x64.zip.sha256sum', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-Windows-x64.zip.asc', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-MacOS-x64.zip', contentType: 'application/zip' }, | ||
{ name: 'OdbDesign-MacOS-x64.zip.sha256sum', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-MacOS-x64.zip.asc', contentType: 'text/plain' } | ||
]; | ||
|
||
const artifactsPath = '${{ github.workspace }}/artifacts'; | ||
|
||
for (const file of files) { | ||
const filePath = artifactsPath +'/' + file.name; | ||
const uploadResponse = await github.rest.repos.uploadReleaseAsset({ | ||
try { | ||
const createResponse = await github.rest.repos.createRelease({ | ||
generate_release_notes: true, | ||
name: process.env.RELEASE_NAME, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: createResponse.data.id, | ||
name: file.name, | ||
data: require('fs').readFileSync(filePath), | ||
headers: { | ||
'content-type': file.contentType, | ||
'content-length': require('fs').statSync(filePath).size | ||
} | ||
prerelease: false, | ||
tag_name: process.env.RELEASE_TAG, | ||
body: require('fs').readFileSync(workspacePath + '/' + 'release/release-body.md', 'utf8'), | ||
target_commitish: refName | ||
}); | ||
|
||
const files = | ||
[ | ||
{ name: 'OdbDesign-Linux-x64.zip', contentType: 'application/zip' }, | ||
{ name: 'OdbDesign-Linux-x64.zip.sha256sum', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-Linux-x64.zip.asc', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-Windows-x64.zip', contentType: 'application/zip' }, | ||
{ name: 'OdbDesign-Windows-x64.zip.sha256sum', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-Windows-x64.zip.asc', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-MacOS-x64.zip', contentType: 'application/zip' }, | ||
{ name: 'OdbDesign-MacOS-x64.zip.sha256sum', contentType: 'text/plain' }, | ||
{ name: 'OdbDesign-MacOS-x64.zip.asc', contentType: 'text/plain' } | ||
]; | ||
|
||
const artifactsPath = workspacePath + '/' + 'artifacts'; | ||
|
||
for (const file of files) { | ||
const filePath = artifactsPath + '/' + file.name; | ||
const uploadResponse = await github.rest.repos.uploadReleaseAsset({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: createResponse.data.id, | ||
name: file.name, | ||
data: require('fs').readFileSync(filePath), | ||
headers: { | ||
'content-type': file.contentType, | ||
'content-length': require('fs').statSync(filePath).size | ||
} | ||
}); | ||
} | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
|
||
return context.payload.client_payload.value | ||
} | ||
|
||
module.exports = createRelease; |