Skip to content

Commit 3b76f55

Browse files
authored
Merge pull request #30 from uiur/master
Release 2022-11-13 11:07:50
2 parents 60778ad + aaf38bc commit 3b76f55

21 files changed

+12739
-2092
lines changed

.github/workflows/create-pr.js.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ name: Create a pull request for QA
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66

77
jobs:
88
build:
99
runs-on: ubuntu-latest
10-
10+
1111
steps:
12-
- uses: actions/checkout@v2
13-
- name: Use Node.js
14-
uses: actions/setup-node@v2
15-
with:
16-
node-version: 16.x
17-
cache: 'npm'
18-
19-
- run: npm ci
20-
- run: npm run build --if-present
21-
- name: Create a release pull request
22-
env:
23-
GITHUB_PR_RELEASE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24-
25-
run: |
26-
./cli/index.js uiur/github-pr-release
12+
- uses: actions/checkout@v2
13+
- name: Use Node.js
14+
uses: actions/setup-node@v2
15+
with:
16+
node-version: 16.x
17+
cache: "npm"
18+
19+
- run: npm ci
20+
- run: npm run build --if-present
21+
- name: Create a release pull request
22+
env:
23+
GITHUB_PR_RELEASE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
25+
run: |
26+
./cli/index.js uiur/github-pr-release

.github/workflows/node.js.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ name: Node.js CI
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches: [master]
99
pull_request:
10-
branches: [ master ]
10+
branches: [master]
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615

1716
strategy:
@@ -20,12 +19,12 @@ jobs:
2019
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2120

2221
steps:
23-
- uses: actions/checkout@v2
24-
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v2
26-
with:
27-
node-version: ${{ matrix.node-version }}
28-
cache: 'npm'
29-
- run: npm ci
30-
- run: npm run build --if-present
31-
- run: npm test
22+
- uses: actions/checkout@v2
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v2
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
cache: "npm"
28+
- run: npm ci
29+
- run: npm run build --if-present
30+
- run: npm test

.github/workflows/release.js.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: npm publish
22
on:
33
pull_request:
4-
types: [ closed ]
4+
types: [closed]
55

66
# Enable running this workflow manually from the Actions tab
77
workflow_dispatch:
@@ -15,8 +15,8 @@ jobs:
1515
- uses: actions/checkout@v2
1616
- uses: actions/setup-node@v2
1717
with:
18-
node-version: '16.x'
19-
cache: 'npm'
18+
node-version: "16.x"
19+
cache: "npm"
2020
- run: npm ci
2121
- run: npm run build --if-present
2222
- run: npm test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ node_modules
3333
npm-debug.log
3434

3535
test.js
36+
dist

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

README.md

Lines changed: 95 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
11
# github-pr-release
2+
23
[![](https://img.shields.io/npm/v/github-pr-release.svg)](https://www.npmjs.com/package/github-pr-release)
34

4-
Create a release pull request by using Github API. Inspired by [git-pr-release]( https://github.com/motemen/git-pr-release).
5+
Create a release pull request using GitHub API. Inspired by [git-pr-release](https://github.com/motemen/git-pr-release).
56

6-
* No dependency on git. You can easily deploy it to Heroku etc.
7-
* Fast because it uses only Github API.
7+
- No dependency on git. You can easily deploy it to Heroku / AWS Lambda / Google Cloud Functions etc.
8+
- Fast because it uses only Github API.
9+
- Written in JavaScript.
810

911
[![Gyazo](http://i.gyazo.com/7484a59ade4e96ce9a015f1aa817cab8.png)](http://gyazo.com/7484a59ade4e96ce9a015f1aa817cab8)
1012

11-
1213
## Usage
14+
15+
<<<<<<< HEAD
16+
1317
### release(config)
18+
19+
=======
20+
21+
### API: release(config)
22+
23+
> > > > > > > origin/master
24+
1425
Create a release pull request and return Promise.
1526

1627
You must pass a config as an argument.
1728

18-
``` javascript
19-
const release = require('github-pr-release')
29+
```javascript
30+
const release = require("github-pr-release");
2031

2132
const config = {
22-
token: 'your github token',
23-
owner: 'uiur',
24-
repo: 'awesome-web-app',
25-
head: 'master', // optional
26-
base: 'production', // optional
27-
template: '/path/to/template.mustache' // optional
28-
}
33+
token: "your github token",
34+
owner: "uiur",
35+
repo: "awesome-web-app",
36+
head: "master", // optional
37+
base: "production", // optional
38+
template: "/path/to/template.mustache", // optional
39+
};
2940

3041
release(config).then(function (pullRequest) {
3142
// success
3243
// `pullRequest` is an object that github api returns.
3344
// See: https://developer.github.com/v3/pulls/#get-a-single-pull-request
34-
})
45+
});
3546
```
3647

3748
Also, the following environment variables can be used for the config:
@@ -43,18 +54,45 @@ Also, the following environment variables can be used for the config:
4354
- `GITHUB_PR_RELEASE_BASE`
4455
- `GITHUB_PR_RELEASE_ENDPOINT`
4556

57+
### CLI
58+
59+
You can create a release pull request by the following command:
60+
61+
```sh
62+
❯ npx github-pr-release owner/repo --head master --base production
63+
# `GITHUB_PR_RELEASE_TOKEN` is required
64+
```
65+
66+
`--help`:
67+
68+
```
69+
❯ npx github-pr-release --help
70+
Usage: github-pr-release [repo]
71+
72+
Options:
73+
--help Show help [boolean]
74+
--version Show version number [boolean]
75+
--head [default: "master"]
76+
--base [default: "production"]
77+
78+
Examples:
79+
github-pr-release uiur/github-pr-release --head master --base production
80+
```
4681

4782
## Install
83+
4884
```
4985
npm install github-pr-release
5086
```
5187

5288
## Tips
89+
5390
### Pull request titles
5491

5592
If one of pull requests of which consist a release pull request has a title like "Bump to v1.0", the title of the release pull request becomes "Release v1.0". Otherwise, it uses timestamps like "Release 2000-01-01 00:00:00" in local timezone.
5693

5794
### Specify a message format
95+
5896
You can specify a template to change the message format. Pass a template path to `config.template`.
5997

6098
```javascript
@@ -76,6 +114,7 @@ Release {{version}}
76114
```
77115

78116
### GitHub Enterprise
117+
79118
If you use this plugin in GitHub Enterprise, you can specify endpoint domain for GitHub Enterprise.
80119

81120
```javascript
@@ -89,10 +128,43 @@ release({
89128

90129
## Example
91130

131+
### GitHub Actions
132+
133+
Creating release pull requests can be automated using GitHub Actions.
134+
135+
Create `.github/workflows/create-pr-release.yml` with the following content:
136+
137+
```yml
138+
name: Create release pull requests
139+
140+
on:
141+
push:
142+
branches: [master]
143+
144+
jobs:
145+
build:
146+
runs-on: ubuntu-latest
147+
148+
steps:
149+
- uses: actions/checkout@v2
150+
- uses: actions/setup-node@v2
151+
with:
152+
node-version: 16.x
153+
cache: "yarn"
154+
155+
- run: yarn install
156+
- name: Create release pull requests
157+
run: |
158+
npx github-pr-release $GITHUB_REPOSITORY --head master --base production
159+
env:
160+
GITHUB_PR_RELEASE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
161+
```
162+
92163
### hubot
164+
93165
![](http://i.gyazo.com/018755d09bbc857aeafdf48372912d79.png)
94166
95-
``` coffee
167+
```coffee
96168
release = require('github-pr-release')
97169
module.exports = (robot) ->
98170
robot.respond /release/i, (msg) ->
@@ -104,5 +176,13 @@ module.exports = (robot) ->
104176
)
105177
```
106178
179+
## Development
180+
181+
The release flow of github-pr-release is managed with github-pr-release itself.
182+
183+
It creates a release pull request when merging a topic branch or pushing to the main branch.
184+
The update can be published by merging a release pull request.
185+
107186
## License
187+
108188
MIT

cli/index.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
#!/usr/bin/env node
22

3-
const yargs = require('yargs/yargs')
4-
const { hideBin } = require('yargs/helpers')
3+
const yargs = require("yargs/yargs");
4+
const { hideBin } = require("yargs/helpers");
55
const argv = yargs(hideBin(process.argv))
6-
.usage('Usage: $0 [repo]')
7-
.example('$0 uiur/github-pr-release --head master --base production', '')
6+
.usage("Usage: $0 [repo]")
7+
.example("$0 uiur/github-pr-release --head master --base production", "")
88
.demandCommand(1)
9-
.default('head', 'master')
10-
.default('base', 'production')
11-
.argv
9+
.default("head", "master")
10+
.default("base", "production").argv;
1211

13-
const createReleasePR = require('../')
12+
const createReleasePR = require("../");
1413

15-
async function main () {
16-
const repoInput = argv._[0]
17-
const [owner, repo] = repoInput.split('/')
14+
async function main() {
15+
const repoInput = argv._[0];
16+
const [owner, repo] = repoInput.split("/");
1817
const config = {
1918
owner,
2019
repo,
2120
head: argv.head,
22-
base: argv.base
23-
}
21+
base: argv.base,
22+
};
2423

25-
const pullRequest = await createReleasePR(config)
24+
const pullRequest = await createReleasePR(config);
2625

27-
console.log(pullRequest.html_url)
26+
console.log(pullRequest.html_url);
2827
}
2928

30-
main().catch(err => {
31-
console.error(err)
32-
process.exit(1)
33-
})
29+
main().catch((err) => {
30+
console.error(err);
31+
process.exit(1);
32+
});

index.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)