forked from oras-project/oras
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support version with makefile, dockerfile, and goreleaser updated
- Loading branch information
Showing
6 changed files
with
105 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
FROM golang:1.11-alpine as builder | ||
ADD . /go/src/github.com/deislabs/oras | ||
WORKDIR /go/src/github.com/deislabs/oras | ||
RUN go install github.com/deislabs/oras/cmd/oras | ||
RUN apk add git make | ||
ENV ORASPKG /go/src/github.com/deislabs/oras | ||
ADD . ${ORASPKG} | ||
WORKDIR ${ORASPKG} | ||
RUN make build-linux | ||
RUN mv ${ORASPKG}/bin/linux/amd64/oras /go/bin/oras | ||
|
||
FROM alpine | ||
LABEL maintainer="[email protected]" | ||
|
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,54 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/deislabs/oras/internal/version" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func versionCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "version", | ||
Short: "Show the oras version information", | ||
Long: `Show the oras version information | ||
Example - print version: | ||
oras version | ||
`, | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return runVersion() | ||
}, | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
func runVersion() error { | ||
items := [][]string{ | ||
{"Version", version.GetVersion()}, | ||
{"Go version", runtime.Version()}, | ||
} | ||
if version.GitCommit != "" { | ||
items = append(items, []string{"Git commit", version.GitCommit}) | ||
} | ||
if version.GitTreeState != "" { | ||
items = append(items, []string{"Git tree state", version.GitTreeState}) | ||
} | ||
|
||
size := 0 | ||
for _, item := range items { | ||
if length := len(item[0]); length > size { | ||
size = length | ||
} | ||
} | ||
for _, item := range items { | ||
fmt.Println(item[0] + ": " + strings.Repeat(" ", size-len(item[0])) + item[1]) | ||
} | ||
|
||
return nil | ||
} |
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,20 @@ | ||
package version | ||
|
||
var ( | ||
// Version is the current version of the oras. | ||
Version = "0.4.0" | ||
// BuildMetadata is the extra build time data | ||
BuildMetadata = "unreleased" | ||
// GitCommit is the git sha1 | ||
GitCommit = "" | ||
// GitTreeState is the state of the git tree | ||
GitTreeState = "" | ||
) | ||
|
||
// GetVersion returns the semver string of the version | ||
func GetVersion() string { | ||
if BuildMetadata == "" { | ||
return Version | ||
} | ||
return Version + "+" + BuildMetadata | ||
} |