Skip to content

Commit

Permalink
Merge pull request #514 from digitalocean/remove-hardcoded-version
Browse files Browse the repository at this point in the history
Remove hardcoded version
  • Loading branch information
bentranter authored Jul 23, 2019
2 parents 13c1a44 + 488c407 commit becb6c4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
5 changes: 0 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ You will also need a valid `GITHUB_TOKEN` environment variable with access to th
1. Run `make changelog` and add the results to the [CHANGELOG](https://github.com/digitalocean/doctl/blob/master/CHANGELOG.md)
under the version you're going to release if they aren't already there.

Update the version in:

* `doit.go`
* `Dockerfile`

1. Generate a PR, get it reviewed, and merge

1. To build `doctl` for all its platforms, run `scripts/stage.sh major minor patch`
Expand Down
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# docker build -t doctl_local --build-arg DOCTL_VERSION=1.23.1 .
#
# This Dockerfile exists so casual uses of `docker build` and `docker run` do something sane.
# We don't recommend using it: If you want to develop in docker, please use `make docker_build`
# instead.

FROM alpine:3.8

ENV DOCTL_VERSION=1.23.1
ARG DOCTL_VERSION
ENV DOCTL_VERSION=$DOCTL_VERSION

RUN apk add --no-cache curl

Expand Down
56 changes: 30 additions & 26 deletions doit.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,45 +43,49 @@ const (
LatestReleaseURL = "https://api.github.com/repos/digitalocean/doctl/releases/latest"
)

// Version is the version info for doit.
type Version struct {
Major, Minor, Patch int
Name, Build, Label string
}

var (
// DoitConfig holds the app's current configuration.
DoitConfig Config = &LiveConfig{}

// DoitVersion is doit's version.
DoitVersion = Version{
Major: 1,
Minor: 23,
Patch: 1,
Label: "dev",
}

// Build is doit's build tag.
Build string

// Major is doctl's major version.
Major string

// Minor is doctl's minor version.
Minor string

// Patch is doctl's patch version.
Patch string
// Build, Major, Minor, Patch and Label are set at build time
Build, Major, Minor, Patch, Label string

// Label is doctl's label.
Label string
// DoitVersion is doctl's version.
DoitVersion Version

// TraceHTTP traces http connections.
TraceHTTP bool
)

func init() {
jww.SetStdoutThreshold(jww.LevelError)
}

// Version is the version info for doit.
type Version struct {
Major, Minor, Patch int
Name, Build, Label string
if Build != "" {
DoitVersion.Build = Build
}
if Major != "" {
i, _ := strconv.Atoi(Major)
DoitVersion.Major = i
}
if Minor != "" {
i, _ := strconv.Atoi(Minor)
DoitVersion.Minor = i
}
if Patch != "" {
i, _ := strconv.Atoi(Patch)
DoitVersion.Patch = i
}
if Label == "" {
DoitVersion.Label = "dev"
} else {
DoitVersion.Label = Label
}
}

func (v Version) String() string {
Expand Down

0 comments on commit becb6c4

Please sign in to comment.