forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dede45e
commit 3b5c06b
Showing
4 changed files
with
143 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### Bug fixes | ||
- feat: support application level extensions (#9923) | ||
- feat: support multiple extensions per resource group/kind (#9834) | ||
- fix: extensions is not loading for ConfigMap/Pods (#10010) | ||
- fix: upgrade moment from 2.29.2 to 2.29.3 (#9330) | ||
### Other changes | ||
- chore: update parse-url (#10101) | ||
- docs: add api field example in the appset security doc (#10087) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"regexp" | ||
"strings" | ||
"time" | ||
) | ||
|
||
func main() { | ||
err := release() | ||
if err != nil { | ||
fmt.Printf("Failed to release: %s\n", err.Error()) | ||
} | ||
} | ||
|
||
func getCurrentCommitSha() (string, error) { | ||
// git rev-parse --short HEAD | ||
cmd := exec.Command("git", "rev-parse", "--short", "HEAD") | ||
result, err := cmd.Output() | ||
if err != nil { | ||
return "", err | ||
} | ||
rs := strings.Split(string(result), "\n") | ||
return strings.Split(rs[0], " ")[0], nil | ||
} | ||
|
||
func getArgoCDVersion() (string, error) { | ||
// git rev-parse --abbrev-ref HEAD | ||
cmd := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD") | ||
result, err := cmd.Output() | ||
if err != nil { | ||
return "", err | ||
} | ||
pattern := `release-(\d+\.\d+)` | ||
re := regexp.MustCompile(pattern) | ||
matches := re.FindStringSubmatch(string(result)) | ||
if len(matches) >= 2 { | ||
return matches[1], nil | ||
} | ||
return "", fmt.Errorf("failed to get argocd version") | ||
} | ||
|
||
// function that returns version of the latest release by patern | ||
// {argocd-version}-{timestamp}-{commit-sha} | ||
func getLatestVersion() (string, error) { | ||
commitSha, err := getCurrentCommitSha() | ||
if err != nil { | ||
return "", err | ||
} | ||
argocdVersion, err := getArgoCDVersion() | ||
if err != nil { | ||
return "", err | ||
} | ||
return fmt.Sprintf("%s-%s-%s", argocdVersion, time.Now().Format("2006.01.02"), commitSha), nil | ||
} | ||
|
||
func updateVersion(version string) error { | ||
file, err := os.OpenFile("VERSION", os.O_WRONLY|os.O_TRUNC, 0644) | ||
if err != nil { | ||
return err | ||
} | ||
defer file.Close() | ||
|
||
// Write the new content to the file | ||
_, err = file.WriteString(version) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func readChangelog() (string, error) { | ||
data, err := os.ReadFile("changelog/CHANGELOG.md") | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(data), nil | ||
} | ||
|
||
func moveChangelog() error { | ||
version, err := getLatestVersion() | ||
if err != nil { | ||
return err | ||
} | ||
// mv changelog/CHANGELOG.md changelog/CHANGELOG-<version>.md | ||
cmd := exec.Command("mv", "changelog/CHANGELOG.md", fmt.Sprintf("changelog/CHANGELOG-%s.md", version)) | ||
if err := cmd.Run(); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func release() error { | ||
version, err := getLatestVersion() | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("Releasing version: %s\n", version) | ||
err = updateVersion(version) | ||
if err != nil { | ||
return err | ||
} | ||
changelog, err := readChangelog() | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("Changelog: %s\n", changelog) | ||
release := fmt.Sprintf("release-v%s", version) | ||
fmt.Printf("Release: %s\n", release) | ||
// git tag -a v2.9.3-2021.07.07-3a4b7f4 -m "Codefresh version for synced 2.9.3" | ||
_ = exec.Command("git", "tag", "-d", release).Run() | ||
cmd := exec.Command("git", "tag", "-a", release, "-m", changelog) | ||
if err := cmd.Run(); err != nil { | ||
return err | ||
} | ||
// git push remote-name --delete tag-name | ||
_ = exec.Command("git", "push", "origin", "--delete", release).Run() | ||
// git push origin tags/version | ||
cmd = exec.Command("git", "push", "origin", "tags/"+release) | ||
if err := cmd.Run(); err != nil { | ||
return err | ||
} | ||
err = moveChangelog() | ||
if err != nil { | ||
return err | ||
} | ||
return exec.Command("git", "push", "origin", "--delete", release).Run() | ||
} |