This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 306
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
5 changed files
with
108 additions
and
99 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const core = require('@actions/core'); | ||
const { GitHub, context } = require('@actions/github'); | ||
|
||
async function run() { | ||
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 owner and repo from context of payload that triggered the action | ||
const { owner, repo } = context.repo; | ||
|
||
// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs | ||
const tagName = core.getInput('tag_name', { required: true }); | ||
|
||
// This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15' | ||
const tag = tagName.replace('refs/tags/', ''); | ||
const releaseName = core.getInput('release_name', { required: true }).replace('refs/tags/', ''); | ||
const draft = core.getInput('draft', { required: false }) === 'true'; | ||
const prerelease = core.getInput('prerelease', { required: false }) === 'true'; | ||
|
||
// Create a release | ||
// API Documentation: https://developer.github.com/v3/repos/releases/#create-a-release | ||
// Octokit Documentation: https://octokit.github.io/rest.js/#octokit-routes-repos-create-release | ||
const createReleaseResponse = await github.repos.createRelease({ | ||
owner, | ||
repo, | ||
tag_name: tag, | ||
name: releaseName, | ||
draft, | ||
prerelease | ||
}); | ||
|
||
// Get the ID, html_url, and upload URL for the created Release from the response | ||
const { | ||
data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl } | ||
} = createReleaseResponse; | ||
|
||
// Set the output variables for use by other actions: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs | ||
core.setOutput('id', releaseId); | ||
core.setOutput('html_url', htmlUrl); | ||
core.setOutput('upload_url', uploadUrl); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
module.exports = run; |
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