Skip to content

Commit

Permalink
Merge branch 'feature/add-version' into 'master'
Browse files Browse the repository at this point in the history
Add `version` in cli

See merge request Qm64/backpack!9
  • Loading branch information
koalalorenzo committed Oct 12, 2020
2 parents e3394a9 + 6303981 commit 7bb32a8
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 9 deletions.
17 changes: 14 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,34 @@ build:master:
expire_in: 6 mos
only:
- master
except:
- tags

build:tags:
variables:
VERSION: $CI_COMMIT_TAG
extends: .buildbase
artifacts:
paths:
- build
only:
- tags

publish:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo "Running a new release"
dependencies:
- build:master
- build:tags
artifacts:
paths:
- build
release:
name: 'Release $CI_COMMIT_TAG'
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'
description: CHANGELOG.md
milestones: ["$CI_COMMIT_TAG"]
description: See CHANGELOG.md
only:
- tags

Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
### Added
### Removed
### Changed
### Fixed
Expand All @@ -22,4 +22,6 @@ This is the first release!
([#6](https://gitlab.com/Qm64/backpack/-/issues/6))
- There are few example backpack files
([#5](https://gitlab.com/Qm64/backpack/-/issues/5))
- A backpack includes markdown documentation ([#8](https://gitlab.com/Qm64/backpack/-/issues/8))
- A backpack includes markdown documentation ([#8](https://gitlab.com/Qm64/backpack/-/issues/8))
- Ability to know what version of backpack I am running
([mr9](https://gitlab.com/Qm64/backpack/-/merge_requests/9))
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ GO_BUILD_OUT_FILE := build/backpack_${GIT_COMMIT_SHORT}_${GOOS}_${GOARCH}
endif
endif

_GO_PACKAGE ?= gitlab.com/qm64/backpack
GO_BUILD_OUT_FILE ?= build/backpack

.DEFAULT_GOAL := build

ifneq (${VERSION},)
BUILD_LDFLAGS := -X ${_GO_PACKAGE}/cmd.version=${VERSION} -X ${_GO_PACKAGE}/cmd.versionGitHash=${GIT_COMMIT_SHORT}
endif
BUILD_LDFLAGS ?= -X ${_GO_PACKAGE}/cmd.versionGitHash=${GIT_COMMIT_SHORT}

clean:
rm -rf vendor
rm -rf build
Expand All @@ -23,7 +29,7 @@ vendor:
go mod vendor -v

build: vendor
go build -a -o ${GO_BUILD_OUT_FILE} main.go
go build -a -ldflags "${BUILD_LDFLAGS}" -o ${GO_BUILD_OUT_FILE} main.go
.PHONY: build

install:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ backpack run ./nginx-0.1.0.backpack -v ./values.yaml

Unpack, customize or Run a backpack **from an URL**:
```shell
backpack unpack https://gitlab.com/Qm64/backpack/-/raw/master/test_files/redis.backpack
backpack run https://gitlab.com/Qm64/backpack/-/raw/master/test_files/redis.backpack -f values
backpack unpack https://backpack.qm64.tech/examples/redis-6.0.0.backpack
backpack run https://backpack.qm64.tech/examples/redis-6.0.0.backpack -f values
```

**Get Help** and learn more for each command
Expand Down
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
)

var (
version string
// rootCmd represents the base command when called without any subcommands
rootCmd = &cobra.Command{
Use: "backpack",
Expand Down
29 changes: 29 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

var (
// Specify a version and versionTag
version = "unstable"
versionGitHash = "HEAD"
)

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Run: versionRun,
Short: "Shows Backpack version",
}

func init() {
rootCmd.AddCommand(versionCmd)
}

func versionRun(cmd *cobra.Command, args []string) {
fmt.Printf("Backpack version: %s (%s)\n", version, versionGitHash)
fmt.Println("More info: https://backpack.qm64.tech")
}

0 comments on commit 7bb32a8

Please sign in to comment.