Skip to content

Commit

Permalink
Add support for specifying the commitish value to be used for a tag
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Jun 8, 2019
1 parent 2a19922 commit 5790c78
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ Options:
-V, --version output the version number
--baseurl <baseurl> API endpoint (default: "https://api.github.com")
-T, --token <token> OAuth2 token
-o, --owner <owner> owner
-r, --repo <repo> repo
-t, --tag <tag> tag
-n, --name <name> name
-b, --body <body> body
-d, --draft [value] draft
-p, --prerelease [value] prerelease
-o, --owner <owner> The repository owner.
-r, --repo <repo> The repository name.
-t, --tag <tag> The name of the tag.
-c, --commitish <value> Specifies the commitish value for tag. Unused if the tag already exists.
-n, --name <name> The name of the release.
-b, --body <body> Text describing the contents of the tag.
-d, --draft [value] `true` makes the release a draft, and `false` publishes the release.
-p, --prerelease [value] `true` to identify the release as a prerelease, `false` to identify the release as a full release.
-h, --help output usage information
```

Expand All @@ -43,6 +44,18 @@ github-release upload \
archive.zip index.html app.min.css app.min.js
```

#### Specify the commitish value for tag

```sh
github-release upload \
--owner cheton \
--repo github-release-cli \
--commitish 6a8e375 \
--tag "v0.1.0" \
--name "v0.1.0" \
--body "The commitish value for tag"
```

#### Create a prerelease

```sh
Expand Down
20 changes: 11 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ program
.usage('<command> [<args>]')
.option('--baseurl <baseurl>', 'API endpoint', 'https://api.github.com')
.option('-T, --token <token>', 'OAuth2 token')
.option('-o, --owner <owner>', 'owner')
.option('-r, --repo <repo>', 'repo')
.option('-t, --tag <tag>', 'tag')
.option('-n, --name <name>', 'name')
.option('-b, --body <body>', 'body')
.option('-d, --draft [value]', 'draft', function(val) {
.option('-o, --owner <owner>', 'The repository owner.')
.option('-r, --repo <repo>', 'The repository name.')
.option('-t, --tag <tag>', 'The name of the tag.')
.option('-c, --commitish <value>', 'Specifies the commitish value for tag. Unused if the tag already exists.')
.option('-n, --name <name>', 'The name of the release.')
.option('-b, --body <body>', 'Text describing the contents of the tag.')
.option('-d, --draft [value]', '`true` makes the release a draft, and `false` publishes the release.', function(val) {
if (String(val).toLowerCase() === 'false') {
return false;
}
return true;
})
.option('-p, --prerelease [value]', 'prerelease', function(val) {
.option('-p, --prerelease [value]', '`true` to identify the release as a prerelease, `false` to identify the release as a full release.', function(val) {
if (String(val).toLowerCase() === 'false') {
return false;
}
Expand Down Expand Up @@ -64,7 +65,7 @@ function next(response) {

const fn = {
'upload': async () => {
const { owner, repo, tag, name, body, draft, prerelease } = program;
const { owner, repo, tag, commitish, name, body, draft, prerelease } = program;
const files = args;
let release;

Expand All @@ -82,11 +83,12 @@ const fn = {

try {
if (!release) {
console.log(`> createRelease: tag_name=${tag}, name=${name || tag}, draft=${!!draft}, prerelease=${!!prerelease}`);
console.log(`> createRelease: tag_name=${tag}, target_commitish=${commitish}, name=${name || tag}, draft=${!!draft}, prerelease=${!!prerelease}`);
const res = await octokit.repos.createRelease({
owner,
repo,
tag_name: tag,
target_commitish: commitish,
name: name || tag,
body: body || '',
draft: !!draft,
Expand Down

0 comments on commit 5790c78

Please sign in to comment.