Skip to content

Commit 4d6d349

Browse files
Ensure release created (#377)
sometimes there is a delay between creation request and it's availability for assets upload
1 parent 21835cd commit 4d6d349

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

tools/release/release.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2017 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2017-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -17,8 +17,6 @@
1717
//
1818
// Copyright holder is ArangoDB GmbH, Cologne, Germany
1919
//
20-
// Author Ewout Prangsma
21-
//
2220

2321
package main
2422

@@ -33,6 +31,7 @@ import (
3331
"os/exec"
3432
"path/filepath"
3533
"strings"
34+
"time"
3635

3736
"github.com/coreos/go-semver/semver"
3837
)
@@ -188,6 +187,9 @@ func githubCreateRelease(version string) {
188187
if err := run(ghRelease, args...); err != nil {
189188
log.Fatalf("Failed to create github release: %v\n", err)
190189
}
190+
// Ensure release created (sometimes there is a delay between creation request and it's availability for assets upload)
191+
ensureReleaseCreated(version)
192+
191193
// Upload binaries
192194
assets := map[string]string{
193195
"SHA256SUMS": "SHA256SUMS",
@@ -220,6 +222,31 @@ func githubCreateRelease(version string) {
220222
}
221223
}
222224

225+
func ensureReleaseCreated(tagName string) {
226+
const attemptsCount = 5
227+
var interval = time.Second
228+
var err error
229+
230+
for i := 1; i <= attemptsCount; i++ {
231+
time.Sleep(interval)
232+
interval *= 2
233+
234+
args := []string{
235+
"info",
236+
"--user", ghUser,
237+
"--repo", ghRepo,
238+
"--tag", tagName,
239+
}
240+
err = run(ghRelease, args...)
241+
if err == nil {
242+
return
243+
}
244+
log.Printf("attempt #%d to get release info for tag %s failed. Retry in %s...", i, tagName, interval.String())
245+
}
246+
247+
log.Fatalf("failed to get release info for tag %s", tagName)
248+
}
249+
223250
func run(cmd string, args ...string) error {
224251
c := exec.Command(cmd, args...)
225252
c.Stdout = os.Stdout

0 commit comments

Comments
 (0)