Skip to content

Commit 084caec

Browse files
Avoid hardcoding a version number in Protoc installation instruction documentation.
Closes #295 PiperOrigin-RevId: 904528509
1 parent 927775e commit 084caec

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

content/installation.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,38 @@ to install `protoc`.
1616
To install the latest release of the protocol compiler from pre-compiled
1717
binaries, follow these instructions:
1818

19-
1. From https://github.com/google/protobuf/releases, manually download the zip
20-
file corresponding to your operating system and computer architecture
21-
(`protoc-<version>-<os>-<arch>.zip`), or fetch the file using commands such
22-
as the following:
19+
1. Navigate to the latest
20+
[GitHub Release](https://github.com/protocolbuffers/protobuf/releases/tag/v34.1).
21+
2. Download the zip file corresponding to your operating system and computer
22+
architecture (`protoc-<version>-<os>-<arch>.zip`).
2323

24-
```sh
25-
PB_REL="https://github.com/protocolbuffers/protobuf/releases"
26-
curl -LO $PB_REL/download/v30.2/protoc-30.2-linux-x86_64.zip
24+
* For example, for Linux x86-64 on 34.1, the filename would be
25+
`protoc-34.1-linux-x86_64.zip`.
26+
27+
**Alternative: Download using commands**
28+
29+
Instead of manual download, you can use the following commands to
30+
automatically fetch the latest Linux x86_64 asset:
2731

32+
```sh
33+
# Fetch the download URL for the latest Linux x86_64 asset from GitHub API
34+
URL=$(curl -s https://api.github.com/repos/protocolbuffers/protobuf/releases/latest \
35+
| jq -r '.assets[] | select(.name | endswith("linux-x86_64.zip")) | .browser_download_url')
36+
curl -LO $URL
2837
```
2938

30-
2. Unzip the file under `$HOME/.local` or a directory of your choice. For
39+
3. Unzip the file under `$HOME/.local` or a directory of your choice. For
3140
example:
3241

3342
```sh
34-
unzip protoc-30.2-linux-x86_64.zip -d $HOME/.local
43+
# If you used the command above:
44+
unzip $(basename $URL) -d $HOME/.local
45+
46+
# If you downloaded manually (replace <version> with actual version):
47+
# unzip protoc-<version>-linux-x86_64.zip -d $HOME/.local
3548
```
3649

37-
3. Update your environment's path variable to include the path to the `protoc`
50+
4. Update your environment's path variable to include the path to the `protoc`
3851
executable. For example:
3952
4053
```sh
@@ -59,22 +72,22 @@ Linux, macOS, or Windows using the following commands.
5972
6073
```sh
6174
apt install -y protobuf-compiler
62-
protoc --version # Ensure compiler version is 3+
75+
protoc --version # Ensure compiler version is 33.0+
6376
```
6477
6578
- MacOS, using [Homebrew](https://brew.sh):
6679
6780
```sh
6881
brew install protobuf
69-
protoc --version # Ensure compiler version is 3+
82+
protoc --version # Ensure compiler version is 33.0+
7083
```
7184
7285
- Windows, using
7386
[Winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/)
7487
7588
```sh
7689
> winget install protobuf
77-
> protoc --version # Ensure compiler version is 3+
90+
> protoc --version # Ensure compiler version is 33.0+
7891
```
7992
8093
### Other Installation Options {#other}

0 commit comments

Comments
 (0)