Skip to content

Commit

Permalink
Revert "Use last release tag and branch (#467)"
Browse files Browse the repository at this point in the history
This reverts commit bde6660.
  • Loading branch information
divolgin committed Oct 29, 2024
1 parent bde6660 commit 040e0bb
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions dagger/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ func (r *Replicated) Release(
return err
}

latestReleaseBranchName, err := getReleaseBranchName(ctx, latestVersion)
if err != nil {
return err
}

major, minor, patch, err := getNextVersion(ctx, latestVersion, version)
major, minor, patch, err := parseVersion(ctx, latestVersion, version)
if err != nil {
return err
}
Expand Down Expand Up @@ -95,9 +90,7 @@ func (r *Replicated) Release(
WithMountedDirectory("/go/src/github.com/replicatedhq/replicated", updatedSource).
WithWorkdir("/go/src/github.com/replicatedhq/replicated").
With(CacheBustingExec([]string{"git", "tag", fmt.Sprintf("v%d.%d.%d", major, minor, patch)})).
With(CacheBustingExec([]string{"git", "push", "dagger", fmt.Sprintf("v%d.%d.%d", major, minor, patch)})).
With(CacheBustingExec([]string{"git", "fetch", "dagger", latestReleaseBranchName})).
With(CacheBustingExec([]string{"git", "fetch", "dagger", "--tags"}))
With(CacheBustingExec([]string{"git", "push", "dagger", fmt.Sprintf("v%d.%d.%d", major, minor, patch)}))
_, err = tagContainer.Stdout(ctx)
if err != nil {
return err
Expand Down Expand Up @@ -172,8 +165,9 @@ func (r *Replicated) Release(
goreleaserContainer := dag.Goreleaser(dagger.GoreleaserOpts{
Version: goreleaserVersion,
}).Ctr().
WithSecretVariable("GITHUB_TOKEN", githubToken).
WithEnvVariable("GORELEASER_CURRENT_TAG", latestVersion)
WithSecretVariable("GITHUB_TOKEN", githubToken)
// TODO: add back after next release
// WithEnvVariable("GORELEASER_CURRENT_TAG", latestVersion)

if snapshot {
_, err := dag.
Expand Down Expand Up @@ -206,7 +200,7 @@ func (r *Replicated) Release(
return nil
}

func getNextVersion(ctx context.Context, latestVersion string, version string) (int64, int64, int64, error) {
func parseVersion(ctx context.Context, latestVersion string, version string) (int64, int64, int64, error) {
parsedLatestVersion, err := semver.NewVersion(latestVersion)
if err != nil {
return 0, 0, 0, err
Expand All @@ -228,15 +222,6 @@ func getNextVersion(ctx context.Context, latestVersion string, version string) (
}
}

func getReleaseBranchName(ctx context.Context, latestVersion string) (string, error) {
parsedLatestVersion, err := semver.NewVersion(latestVersion)
if err != nil {
return "", err
}

return fmt.Sprintf("release-%d.%d.%d", parsedLatestVersion.Major(), parsedLatestVersion.Minor(), parsedLatestVersion.Patch()), nil
}

func getLatestVersion(ctx context.Context) (string, error) {
resp, err := http.DefaultClient.Get("https://api.github.com/repos/replicatedhq/replicated/releases/latest")
if err != nil {
Expand Down

0 comments on commit 040e0bb

Please sign in to comment.