Skip to content

Commit 68ac985

Browse files
committed
Added version operability for git archive | updated zsh-completion
1 parent 38ad9cd commit 68ac985

File tree

5 files changed

+101
-89
lines changed

5 files changed

+101
-89
lines changed

.VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$Format%d$
1+
$Format:%d$

.version.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
read -r firstline < .VERSION
3+
last_half="${firstline##*tag: }"
4+
if [[ ${last_half::1} == "v" ]]; then
5+
version_string="${last_half%%[,)]*}"
6+
fi
7+
echo "${version_string:-v0.0.0}"

Makefile

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,96 @@ all: build lint test
22

33
.PHONY: all
44

5+
# Version flags to embed in the binaries
6+
VERSION ?= $(shell [ -d .git ] && git describe --tags --always --dirty="-dev")
7+
# If we are not in an active git dir then try reading the version from .VERSION.
8+
# .VERSION contains a slug populated by `git archive`.
9+
VERSION := $(or $(VERSION),$(shell ./.version.sh .VERSION))
10+
511
-include make/common.mk
612
-include make/docker.mk
13+
14+
#########################################
15+
# Debian
16+
#########################################
17+
18+
changelog:
19+
$Q echo "step-cli ($(VERSION)) unstable; urgency=medium" > debian/changelog
20+
$Q echo >> debian/changelog
21+
$Q echo " * See https://github.com/smallstep/cli/releases" >> debian/changelog
22+
$Q echo >> debian/changelog
23+
$Q echo " -- Smallstep Labs, Inc. <[email protected]> $(shell date -uR)" >> debian/changelog
24+
25+
debian: changelog
26+
$Q set -e; mkdir -p $(RELEASE); \
27+
OUTPUT=../step-cli_*.deb; \
28+
rm -f $$OUTPUT; \
29+
dpkg-buildpackage -b -rfakeroot -us -uc && cp $$OUTPUT $(RELEASE)/
30+
31+
distclean: clean
32+
33+
.PHONY: changelog debian distclean
34+
35+
#################################################
36+
# Build statically compiled step binary for various operating systems
37+
#################################################
38+
39+
BINARY_OUTPUT=$(OUTPUT_ROOT)binary/
40+
BUNDLE_MAKE=v=$v GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2)' PREFIX=$(3) make $(3)bin/step
41+
RELEASE=./.travis-releases
42+
43+
binary-linux:
44+
$(call BUNDLE_MAKE,linux,amd64,$(BINARY_OUTPUT)linux/)
45+
46+
binary-darwin:
47+
$(call BUNDLE_MAKE,darwin,amd64,$(BINARY_OUTPUT)darwin/)
48+
49+
define BUNDLE
50+
$(q)set -e; BUNDLE_DIR=$(BINARY_OUTPUT)$(1)/bundle; \
51+
stepName=step_$(2); \
52+
mkdir -p $$BUNDLE_DIR $(RELEASE); \
53+
TMP=$$(mktemp -d $$BUNDLE_DIR/tmp.XXXX); \
54+
trap "rm -rf $$TMP" EXIT INT QUIT TERM; \
55+
newdir=$$TMP/$$stepName; \
56+
mkdir -p $$newdir/bin; \
57+
cp $(BINARY_OUTPUT)$(1)/bin/step $$newdir/bin/; \
58+
cp README.md $$newdir/; \
59+
NEW_BUNDLE=$(RELEASE)/step_$(2)_$(1)_$(3).tar.gz; \
60+
rm -f $$NEW_BUNDLE; \
61+
tar -zcvf $$NEW_BUNDLE -C $$TMP $$stepName;
62+
endef
63+
64+
bundle-linux: binary-linux
65+
$(call BUNDLE,linux,$(VERSION),amd64)
66+
67+
bundle-darwin: binary-darwin
68+
$(call BUNDLE,darwin,$(VERSION),amd64)
69+
70+
.PHONY: binary-linux binary-darwin bundle-linux bundle-darwin
71+
72+
#################################################
73+
# Targets for creating OS specific artifacts
74+
#################################################
75+
76+
artifacts-linux-tag: bundle-linux debian
77+
78+
artifacts-darwin-tag: bundle-darwin
79+
80+
artifacts-tag: artifacts-linux-tag artifacts-darwin-tag
81+
82+
.PHONY: artifacts-linux-tag artifacts-darwin-tag artifacts-tag
83+
84+
#################################################
85+
# Targets for creating step artifacts
86+
#################################################
87+
88+
# For all builds that are not tagged
89+
artifacts-master:
90+
91+
# For all builds with a release tag
92+
artifacts-release: artifacts-tag
93+
94+
# This command is called by travis directly *after* a successful build
95+
artifacts: artifacts-$(PUSHTYPE) docker-$(PUSHTYPE)
96+
97+
.PHONY: artifacts-master artifacts-release artifacts

autocomplete/zsh_autocomplete

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
_cli_zsh_autocomplete() {
1+
#compdef _step step
22

3+
function _step {
34
local -a opts
45
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
56

67
_describe 'values' opts
78

89
return
910
}
10-
11-
compdef _cli_zsh_autocomplete $PROG

make/common.mk

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -151,91 +151,6 @@ uninstall:
151151

152152
.PHONY: install uninstall
153153

154-
#########################################
155-
# Debian
156-
#########################################
157-
158-
changelog:
159-
$Q echo "step-cli ($(VERSION)) unstable; urgency=medium" > debian/changelog
160-
$Q echo >> debian/changelog
161-
$Q echo " * See https://github.com/smallstep/cli/releases" >> debian/changelog
162-
$Q echo >> debian/changelog
163-
$Q echo " -- Smallstep Labs, Inc. <[email protected]> $(shell date -uR)" >> debian/changelog
164-
165-
debian: changelog
166-
$Q set -e; mkdir -p $(RELEASE); \
167-
OUTPUT=../step-cli_*.deb; \
168-
rm -f $$OUTPUT; \
169-
dpkg-buildpackage -b -rfakeroot -us -uc && cp $$OUTPUT $(RELEASE)/
170-
171-
distclean: clean
172-
173-
.PHONY: changelog debian distclean
174-
175-
#################################################
176-
# Build statically compiled step binary for various operating systems
177-
#################################################
178-
179-
BINARY_OUTPUT=$(OUTPUT_ROOT)binary/
180-
BUNDLE_MAKE=v=$v GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2)' PREFIX=$(3) make $(3)bin/step
181-
RELEASE=./.travis-releases
182-
183-
binary-linux:
184-
$(call BUNDLE_MAKE,linux,amd64,$(BINARY_OUTPUT)linux/)
185-
186-
binary-darwin:
187-
$(call BUNDLE_MAKE,darwin,amd64,$(BINARY_OUTPUT)darwin/)
188-
189-
define BUNDLE
190-
$(q)set -e; BUNDLE_DIR=$(BINARY_OUTPUT)$(1)/bundle; \
191-
stepName=step_$(2); \
192-
mkdir -p $$BUNDLE_DIR $(RELEASE); \
193-
TMP=$$(mktemp -d $$BUNDLE_DIR/tmp.XXXX); \
194-
trap "rm -rf $$TMP" EXIT INT QUIT TERM; \
195-
newdir=$$TMP/$$stepName; \
196-
mkdir -p $$newdir/bin; \
197-
cp $(BINARY_OUTPUT)$(1)/bin/step $$newdir/bin/; \
198-
cp README.md $$newdir/; \
199-
NEW_BUNDLE=$(RELEASE)/step_$(2)_$(1)_$(3).tar.gz; \
200-
rm -f $$NEW_BUNDLE; \
201-
tar -zcvf $$NEW_BUNDLE -C $$TMP $$stepName;
202-
endef
203-
204-
bundle-linux: binary-linux
205-
$(call BUNDLE,linux,$(VERSION),amd64)
206-
207-
bundle-darwin: binary-darwin
208-
$(call BUNDLE,darwin,$(VERSION),amd64)
209-
210-
.PHONY: binary-linux binary-darwin bundle-linux bundle-darwin
211-
212-
#################################################
213-
# Targets for creating OS specific artifacts
214-
#################################################
215-
216-
artifacts-linux-tag: bundle-linux debian
217-
218-
artifacts-darwin-tag: bundle-darwin
219-
220-
artifacts-tag: artifacts-linux-tag artifacts-darwin-tag
221-
222-
.PHONY: artifacts-linux-tag artifacts-darwin-tag artifacts-tag
223-
224-
#################################################
225-
# Targets for creating step artifacts
226-
#################################################
227-
228-
# For all builds that are not tagged
229-
artifacts-master:
230-
231-
# For all builds with a release tag
232-
artifacts-release: artifacts-tag
233-
234-
# This command is called by travis directly *after* a successful build
235-
artifacts: artifacts-$(PUSHTYPE) docker-$(PUSHTYPE)
236-
237-
.PHONY: artifacts-master artifacts-release artifacts
238-
239154
#########################################
240155
# Clean
241156
#########################################

0 commit comments

Comments
 (0)