Skip to content

Commit

Permalink
fix(CI): use the correct version for VespaCLI publishing (#32233)
Browse files Browse the repository at this point in the history
* fix(CI): use the correct version for VespaCLI publishing

* fix(CI): ensure request to Github API are authenticated

* fix(CI): ensure the workflow has the required permission
  • Loading branch information
esolitos authored Aug 26, 2024
1 parent 0b3e221 commit 61e02db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ jobs:
- prepare
- build-test

permissions:
contents: write

defaults:
run:
# This workflow only interacts with the client/go directory, so we can set the working directory here.
working-directory: client/go

env:
VERSION: ${{ needs.prepare.outputs.version }}
VERSION: ${{ needs.prepare.outputs.build-version }}

steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 11 additions & 1 deletion client/go/cond_make.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,16 @@ func latestReleasedTag(mirror string) (string, error) {
switch mirror {
case "github":
url := "https://api.github.com/repos/vespa-engine/vespa/releases/latest"
resp, err := http.Get(url)
token := "Bearer " + os.Getenv("GH_TOKEN")

req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Println("Error on setting up http request.\n[ERROR] -", err)
}
req.Header.Add("Authorization", token)

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return "", err
}
Expand All @@ -100,6 +109,7 @@ func latestReleasedTag(mirror string) (string, error) {
return "", err
}
return release.TagName, nil

case "homebrew":
cmd, stdout, _ := newCmd("brew", "info", "--json", "--formula", "vespa-cli")
cmd.Stdout = stdout // skip printing output to os.Stdout
Expand Down

0 comments on commit 61e02db

Please sign in to comment.