diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 336efe3..ca7e3e3 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -18,6 +18,8 @@ env: jobs: ci: + # CI is skipped because `deliver` runs it first anyway + if: "github.ref != 'refs/heads/main'" runs-on: "ubuntu-latest" permissions: contents: "read" diff --git a/internal/tasks/delivery/run.go b/internal/tasks/delivery/run.go index d4c5eaf..422f768 100644 --- a/internal/tasks/delivery/run.go +++ b/internal/tasks/delivery/run.go @@ -8,7 +8,6 @@ import ( "time" "github.com/opensourcecorp/oscar/internal/consts" - igit "github.com/opensourcecorp/oscar/internal/git" iprint "github.com/opensourcecorp/oscar/internal/print" "github.com/opensourcecorp/oscar/internal/tasks/ci" containertools "github.com/opensourcecorp/oscar/internal/tasks/tools/containers" @@ -64,19 +63,7 @@ func Run(ctx context.Context) (err error) { return fmt.Errorf("internal error setting up run info: %w", err) } - git, err := igit.New(ctx) - if err != nil { - return err - } - iprint.Infof(run.Colors.Gray + git.String() + run.Colors.Reset) - - repo, err := taskutil.NewRepo(ctx) - if err != nil { - return fmt.Errorf("getting repo composition: %w", err) - } - iprint.Infof(run.Colors.Gray + repo.String() + run.Colors.Reset) - - taskMap, err := getDeliveryTaskMap(repo) + taskMap, err := getDeliveryTaskMap(run.Repo) if err != nil { return err } diff --git a/internal/tasks/tools/go/deliver.go b/internal/tasks/tools/go/deliver.go index ab41e92..6eccf55 100644 --- a/internal/tasks/tools/go/deliver.go +++ b/internal/tasks/tools/go/deliver.go @@ -2,6 +2,7 @@ package gotools import ( "context" + "errors" "fmt" "os" "path/filepath" @@ -9,6 +10,7 @@ import ( "strings" "github.com/opensourcecorp/oscar/internal/oscarcfg" + iprint "github.com/opensourcecorp/oscar/internal/print" "github.com/opensourcecorp/oscar/internal/system" taskutil "github.com/opensourcecorp/oscar/internal/tasks/util" ) @@ -47,12 +49,12 @@ func (t ghRelease) Exec(ctx context.Context) error { return err } - var buildErr error + var buildErrs error for _, src := range cfg.GetDeliverables().GetGoGithubRelease().GetBuildSources() { - buildErr = goBuild(ctx, src) + buildErrs = errors.Join(buildErrs, goBuild(ctx, src)) } - if buildErr != nil { - return err + if buildErrs != nil { + return buildErrs } buildDir := "build" @@ -121,6 +123,8 @@ func goBuild(ctx context.Context, src string) error { } for _, distro := range distros { + iprint.Debugf("building for %s\n", distro) + splits := strings.Split(distro, "/") goos := splits[0] goarch := splits[1] @@ -128,14 +132,20 @@ func goBuild(ctx context.Context, src string) error { binName := filepath.Base(src) target := filepath.Join(targetDir, fmt.Sprintf("%s-%s-%s", binName, goos, goarch)) + // At the time of this writing, UPX only works for Linux, so run it accordingly + runUPX := fmt.Sprintf("upx --best %s", target) + if goos != "linux" { + runUPX = "" + } + if _, err := system.RunCommand(ctx, []string{"bash", "-c", fmt.Sprintf(` CGO_ENABLED=0 \ GOOS=%s GOARCH=%s \ go build -ldflags '-s -w -extldflags "-static"' -o %s %s - upx --best %s`, + %s`, goos, goarch, target, src, - target, + runUPX, )}); err != nil { return fmt.Errorf("building Go binary: %w", err) } diff --git a/oscar.yaml b/oscar.yaml index 350266f..ff5bc64 100644 --- a/oscar.yaml +++ b/oscar.yaml @@ -1,5 +1,5 @@ --- -version: "0.3.0-alpha1" +version: "0.3.0-alpha2" deliverables: go_github_release: build_sources: