Skip to content

Ensure release created #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions tools/release/release.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2017 ArangoDB GmbH, Cologne, Germany
// Copyright 2017-2023 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,8 +17,6 @@
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Ewout Prangsma
//

package main

Expand All @@ -33,6 +31,7 @@ import (
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/coreos/go-semver/semver"
)
Expand Down Expand Up @@ -188,6 +187,9 @@ func githubCreateRelease(version string) {
if err := run(ghRelease, args...); err != nil {
log.Fatalf("Failed to create github release: %v\n", err)
}
// Ensure release created (sometimes there is a delay between creation request and it's availability for assets upload)
ensureReleaseCreated(version)

// Upload binaries
assets := map[string]string{
"SHA256SUMS": "SHA256SUMS",
Expand Down Expand Up @@ -220,6 +222,31 @@ func githubCreateRelease(version string) {
}
}

func ensureReleaseCreated(tagName string) {
const attemptsCount = 5
var interval = time.Second
var err error

for i := 1; i <= attemptsCount; i++ {
time.Sleep(interval)
interval *= 2

args := []string{
"info",
"--user", ghUser,
"--repo", ghRepo,
"--tag", tagName,
}
err = run(ghRelease, args...)
if err == nil {
return
}
log.Printf("attempt #%d to get release info for tag %s failed. Retry in %s...", i, tagName, interval.String())
}

log.Fatalf("failed to get release info for tag %s", tagName)
}

func run(cmd string, args ...string) error {
c := exec.Command(cmd, args...)
c.Stdout = os.Stdout
Expand Down