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

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
A `semantic-release` plugin to update the bazel module version specified in `MODULE.bazel`
Matthew Clarkson's avatar
Matthew Clarkson committed

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
| Step | Description |
| ---- | ----------- |
| verifyConditions | Verify that `MODULE.bazel` exists, `module.version` is specified in it and is writable. |
| prepare | Updates the version specified by `module.version` following semantic versioning. |
Matthew Clarkson's avatar
Matthew Clarkson committed

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
## Getting Started
Matthew Clarkson's avatar
Matthew Clarkson committed

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
```sh
npm config set always-auth true
npm config set @semantic-release:registry https://gitlab.gpu.arm.com/api/v4/packages/npm/
npm config set -- '//gitlab.gpu.arm.com/api/v4/packages/npm/:_authToken' '${GITLAB_TOKEN}'
export GITLAB_TOKEN="<personal-access-token>"
npm install --save-dev @semantic-release/bzlmod
Matthew Clarkson's avatar
Matthew Clarkson committed
```

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

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
```yaml
plugins:
  - "@semantic-release/bzlmod"
```
Matthew Clarkson's avatar
Matthew Clarkson committed

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
## Configuration
Matthew Clarkson's avatar
Matthew Clarkson committed

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
By default the plugin will locate `MODULE.bazel` in the current package root `.`
Matthew Clarkson's avatar
Matthew Clarkson committed

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
The path to `MODULE.bazel` can be specified in the plugin configuration. 
Matthew Clarkson's avatar
Matthew Clarkson committed

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
For example, to specify `MODULE.bazel` in `./custom/`, do:
Matthew Clarkson's avatar
Matthew Clarkson committed

Zhen Yuen Chong's avatar
Zhen Yuen Chong committed
```yaml
plugins:
  - path: "@semantic-release/bzlmod"
    filepath:
      - "./custom/MODULE.bazel"
```
Matthew Clarkson's avatar
Matthew Clarkson committed

### `source`

The plugin can automatically create a `source.json` which can be used to integrate with `bzlmod`.

The `prefix` and `url` must be specified:

```yaml
plugins:
  - path: "@semantic-release/bzlmod"
    source:
      prefix: ${CI_PROJECT_NAME}-${nextRelease.version}
      url: ${CI_PROJECT_URL}/-/archive/${CI_PROJECT_NAME}/${version}/${CI_PROJECT_NAME}-${version}.tar
```

This will generate a `source.json` that can be uploaded as part of a GitLab release:

```yaml
plugins:
  - path: "@semantic-release/gitlab"
    assets: 
      - path: MODULE.bazel
        type: package
        filepath: /modules/${env.CI_PROJECT_NAME}/${nextRelease.version}/MODULE.bazel
      - path: source.json
        type: package
        filepath: /modules/${env.CI_PROJECT_NAME}/${nextRelease.version}/source.json
```

`bzlmod` can then be pointed directly at the GitLab release to use the project.

Set the `--registry` to the release URL.

[bzlmod]: https://bazel.build/build/bzlmod