Skip to content

Commit 23e1c21

Browse files
authored
Initial release (#1)
1 parent 8f436d5 commit 23e1c21

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# bump-request
2+
3+
[Custom action](https://docs.github.com/en//actions/creating-actions/about-custom-actions) to create a pull request that bumps version.
4+
5+
## Usage
6+
7+
Create a workflow file as follows:
8+
9+
```yaml
10+
# .github/workflows/bump-request.yml
11+
name: bump-request
12+
13+
on:
14+
workflow_dispatch:
15+
inputs:
16+
version:
17+
description: Version to change to.
18+
required: true
19+
type: string
20+
21+
jobs:
22+
run:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: r7kamura/bump-request@v0
26+
with:
27+
command: |
28+
npm version --no-git-commit-hooks --no-git-tag-version "${{ inputs.version }}"
29+
version: ${{ inputs.version }}
30+
```
31+
32+
Now you can run it manually via actions page:
33+
34+
![](images/workflow.png)
35+
36+
or if you want to do it from CLI, use [GitHub CLI](https://cli.github.com/) like this:
37+
38+
```bash
39+
gh workflow run bump-request --field version=1.2.3
40+
```
41+
42+
After the action is complete, a new pull request is created.
43+
44+
## Inputs
45+
46+
### `command`
47+
48+
Shell command for modifying files that contain versions such as package.json, Catgo.toml, etc.
49+
50+
- required
51+
52+
NPM package example:
53+
54+
```yaml
55+
command: |
56+
npm version --no-git-commit-hooks --no-git-tag-version "${{ inputs.version }}"
57+
```
58+
59+
Ruby gem example:
60+
61+
```yaml
62+
command: |
63+
sed -i -r 's/([0-9]+\.[0-9]+\.[0-9]+)/${{ inputs.version }}/' lib/my_ruby_gem/version.rb
64+
bundle install
65+
```
66+
67+
### `version`
68+
69+
Version to change to.
70+
71+
- required
72+
- e.g. `1.2.3`
73+
74+
### `gh_pr_create_options`
75+
76+
Additional options for `gh pr create` command.
77+
78+
- optional
79+
- e.g. `--draft`

action.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: bump-request
2+
description: Create a pull request that bumps version.
3+
inputs:
4+
command:
5+
descriotion: Shell command for modifying files that contain versions such as package.json, Catgo.toml, etc.
6+
required: true
7+
gh_pr_create_options:
8+
desecription: Additional options for `gh pr create` command.
9+
required: false
10+
default: ""
11+
github_token:
12+
description: GitHub access token.
13+
required: false
14+
version:
15+
description: Version to change to.
16+
required: true
17+
runs:
18+
using: composite
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: Run command
22+
run: |
23+
${{ inputs.command }}
24+
shell: bash
25+
- name: Create pull request
26+
run: |
27+
description=$(
28+
gh api \
29+
--method POST \
30+
-H "Accept: application/vnd.github+json" \
31+
-f tag_name='v${{ inputs.version }}' \
32+
-f target_commitish='${{ github.ref }}' \
33+
--jq '.name + "\n\n" + .body' \
34+
/repos/${{ github.repository }}/releases/generate-notes
35+
)
36+
branch="bump-request-${GITHUB_RUN_ID}"
37+
git config user.name "${GITHUB_ACTOR}"
38+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
39+
git switch --create "${branch}"
40+
git add .
41+
git commit --message "${description}"
42+
git push --set-upstream origin "${branch}"
43+
gh pr create --fill ${{ inputs.gh_pr_create_options }}
44+
env:
45+
GITHUB_TOKEN: ${{ inputs.github_token || github.token }}
46+
shell: bash
47+
branding:
48+
color: blue
49+
icon: git-pull-request

0 commit comments

Comments
 (0)