Skip to content

Commit

Permalink
Release 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreben committed Feb 15, 2019
1 parent de98efd commit 9535f6b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = 1.1.0
VERSION = 1.1.1

APP := subst
PACKAGES := $(shell go list -f {{.Dir}} ./...)
Expand All @@ -7,14 +7,13 @@ GOFILES := $(wildcard $(GOFILES))

.PHONY: clean release release-ci release-manual docker docker-latest README.md

clean:
clean:
rm -rf binaries/
rm -rf release/

release-ci: README.md zip

release: README.md
git reset
git add README.md
git add Makefile
git commit -am "Release $(VERSION)" || true
Expand Down Expand Up @@ -45,48 +44,48 @@ binaries: binaries/osx_x86_64/$(APP) binaries/windows_x86_64/$(APP).exe binaries
release/$(APP)_$(VERSION)_osx_x86_64.zip: binaries/osx_x86_64/$(APP)
mkdir -p release
cd ./binaries/osx_x86_64 && zip -r -D ../../release/$(APP)_$(VERSION)_osx_x86_64.zip $(APP)

binaries/osx_x86_64/$(APP): $(GOFILES)
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o binaries/osx_x86_64/$(APP)

release/$(APP)_$(VERSION)_windows_x86_64.zip: binaries/windows_x86_64/$(APP).exe
mkdir -p release
cd ./binaries/windows_x86_64 && zip -r -D ../../release/$(APP)_$(VERSION)_windows_x86_64.zip $(APP).exe

binaries/windows_x86_64/$(APP).exe: $(GOFILES)
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o binaries/windows_x86_64/$(APP).exe

release/$(APP)_$(VERSION)_linux_x86_64.zip: binaries/linux_x86_64/$(APP)
mkdir -p release
cd ./binaries/linux_x86_64 && zip -r -D ../../release/$(APP)_$(VERSION)_linux_x86_64.zip $(APP)

binaries/linux_x86_64/$(APP): $(GOFILES)
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=$(VERSION)" -o binaries/linux_x86_64/$(APP)

release/$(APP)_$(VERSION)_osx_x86_32.zip: binaries/osx_x86_32/$(APP)
mkdir -p release
cd ./binaries/osx_x86_32 && zip -r -D ../../release/$(APP)_$(VERSION)_osx_x86_32.zip $(APP)

binaries/osx_x86_32/$(APP): $(GOFILES)
GOOS=darwin GOARCH=386 go build -ldflags "-X main.version=$(VERSION)" -o binaries/osx_x86_32/$(APP)

release/$(APP)_$(VERSION)_windows_x86_32.zip: binaries/windows_x86_32/$(APP).exe
mkdir -p release
cd ./binaries/windows_x86_32 && zip -r -D ../../release/$(APP)_$(VERSION)_windows_x86_32.zip $(APP).exe

binaries/windows_x86_32/$(APP).exe: $(GOFILES)
GOOS=windows GOARCH=386 go build -ldflags "-X main.version=$(VERSION)" -o binaries/windows_x86_32/$(APP).exe

release/$(APP)_$(VERSION)_linux_x86_32.zip: binaries/linux_x86_32/$(APP)
mkdir -p release
cd ./binaries/linux_x86_32 && zip -r -D ../../release/$(APP)_$(VERSION)_linux_x86_32.zip $(APP)

binaries/linux_x86_32/$(APP): $(GOFILES)
GOOS=linux GOARCH=386 go build -ldflags "-X main.version=$(VERSION)" -o binaries/linux_x86_32/$(APP)

release/$(APP)_$(VERSION)_linux_arm64.zip: binaries/linux_arm64/$(APP)
mkdir -p release
cd ./binaries/linux_arm64 && zip -r -D ../../release/$(APP)_$(VERSION)_linux_arm64.zip $(APP)

binaries/linux_arm64/$(APP): $(GOFILES)
GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=$(VERSION)" -o binaries/linux_arm64/$(APP)
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

- [Get it](#get-it)
- [Use it](#use-it)
- [Examples](#examples)
- [Examples](#examples)
- [Comments](#comments)

<!-- /TOC -->
Expand All @@ -21,20 +21,20 @@ Using go get:
go get -u github.com/sgreben/subst
```

Or [download the binary](https://github.com/sgreben/subst/releases/latest) from the releases page.
Or [download the binary](https://github.com/sgreben/subst/releases/latest) from the releases page.

```bash
# Linux
curl -LO https://github.com/sgreben/subst/releases/download/1.1.0/subst_1.1.0_linux_x86_64.zip
unzip subst_1.1.0_linux_x86_64.zip
curl -LO https://github.com/sgreben/subst/releases/download/1.1.1/subst_1.1.1_linux_x86_64.zip
unzip subst_1.1.1_linux_x86_64.zip

# OS X
curl -LO https://github.com/sgreben/subst/releases/download/1.1.0/subst_1.1.0_osx_x86_64.zip
unzip subst_1.1.0_osx_x86_64.zip
curl -LO https://github.com/sgreben/subst/releases/download/1.1.1/subst_1.1.1_osx_x86_64.zip
unzip subst_1.1.1_osx_x86_64.zip

# Windows
curl -LO https://github.com/sgreben/subst/releases/download/1.1.0/subst_1.1.0_windows_x86_64.zip
unzip subst_1.1.0_windows_x86_64.zip
curl -LO https://github.com/sgreben/subst/releases/download/1.1.1/subst_1.1.1_windows_x86_64.zip
unzip subst_1.1.1_windows_x86_64.zip
```

## Use it
Expand Down Expand Up @@ -64,17 +64,17 @@ comment: $COMMENT
$ cat template.yaml | subst -q NAME=jp URL=github.com/sgreben/jp COMMENT=
name: jp
url: github.com/sgreben/jp
comment:
comment:

$ cat template.yaml | subst -q NAME=jp
$ cat template.yaml | subst -q NAME=jp
name: jp
url: $URL
comment: $COMMENT

$ cat template.yaml | subst -q -unknown=empty NAME=jp
$ cat template.yaml | subst -q -unknown=empty NAME=jp
name: jp
url:
comment:
url:
comment:
```

Without the `-q` flag, `subst` also prints to stderr:
Expand All @@ -98,7 +98,7 @@ To ignore occurrences of defined variables, you can define an escape string usin

```shell
$ echo 'unescaped: $X, ${X}. escaped: \$X, \${X}.' | subst -escape '\' X=value
unescaped: value, value. escaped: \$X, \${X}.
unescaped: value, value. escaped: $X, ${X}.
```

## Comments
Expand Down
18 changes: 9 additions & 9 deletions README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

- [Get it](#get-it)
- [Use it](#use-it)
- [Examples](#examples)
- [Examples](#examples)
- [Comments](#comments)

<!-- /TOC -->
Expand All @@ -21,7 +21,7 @@ Using go get:
go get -u github.com/sgreben/subst
```

Or [download the binary](https://github.com/sgreben/subst/releases/latest) from the releases page.
Or [download the binary](https://github.com/sgreben/subst/releases/latest) from the releases page.

```bash
# Linux
Expand Down Expand Up @@ -64,17 +64,17 @@ comment: $COMMENT
$ cat template.yaml | subst -q NAME=jp URL=github.com/sgreben/jp COMMENT=
name: jp
url: github.com/sgreben/jp
comment:
comment:

$ cat template.yaml | subst -q NAME=jp
$ cat template.yaml | subst -q NAME=jp
name: jp
url: $URL
comment: $COMMENT

$ cat template.yaml | subst -q -unknown=empty NAME=jp
$ cat template.yaml | subst -q -unknown=empty NAME=jp
name: jp
url:
comment:
url:
comment:
```

Without the `-q` flag, `subst` also prints to stderr:
Expand All @@ -98,9 +98,9 @@ To ignore occurrences of defined variables, you can define an escape string usin

```shell
$ echo 'unescaped: $X, ${X}. escaped: \$X, \${X}.' | subst -escape '\' X=value
unescaped: value, value. escaped: \$X, \${X}.
unescaped: value, value. escaped: $X, ${X}.
```

## Comments

Feel free to [leave a comment](https://github.com/sgreben/subst/issues/1) or create an issue.
Feel free to [leave a comment](https://github.com/sgreben/subst/issues/1) or create an issue.
8 changes: 6 additions & 2 deletions expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ func expand(s, escape string, mapping func(string) string) string {
for j := 0; j < len(s); j++ {
if shouldEscape {
if j+len(escaped) < len(s) && s[j:j+len(escaped)] == escaped {
j += len(escaped)
buf = append(buf, s[i:j]...)
buf = append(buf, s[j+len(escape):j+len(escaped)]...)
i = j + len(escaped)
j = i
continue
}
}
if s[j] == '$' && j+1 < len(s) {
buf = append(buf, s[i:j]...)
name, w := variableName(s[j+1:])
buf = append(buf, mapping(name)...)
value := mapping(name)
buf = append(buf, value...)
j += w
i = j + 1
}
Expand Down

0 comments on commit 9535f6b

Please sign in to comment.