Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
actions
/
create-release
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security
Insights
Files
818a8f0
.github
dist
src
create-release.js
main.js
tests
.eslintrc
.gitignore
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
action.yml
package-lock.json
package.json
Breadcrumbs
create-release
/
src
/
create-release.js
Blame
Blame
Latest commit
History
History
64 lines (55 loc) · 2.64 KB
Breadcrumbs
create-release
/
src
/
create-release.js
Top
File metadata and controls
Code
Blame
64 lines (55 loc) · 2.64 KB
Raw
const core = require('@actions/core'); const { GitHub, context } = require('@actions/github'); const fs = require('fs'); 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: currentOwner, repo: currentRepo } = 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: false }).replace('refs/tags/', ''); const body = core.getInput('body', { required: false }); const draft = core.getInput('draft', { required: false }) === 'true'; const prerelease = core.getInput('prerelease', { required: false }) === 'true'; const commitish = core.getInput('commitish', { required: false }) || context.sha; const bodyPath = core.getInput('body_path', { required: false }); const owner = core.getInput('owner', { required: false }) || currentOwner; const repo = core.getInput('repo', { required: false }) || currentRepo; let bodyFileContent = null; if (bodyPath !== '' && !!bodyPath) { try { bodyFileContent = fs.readFileSync(bodyPath, { encoding: 'utf8' }); } catch (error) { core.setFailed(error.message); } } // 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, body: bodyFileContent || body, draft, prerelease, target_commitish: commitish }); // 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;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
You can’t perform that action at this time.