Skip to content

Commit

Permalink
Merge pull request #12 from cheton/feature/commitish
Browse files Browse the repository at this point in the history
Support for specifying the commitish value for tag
  • Loading branch information
cheton authored Jun 8, 2019
2 parents 2a19922 + 80b7563 commit eff3932
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ os:
- linux

node_js:
- '8'
- '6'
- '8'
- '10'

before_install:
- npm install -g npm
Expand Down
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-release-cli",
"version": "1.1.0",
"version": "1.2.0",
"description": "A command-line tool for managing release assets on a GitHub repository",
"homepage": "https://github.com/cheton/github-release-cli",
"author": "Cheton Wu <[email protected]>",
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 eff3932

Please sign in to comment.