Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create pre-release when release PR labelled as 'autorelease: pre-rele… #10

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 33 additions & 26 deletions __snapshots__/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Options:
--release-label set a pull request label other than
"autorelease: tagged"
[string] [default: "autorelease: tagged"]
--prerelease-label set a pre-release pull request label other than
"autorelease: pre-release"
[string] [default: "autorelease: pre-release"]
--snapshot-label set a java snapshot pull request label other
than "autorelease: snapshot"
[string] [default: "autorelease: snapshot"]
Expand Down Expand Up @@ -122,43 +125,47 @@ release-please manifest-release
create releases/tags from last release-PR using a manifest file

Options:
--help Show help [boolean]
--version Show version number [boolean]
--debug print verbose errors (use only for local debugging).
--help Show help [boolean]
--version Show version number [boolean]
--debug print verbose errors (use only for local debugging).
[boolean] [default: false]
--trace print extra verbose errors (use only for local debugging).
--trace print extra verbose errors (use only for local debugging).
[boolean] [default: false]
--plugin load plugin named release-please-<plugin-name>
--plugin load plugin named release-please-<plugin-name>
[array] [default: []]
--token GitHub token with repo write permissions
--api-url URL to use when making API requests
--token GitHub token with repo write permissions
--api-url URL to use when making API requests
[string] [default: "https://api.github.com"]
--graphql-url URL to use when making GraphQL requests
--graphql-url URL to use when making GraphQL requests
[string] [default: "https://api.github.com"]
--default-branch The branch to open release PRs against and tag releases on
--default-branch The branch to open release PRs against and tag releases on
[deprecated: use --target-branch instead] [string]
--target-branch The branch to open release PRs against and tag releases on
--target-branch The branch to open release PRs against and tag releases on
[string]
--repo-url GitHub URL to generate release for [required]
--dry-run Prepare but do not take action [boolean] [default: false]
--use-graphql Whether or not the GraphQL API should be used. If false, the
REST API will be used instead. [boolean] [default: true]
--draft mark release as a draft. no tag is created but tag_name and
target_commitish are associated with the release for future
tag creation upon "un-drafting" the release.
--repo-url GitHub URL to generate release for [required]
--dry-run Prepare but do not take action [boolean] [default: false]
--use-graphql Whether or not the GraphQL API should be used. If false,
the REST API will be used instead.
[boolean] [default: true]
--draft mark release as a draft. no tag is created but tag_name
and target_commitish are associated with the release for
future tag creation upon "un-drafting" the release.
[boolean] [default: false]
--prerelease mark release that have prerelease versions as as a
prerelease on Github [boolean] [default: false]
--label comma-separated list of labels to remove to from release PR
[default: "autorelease: pending"]
--release-label set a pull request label other than "autorelease: tagged"
--prerelease mark release that have prerelease versions as as a
prerelease on Github [boolean] [default: false]
--label comma-separated list of labels to remove to from release
PR [default: "autorelease: pending"]
--release-label set a pull request label other than "autorelease: tagged"
[string] [default: "autorelease: tagged"]
--snapshot-label set a java snapshot pull request label other than
"autorelease: snapshot"
--prerelease-label set a pre-release pull request label other than
"autorelease: pre-release"
[string] [default: "autorelease: pre-release"]
--snapshot-label set a java snapshot pull request label other than
"autorelease: snapshot"
[string] [default: "autorelease: snapshot"]
--config-file where can the config file be found in the project?
--config-file where can the config file be found in the project?
[default: "release-please-config.json"]
--manifest-file where can the manifest file be found in the project?
--manifest-file where can the manifest file be found in the project?
[default: ".release-please-manifest.json"]
`

Expand Down
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Extra options:
## Creating/updating release PRs

```bash
release-please release-pr
release-please release-pr
--token=$GITHUB_TOKEN \
--repo-url=<owner>/<repo> [extra options]
```
Expand Down
72 changes: 58 additions & 14 deletions schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
"type": "boolean"
}
},
"required": ["type", "section"]
"required": [
"type",
"section"
]
}
},
"release-as": {
Expand Down Expand Up @@ -81,7 +84,10 @@
"changelog-type": {
"description": "The type of changelog to use. Defaults to `default`.",
"type": "string",
"enum": ["default", "github"]
"enum": [
"default",
"github"
]
},
"changelog-host": {
"description": "Generate changelog links to this GitHub host. Useful for running against GitHub Enterprise.",
Expand Down Expand Up @@ -122,7 +128,11 @@
"properties": {
"type": {
"description": "The file format type.",
"enum": ["json", "toml", "yaml"]
"enum": [
"json",
"toml",
"yaml"
]
},
"path": {
"description": "The path to the file.",
Expand All @@ -137,15 +147,21 @@
"type": "string"
}
},
"required": ["type", "path", "jsonpath"]
"required": [
"type",
"path",
"jsonpath"
]
},
{
"description": "An extra XML file with a targeted update via xpath.",
"type": "object",
"properties": {
"type": {
"description": "The file format type.",
"enum": ["xml"]
"enum": [
"xml"
]
},
"path": {
"description": "The path to the file.",
Expand All @@ -160,15 +176,21 @@
"type": "string"
}
},
"required": ["type", "path", "xpath"]
"required": [
"type",
"path",
"xpath"
]
},
{
"description": "An extra pom.xml file.",
"type": "object",
"properties": {
"type": {
"description": "The file format type.",
"enum": ["pom"]
"enum": [
"pom"
]
},
"path": {
"description": "The path to the file.",
Expand All @@ -179,7 +201,10 @@
"type": "boolean"
}
},
"required": ["type", "path"]
"required": [
"type",
"path"
]
}
]
}
Expand Down Expand Up @@ -256,7 +281,9 @@
"type": {
"description": "The name of the plugin.",
"type": "string",
"enum": ["linked-versions"]
"enum": [
"linked-versions"
]
},
"groupName": {
"description": "The name of the group of components.",
Expand All @@ -281,7 +308,11 @@
}
}
},
"required": ["type", "groupName", "components"]
"required": [
"type",
"groupName",
"components"
]
},
{
"description": "Configuration for various `workspace` plugins.",
Expand All @@ -290,7 +321,11 @@
"type": {
"description": "The name of the plugin.",
"type": "string",
"enum": ["cargo-workspace", "maven-workspace", "node-workspace"]
"enum": [
"cargo-workspace",
"maven-workspace",
"node-workspace"
]
},
"updateAllPackages": {
"description": "Whether to force updating all packages regardless of the dependency tree. Defaults to `false`.",
Expand All @@ -313,7 +348,9 @@
"type": {
"description": "The name of the plugin.",
"type": "string",
"enum": ["group-priority"]
"enum": [
"group-priority"
]
},
"groups": {
"description": "Group names ordered with highest priority first.",
Expand Down Expand Up @@ -360,9 +397,15 @@
"release-label": {
"description": "Comma-separated list of labels to add to a pull request that has been released/tagged",
"type": "string"
},
"prerelease-label": {
"description": "Comma-separated list of labels to add to a pull request to denote the release should be marked as pre-release",
"type": "string"
}
},
"required": ["packages"]
"required": [
"packages"
]
}
],
"properties": {
Expand All @@ -388,6 +431,7 @@
"draft-pull-request": true,
"label": true,
"release-label": true,
"prerelease-label": true,
"extra-label": true,
"include-component-in-tag": true,
"include-v-in-tag": true,
Expand All @@ -404,4 +448,4 @@
"initial-version": true,
"exclude-paths": true
}
}
}
10 changes: 10 additions & 0 deletions src/bin/release-please.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ interface ReleaseArgs {
draft?: boolean;
prerelease?: boolean;
releaseLabel?: string;
prereleaseLabel?: string;
snapshotLabel?: string;
label?: string;
}
Expand Down Expand Up @@ -227,6 +228,12 @@ function releaseOptions(yargs: yargs.Argv): yargs.Argv {
default: 'autorelease: tagged',
type: 'string',
})
.option('prerelease-label', {
describe:
'set a pre-release pull request label other than "autorelease: pre-release"',
default: 'autorelease: pre-release',
type: 'string',
})
.option('snapshot-label', {
describe:
'set a java snapshot pull request label other than "autorelease: snapshot"',
Expand Down Expand Up @@ -887,6 +894,9 @@ function extractManifestOptions(
if ('releaseLabel' in argv && argv.releaseLabel) {
manifestOptions.releaseLabels = argv.releaseLabel.split(',');
}
if ('prereleaseLabel' in argv && argv.prereleaseLabel) {
manifestOptions.prereleaseLabels = argv.prereleaseLabel.split(',');
}
if ('snapshotLabel' in argv && argv.snapshotLabel) {
manifestOptions.snapshotLabels = argv.snapshotLabel.split(',');
}
Expand Down
34 changes: 34 additions & 0 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1976,6 +1976,40 @@ export class GitHub {
force: true,
});
}

async getLabels(): Promise<string[]> {
const {owner, repo} = this.repository;
this.logger.info(`Fetch labels from repo ${owner}/${repo}`);
const labels: string[] = [];
for await (const page of this.octokit.paginate.iterator(
'GET /repos/{owner}/{repo}/labels',
{
owner,
repo,
}
)) {
for (const label of page.data) {
labels.push(label.name);
}
}
this.logger.debug(`Found ${labels.length} labels: ${labels.join(', ')}`);
return labels;
}

async createLabels(labels: string[]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what permissions are needed for this to work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I need to check...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Can you double check with a test repo just to make sure? (I'm fairly paranoid about GitHub doing weird things)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I will double check, I don't want to break the whole CI

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm, that seems to work with only Pull Request or only Issues as writeable :)

const {owner, repo} = this.repository;
for (const label of labels) {
this.logger.info(`Creating label '${label}' for repo ${owner}/${repo}`);
await this.request('POST /repos/{owner}/{repo}/labels', {
owner,
repo,
name: label,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
},
});
}
}
}

/**
Expand Down
Loading
Loading