bazelbuild / bazelbuild/bazel

Add `bazel update` to update WORKSPACE package versions

Open
#10,332 12 comments 8 reactions 0 assignees View on GitHub
not stale P4 team-ExternalDeps type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 16h
Merged PRs (30d)
72

Description

It would be useful to add a `bazel update` command to update `WORKSPACE` package versions and shasums, this would apply to `http_archive()` and `git_repository()` functions.

It would also be nice to be able to update the bazel version in the `.bazelversion` file to the latest stable version, but maybe that should be a `bazelisk` issue.

Updating versions of rules is currently a manual process. This should become easier with the bazel federation, but it still involves changing two different shasums, even if you have no other dependencies (unlikely):

```python
http_archive(
name = "bazel_federation",
# Sha of archive zip.
sha256 = "9d4fdf7cc533af0b50f7dd8e58bea85df3b4454b7ae00056d7090eb98e3515cc",
# Sha of git commit.
strip_prefix = "bazel-federation-130c84ec6d60f31b711400e8445a8d0d4a2b5de8",
type = "zip",
url = "https://github.com/bazelbuild/bazel-federation/archive/130c84ec6d60f31b711400e8445a8d0d4a2b5de8.zip",
)
```

Most package management systems have an automated way to update their dependencies (e.g. `npm update`, `cargo update`). The [pinning rules in `rules_jvm_external`](https://github.com/bazelbuild/rules_jvm_external#pinning-artifacts-and-integration-with-bazels-downloader) also support automated updates.

To do this we would have to recognise certain URL types (like `https://.*\.github\.com/.*/archive/[a-f0-9]{40}\.zip`), and know how to query GitHub for the latest version.

If this belongs somewhere else like bazelisk, buildifier, or gazelle, then let me know, but it seems like something quite core to bazel.

### What's the output of `bazel info release`?

`release 1.2.0`

### Have you found anything relevant by searching the web?

No. I feel like this must have been discussed somewhere before, but I couldn't find anything.

Contributor guide

Open the contributing guide

Research direction

Start with the WORKSPACE examples using http_archive() and git_repository(), and investigate the existing Bazel command and repository-rule entry points. Clarify whether Bazel, bazelisk, buildifier, or gazelle should own the feature; done should include a defined way to update package versions and shasums, with the .bazelversion update decision resolved.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.