diff --git a/.drone.jsonnet b/.drone.jsonnet index 6fb3f4a..cdc5355 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,54 +1,57 @@ -[ - { - kind: 'pipeline', - name: 'go%s' % version, - platform: { - os: 'linux', - arch: 'amd64', - }, +{ + kind: 'pipeline', + name: 'default', + platform: { + os: 'linux', + arch: 'amd64', + }, - local golang = { - name: 'golang', - image: 'golang:%s' % version, - pull: 'always', - environment: { - CGO_ENABLED: '0', - GO111MODULE: 'on', - }, - when: { - event: { - exclude: ['tag'], - }, + local golang(version='latest') = { + name: 'golang', + image: 'golang:%s' % version, + pull: 'always', + environment: { + CGO_ENABLED: '0', + GO111MODULE: 'on', + }, + when: { + event: { + exclude: ['tag'], }, }, + }, - steps: [ - golang { - name: 'gomod', - commands: [ - 'go mod vendor', - 'git diff --exit-code', - ], - }, - - golang { - name: 'build', - commands: [ - 'make build', - 'make test', - 'make test-integration', - ], - }, - - golang { - name: 'generate', - commands: [ - 'make check-license', - 'make generate', - 'git diff --exit-code', - ], - }, + local build(version) = golang(version) { + name: 'build-%s' % version, + commands: [ + 'make build', + 'make test', + 'make test-integration', ], - } - for version in ['1.13', '1.12', '1.11'] -] + depends_on: ["gomod"] + }, + + steps: [ + golang() { + name: 'gomod', + commands: [ + 'go mod vendor', + 'git diff --exit-code', + ], + }, + + build('1.11'), + build('1.12'), + build('1.13') + {depends_on: ["build-1.11", "build-1.12"]}, + + golang() { + name: 'generate', + commands: [ + 'make check-license', + 'make generate', + 'git diff --exit-code', + ], + depends_on: ["build-1.13"] + }, + ], +} diff --git a/.drone.yml b/.drone.yml index 6331965..d5285ea 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ --- kind: pipeline -name: go1.13 +name: default platform: os: linux @@ -9,7 +9,7 @@ platform: steps: - name: gomod pull: always - image: golang:1.13 + image: golang:latest commands: - go mod vendor - git diff --exit-code @@ -21,113 +21,7 @@ steps: exclude: - tag -- name: build - pull: always - image: golang:1.13 - commands: - - make build - - make test - - make test-integration - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - exclude: - - tag - -- name: generate - pull: always - image: golang:1.13 - commands: - - make check-license - - make generate - - git diff --exit-code - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - exclude: - - tag - ---- -kind: pipeline -name: go1.12 - -platform: - os: linux - arch: amd64 - -steps: -- name: gomod - pull: always - image: golang:1.12 - commands: - - go mod vendor - - git diff --exit-code - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - exclude: - - tag - -- name: build - pull: always - image: golang:1.12 - commands: - - make build - - make test - - make test-integration - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - exclude: - - tag - -- name: generate - pull: always - image: golang:1.12 - commands: - - make check-license - - make generate - - git diff --exit-code - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - exclude: - - tag - ---- -kind: pipeline -name: go1.11 - -platform: - os: linux - arch: amd64 - -steps: -- name: gomod - pull: always - image: golang:1.11 - commands: - - go mod vendor - - git diff --exit-code - environment: - CGO_ENABLED: 0 - GO111MODULE: on - when: - event: - exclude: - - tag - -- name: build +- name: build-1.11 pull: always image: golang:1.11 commands: @@ -141,10 +35,47 @@ steps: event: exclude: - tag + depends_on: + - gomod + +- name: build-1.12 + pull: always + image: golang:1.12 + commands: + - make build + - make test + - make test-integration + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + exclude: + - tag + depends_on: + - gomod + +- name: build-1.13 + pull: always + image: golang:1.13 + commands: + - make build + - make test + - make test-integration + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + exclude: + - tag + depends_on: + - build-1.11 + - build-1.12 - name: generate pull: always - image: golang:1.11 + image: golang:latest commands: - make check-license - make generate @@ -156,5 +87,7 @@ steps: event: exclude: - tag + depends_on: + - build-1.13 ... diff --git a/README.md b/README.md index 791985f..57f5462 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,11 @@ usage: jb [] [ ...] A jsonnet package manager Flags: - -h, --help Show context-sensitive help (also try --help-long and --help-man). + -h, --help Show context-sensitive help (also try --help-long and + --help-man). + --version Show application version. --jsonnetpkg-home="vendor" - The directory used to cache packages in. + The directory used to cache packages in. Commands: help [...] diff --git a/cmd/jb/main.go b/cmd/jb/main.go index fd25873..63c6b4e 100644 --- a/cmd/jb/main.go +++ b/cmd/jb/main.go @@ -23,7 +23,6 @@ import ( "github.com/fatih/color" "github.com/pkg/errors" - kingpin "gopkg.in/alecthomas/kingpin.v2" "github.com/jsonnet-bundler/jsonnet-bundler/spec" ) @@ -57,7 +56,7 @@ func Main() int { color.Output = color.Error - a := kingpin.New(filepath.Base(os.Args[0]), "A jsonnet package manager") + a := newApp() a.HelpFlag.Short('h') a.Flag("jsonnetpkg-home", "The directory used to cache packages in."). diff --git a/cmd/jb/version.go b/cmd/jb/version.go new file mode 100644 index 0000000..f58bfd1 --- /dev/null +++ b/cmd/jb/version.go @@ -0,0 +1,34 @@ +// Copyright 2018 jsonnet-bundler authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build go1.12 + +package main + +import ( + "os" + "path/filepath" + "runtime/debug" + + kingpin "gopkg.in/alecthomas/kingpin.v2" +) + +func newApp() *kingpin.Application { + a := kingpin.New(filepath.Base(os.Args[0]), "A jsonnet package manager") + d, ok := debug.ReadBuildInfo() + if ok { + return a.Version(d.Main.Version) + } + return a +} diff --git a/cmd/jb/version111.go b/cmd/jb/version111.go new file mode 100644 index 0000000..40ca400 --- /dev/null +++ b/cmd/jb/version111.go @@ -0,0 +1,29 @@ +// Copyright 2018 jsonnet-bundler authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build !go1.12 + +package main + +import ( + "os" + "path/filepath" + + kingpin "gopkg.in/alecthomas/kingpin.v2" +) + +func newApp() *kingpin.Application { + a := kingpin.New(filepath.Base(os.Args[0]), "A jsonnet package manager") + return a +}