Skip to content

Commit

Permalink
Merge pull request #19 from kubesphere-sigs/set-commitish
Browse files Browse the repository at this point in the history
Set commitish when creating a release
  • Loading branch information
LinuxSuRen authored Nov 4, 2021
2 parents 8cf4ea3 + 07491b1 commit b25af8c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
workflow_dispatch:

jobs:
UpdateReleaseDraft:
Expand Down
6 changes: 3 additions & 3 deletions controllers/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
/**
TODO make these functions into a struct
For example, we can share parts of the variables, such as git.Repository, secret .etc.
*/
*/

func saveAndPush(gitRepo *git.Repository, user, targetFile string, data []byte, secret *v1.Secret) (err error) {
if err = ioutil.WriteFile(targetFile, data, 0644); err != nil {
Expand Down Expand Up @@ -89,12 +89,12 @@ func release(repo devopsv1alpha1.Repository, secret *v1.Secret, user string) (er
case devopsv1alpha1.ActionPreRelease:
provider := internal_scm.GetGitProvider(string(repo.Provider), orgAndRepo, string(secret.Data[v1.BasicAuthPasswordKey]))
if provider != nil {
err = provider.Release(repo.Version, false, true)
err = provider.Release(repo.Version, repo.Branch, false, true)
}
case devopsv1alpha1.ActionRelease:
provider := internal_scm.GetGitProvider(string(repo.Provider), orgAndRepo, string(secret.Data[v1.BasicAuthPasswordKey]))
if provider != nil {
err = provider.Release(repo.Version, false, false)
err = provider.Release(repo.Version, repo.Branch, false, false)
}
}
return
Expand Down
2 changes: 1 addition & 1 deletion controllers/internal_scm/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package internal_scm
import "github.com/kubesphere-sigs/ks-releaser/api/v1alpha1"

type GitReleaser interface {
Release(version string, draft, prerelease bool) (err error)
Release(version, commitish string, draft, prerelease bool) (err error)
}

// GetGitProvider returns the GitReleaser implement by kind
Expand Down
3 changes: 2 additions & 1 deletion controllers/internal_scm/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ func NewGitHub(repo, token string) *GitHub {
}
}

func (r *GitHub) Release(version string, draft, prerelease bool) (err error) {
func (r *GitHub) Release(version, commitish string, draft, prerelease bool) (err error) {
client := r.getClient()

releaseInput := &scm.ReleaseInput{
Title: version,
Tag: version,
Commitish: commitish,
Draft: draft,
Prerelease: prerelease,
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ status: {}
}
})
}
}
}
2 changes: 1 addition & 1 deletion controllers/yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Test_updateReleaserAsYAML(t *testing.T) {
}{{
name: "normal case",
args: args{
data: []byte(`apiVersion: devops.kubesphere.io/v1alpha1
data: []byte(`apiVersion: devops.kubesphere.io/v1alpha1
kind: Releaser
metadata:
name: releaser-sample-1
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func main() {
}

if err = (&controllers.ReleaserReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
GitCacheDir: "tmp",
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Releaser")
Expand Down

0 comments on commit b25af8c

Please sign in to comment.