Skip to content

Commit

Permalink
feat: add option to create release PR as draft (#42)
Browse files Browse the repository at this point in the history
* feat: add option to create PR as draft

* chore: fix linting

* chore: bump ncc
  • Loading branch information
sparten11740 authored Mar 25, 2024
1 parent 5bc3d09 commit 3828ca7
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 15 deletions.
4 changes: 3 additions & 1 deletion dist/publish/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/publish/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/version-dispatch/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/version-dispatch/index.js.map

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions dist/version/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/version/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/node": "^18.6.3",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"@vercel/ncc": "^0.34.0",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.56.0",
"eslint-import-resolver-typescript": "^2.7.1",
"husky": "^8.0.3",
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum Input {
VersionExtraArgs = 'version-extra-args',
VersionStrategy = 'version-strategy',
AutoMerge = 'auto-merge',
Draft = 'draft',
RequestReviewers = 'request-reviewers',
DefaultBranch = 'default-branch',
}
Expand Down
3 changes: 3 additions & 0 deletions src/utils/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type CreatePullRequestsParams = {
body?: string
labels?: string[]
autoMerge?: boolean
draft?: boolean
reviewers?: string[]
}

Expand All @@ -38,6 +39,7 @@ export async function createPullRequest({
labels,
assignees,
autoMerge,
draft,
reviewers,
}: CreatePullRequestsParams) {
core.debug(`Creating pull request in ${repo.owner}/${repo.owner} with base branch ${base}`)
Expand All @@ -47,6 +49,7 @@ export async function createPullRequest({
head,
base,
body,
draft,
})

const promises = []
Expand Down
11 changes: 9 additions & 2 deletions src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { assertStrategy, validateAllowedStrategies, VersionStrategy } from './ve
import updateChangelog from './version/update-changelog'
import closePreviousPrs from './version/close-previous-prs'
import { unwrapErrorMessage } from './utils/errors'
import * as assert from 'assert'

if (require.main === module) {
version().catch((error: Error) => {
Expand All @@ -41,11 +42,16 @@ export default async function version({
token = core.getInput(Input.GithubToken, { required: true }),
versionExtraArgs = core.getInput(Input.VersionExtraArgs),
versionStrategy = core.getInput(Input.VersionStrategy),
autoMerge = core.getInput(Input.AutoMerge) === 'true',
requestReviewers = core.getInput(Input.RequestReviewers) === 'true',
autoMerge = core.getBooleanInput(Input.AutoMerge),
draft = core.getBooleanInput(Input.Draft),
requestReviewers = core.getBooleanInput(Input.RequestReviewers),
assignee = core.getInput(Input.Assignee),
} = {}) {
assertStrategy(versionStrategy)
assert(
!(draft && autoMerge),
'A pull-request can either be created as draft, or with auto-merge enabled, but not both at the same time.'
)

const { actor, repo } = github.context
assignee = assignee || actor
Expand Down Expand Up @@ -113,6 +119,7 @@ export default async function version({
core.info('Creating PR')
const pullRequest = await createPullRequest({
client,
draft,
base: defaultBranch,
repo,
packages,
Expand Down
3 changes: 3 additions & 0 deletions src/version/create-pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Params = {
labels?: string[]
assignees?: string[]
autoMerge?: boolean
draft?: boolean
requestReviewers?: boolean
}

Expand All @@ -26,6 +27,7 @@ export default async function createPullRequest({
labels,
assignees,
autoMerge,
draft,
requestReviewers,
}: Params) {
const packageNames = packages.map((it) => path.basename(it))
Expand All @@ -45,6 +47,7 @@ export default async function createPullRequest({
labels,
assignees,
autoMerge,
draft,
reviewers: requestReviewers ? assignees : undefined,
})
}
3 changes: 3 additions & 0 deletions version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
request-reviewers:
description: 'Request PR assignees as reviewers'
default: true
draft:
description: 'Creates the release PR as draft'
default: false

runs:
using: 'node20'
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ __metadata:
"@types/node": ^18.6.3
"@typescript-eslint/eslint-plugin": ^5.21.0
"@typescript-eslint/parser": ^5.21.0
"@vercel/ncc": ^0.34.0
"@vercel/ncc": ^0.38.1
conventional-changelog-conventionalcommits: ^5.0.0
conventional-changelog-core: ^4.2.4
eslint: ^8.56.0
Expand Down Expand Up @@ -1793,14 +1793,14 @@ __metadata:
languageName: node
linkType: hard

"@vercel/ncc@npm:^0.34.0":
version: 0.34.0
resolution: "@vercel/ncc@npm:0.34.0"
"@vercel/ncc@npm:^0.38.1":
version: 0.38.1
resolution: "@vercel/ncc@npm:0.38.1"
dependencies:
node-gyp: latest
bin:
ncc: dist/ncc/cli.js
checksum: 3282578e990572759454f7f8d7ef025f2ae060b261fcb28a96d165350e3665438dc8fb72caf122081d6c57277e4899dab30ea0d8759bfd90baf37286cb887597
checksum: a522bb44c25a65db89941b08ca5817794b6920052f09a9cbd202cc987b81c13dd48cad9aa3b06793fc47ef70ae87fa0b85caf5b6a73e95de8091818049ed6194
languageName: node
linkType: hard

Expand Down

0 comments on commit 3828ca7

Please sign in to comment.