Skip to content

Commit

Permalink
Merge pull request #57 from cpanato/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
k8s-ci-robot authored Mar 27, 2023
2 parents 33d1f14 + e70969c commit 653e1b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 63 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Snapshot

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
pull_request:

jobs:
release:
snapshot:
runs-on: ubuntu-latest

steps:
Expand All @@ -25,7 +25,7 @@ jobs:
install-only: true

- name: Run Mage
uses: magefile/mage-action@v2
uses: magefile/mage-action@3b833fb24c0d19eed3aa760b9eb285b4b84f420f # v2.3.0
with:
version: latest
args: buildBinariesSnapshot
Expand Down
62 changes: 2 additions & 60 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"

"github.com/carolynvs/magex/pkg"
"github.com/carolynvs/magex/pkg/archive"
"github.com/carolynvs/magex/pkg/downloads"
"github.com/magefile/mage/sh"

"sigs.k8s.io/release-utils/mage"
Expand Down Expand Up @@ -141,7 +138,7 @@ func BuildImages() error {
// BuildImagesLocal build images locally and not push
func BuildImagesLocal() error {
fmt.Println("Building image with ko for local test...")
if err := EnsureKO(""); err != nil {
if err := mage.EnsureKO("0.13.0"); err != nil {
return err
}

Expand All @@ -164,7 +161,7 @@ func BuildStaging() error {
return err
}

if err := EnsureKO(""); err != nil {
if err := mage.EnsureKO(""); err != nil {
return err
}

Expand Down Expand Up @@ -252,58 +249,3 @@ func getBuildDateTime() string {
date, _ := sh.Output("date", "+%Y-%m-%dT%H:%M:%SZ")
return date
}

// Maybe we can move this to release-utils
func EnsureKO(version string) error {
versionToInstall := version
if versionToInstall == "" {
versionToInstall = "0.13.0"
}

fmt.Printf("Checking if `ko` version %s is installed\n", versionToInstall)
found, err := pkg.IsCommandAvailable("ko", "version", versionToInstall)
if err != nil {
return err
}

if !found {
fmt.Println("`ko` not found")
return InstallKO(versionToInstall)
}

fmt.Println("`ko` is installed!")
return nil
}

// Maybe we can move this to release-utils
func InstallKO(version string) error {
fmt.Println("Will install `ko`")
target := "ko"
if runtime.GOOS == "windows" {
target = "ko.exe"
}

opts := archive.DownloadArchiveOptions{
DownloadOptions: downloads.DownloadOptions{
UrlTemplate: "https://github.com/google/ko/releases/download/v{{.VERSION}}/ko_{{.VERSION}}_{{.GOOS}}_{{.GOARCH}}{{.EXT}}",
Name: "ko",
Version: version,
OsReplacement: map[string]string{
"darwin": "Darwin",
"linux": "Linux",
"windows": "Windows",
},
ArchReplacement: map[string]string{
"amd64": "x86_64",
},
},
ArchiveExtensions: map[string]string{
"linux": ".tar.gz",
"darwin": ".tar.gz",
"windows": ".tar.gz",
},
TargetFileTemplate: target,
}

return archive.DownloadToGopathBin(opts)
}

0 comments on commit 653e1b3

Please sign in to comment.