Skip to content
README.md 2.9 KiB
Newer Older
Matthew Clarkson's avatar
Matthew Clarkson committed
# Bazelisk
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
A `semantic-release` plugin to run [Bazelisk][bazelisk] targets for each
`semantic-release` stage.
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
| Step             | Description                            |
| ---------------- | -------------------------------------- |
| verifyConditions | Runs `//release:verify`, if available  |
| prepare          | Runs `//release:prepare`, if available |
| publish          | Runs `//release:publish`, if available |
| notify           | Runs `//release:notify`, if available  |
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
## Getting Started
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
```sh
npm config --location project set registry https://gitlab.arm.com/api/v4/groups/semantic-release/-/packages/npm/
npm install --save-dev @semantic-release/bazelisk
Matthew Clarkson's avatar
Matthew Clarkson committed
```

Matthew Clarkson's avatar
Matthew Clarkson committed
Add the following to `.releaserc.yaml`:
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
```yaml
plugins:
  - "@semantic-release/bazelisk"
```
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
## Usage
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
Add a `release/BUILD.bazel` file with the stage targets:
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
```py
alias(
    name = "prepare",
    actual = "//some:target",
)
```
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
The `//some:target` would be ran as part of the `prepare` stage.

Custom rules can be written to customise what Bazelisk performs in that stage.

## Configuration

The command and arguments to `bazelisk <command> -- <arguments>` can be
controlled for each stage:

```yaml
plugins:
  - path: "@semantic-release/yq"
    stages:
      verify: "//something:verify"
      prepare:
        - "//something:else"
      publish:
        query: false
        timeout: "60s"
        command:
          - "run"
          - "--stamp"
          - "--embed_label=${nextRelease.version}"
        arguments: "//some:target"
      verify:
        arguments:
        - "//something:upload"
        - "--url=https://somewhere.com/upload/endpoint"
```
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
## `stages[*].command`
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
Can be a string as a convenience for a single element array.
Matthew Clarkson's avatar
Matthew Clarkson committed

Otherwise, an array of arguments to use for the command portion of
Matthew Clarkson's avatar
Matthew Clarkson committed
`bazelisk <command> -- <arguments>`.
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
Defaults to `run`.
Matthew Clarkson's avatar
Matthew Clarkson committed

The command can consume [substitutions] in a [lodash template].
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
## `stages[*].arguments`
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
Can be a string as a convenience for a single element array.
Matthew Clarkson's avatar
Matthew Clarkson committed

Otherwise, an array of arguments to use for the arguments portion of
Matthew Clarkson's avatar
Matthew Clarkson committed
`bazelisk <command> -- <arguments>`.
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
Defaults to `//release:<stage-name>`.
Matthew Clarkson's avatar
Matthew Clarkson committed

The arguments can consume [substitutions] in a [lodash template].
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
# `stages[*].query`
Matthew Clarkson's avatar
Matthew Clarkson committed

Determines if `bazelisk query -- <target>` is ran to detect if the target
exists. If the target is not available, the stage does nothing.
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
The default is `true`.
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
Setting it to `false` will run the command and fail if the target does not
exist.
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
# `stages[*].timeout`
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
Sets the timeout for `bazelisk` executions.
Matthew Clarkson's avatar
Matthew Clarkson committed

Can be anything that [ms] understands (such as `"60s"`, `"1m"`), the number of
milliseconds, `"infinity"` or `"∞"`.
Matthew Clarkson's avatar
Matthew Clarkson committed

Defaults to an unlimited timeout.
Matthew Clarkson's avatar
Matthew Clarkson committed

Matthew Clarkson's avatar
Matthew Clarkson committed
[bazelisk]: https://github.com/bazelbuild/bazelisk
[lodash template]: https://docs-lodash.com/v4/template/
[substitutions]:
  https://semantic-release.gitbook.io/semantic-release/developer-guide/js-api#nextrelease
[ms]: https://www.npmjs.com/package/ms