Skip to content

Commit 8ac7052

Browse files
authored
Merge pull request #222 from NeowayLabs/addReleaser
Add releaser
2 parents 7b41ca0 + ef3c16a commit 8ac7052

File tree

5 files changed

+79
-10
lines changed

5 files changed

+79
-10
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/cmd/nash/nash
33
/coverage.txt
44
cmd/nashfmt/nashfmt
5+
dist
6+
*.exe

Diff for: Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ install:
2626
update-vendor:
2727
cd cmd/nash && nash ./vendor.sh
2828

29+
release: clean
30+
./hack/releaser.sh $(version)
31+
2932
clean:
3033
rm -f cmd/nash/nash
3134
rm -f cmd/nashfmt/nashfmt
35+
rm -rf dist

Diff for: README.md

+10
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,16 @@ calling the parent namespace as "host". This breaks the namespace
409409
sharing/unsharing idea of processes. What I wanted was a copy of the
410410
missing plan9 'environment namespace' to child namespaces.
411411
412+
# Releasing
413+
414+
To generate a release basically:
415+
416+
* Generate the release on github
417+
* Clone the generated tag
418+
* Run: ``` make release "version=<version>" ```
419+
420+
Where **<version>** must match the version of the git tag.
421+
412422
# Want to contribute?
413423
414424
Open issues and PR :)

Diff for: cmd/nash/Makefile

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
all: build install
22

3-
ifndef VERSION
4-
VERSION=$(shell git rev-list -1 HEAD)
3+
ifndef version
4+
version=$(shell git rev-list -1 HEAD)
55
endif
66

7-
BUILDARGS = -installsuffix netgo -ldflags "-linkmode external -extldflags -static -X main.VersionString=$(VERSION)" -v
8-
UNAME_S := $(shell uname -s)
9-
ifeq ($(UNAME_S),Darwin)
10-
BUILDARGS = -ldflags "-linkmode external -X main.VersionString=$(VERSION)" -v
11-
endif
7+
buildargs = -ldflags "-X main.VersionString=$(version)" -v
128

139
build:
14-
@echo "building nash version: "$(VERSION)
15-
GO15VENDOREXPERIMENT=1 go build $(BUILDARGS)
10+
@echo "building nash version: "$(version)
11+
GO15VENDOREXPERIMENT=1 go build $(buildargs)
1612

1713
install:
18-
GO15VENDOREXPERIMENT=1 go install $(BUILDARGS)
14+
GO15VENDOREXPERIMENT=1 go install $(buildargs)

Diff for: hack/releaser.sh

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env nash
2+
3+
if len($ARGS) != "2" {
4+
print("usage: %s <version>\n\n", $ARGS[0])
5+
exit("1")
6+
}
7+
8+
version = $ARGS[1]
9+
supported_os = ("linux" "darwin" "windows")
10+
supported_arch = ("amd64")
11+
12+
# Guarantee passing tests at least on the host arch/os
13+
make test
14+
15+
setenv CGO_ENABLED = "0"
16+
17+
mkdir -p dist
18+
19+
fn prepare_execs(distfiles, os) {
20+
if $os == "windows" {
21+
newfiles = ()
22+
23+
for distfile in $distfiles {
24+
file = $distfile+".exe"
25+
26+
newfiles <= append($newfiles, $file)
27+
}
28+
29+
return $newfiles
30+
}
31+
if $os == "linux" {
32+
for distfile in $distfiles {
33+
strip $distfile
34+
}
35+
}
36+
37+
return $distfiles
38+
}
39+
40+
for os in $supported_os {
41+
for arch in $supported_arch {
42+
setenv GOOS = $os
43+
setenv GOARCH = $arch
44+
45+
echo "building OS: "+$GOOS+" ARCH : "+$GOARCH
46+
make build "version="+$version
47+
48+
nash = "cmd/nash/nash"
49+
nashfmt = "cmd/nashfmt/nashfmt"
50+
execfiles = ($nash $nashfmt)
51+
52+
distfiles <= prepare_execs($execfiles, $os)
53+
distar <= format("dist/nash-%s-%s-%s.tar.gz", $version, $os, $arch)
54+
55+
tar cvfz $distar $distfiles
56+
}
57+
}

0 commit comments

Comments
 (0)