fix: fix publisher command

fix: fix ci pipeline to include publish testing
This commit is contained in:
Marcel S. Henselin 2026-01-30 12:27:46 +01:00
parent 4153035eae
commit 5e8bc4b7f0
3 changed files with 112 additions and 2 deletions

View file

@ -8,11 +8,13 @@ import (
"io/fs"
"log"
"os"
"os/exec"
"path"
"strings"
)
type Provider struct {
RootPath string
Namespace string
Provider string
DistPath string
@ -23,6 +25,17 @@ type Provider struct {
Domain string
}
func (p *Provider) GetRoot() error {
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
out, err := cmd.Output()
if err != nil {
return err
}
lines := strings.Split(string(out), "\n")
p.RootPath = lines[0]
return nil
}
func (p *Provider) CreateV1Dir() error {
// Path to semantic version dir
versionPath := p.providerDirs()

View file

@ -6,6 +6,7 @@ import (
"io/fs"
"log"
"os"
"path"
"path/filepath"
publish2 "github.com/mhenselin/terraform-provider-stackitprivatepreview/cmd/cmd/publish"
@ -96,10 +97,14 @@ func publish() error {
GpgPubKeyFile: gpgPubKeyFile,
Domain: domain,
}
err := p.GetRoot()
if err != nil {
return err
}
// Create release dir - only the contents of this need to be uploaded to S3
log.Printf("* Creating reelase directory")
err := os.Mkdir("release", os.ModePerm)
err = os.Mkdir(path.Join(p.RootPath, "release"), os.ModePerm)
if !errors.Is(err, fs.ErrExist) {
return fmt.Errorf("error creating 'release' dir: %w", err)
}