Skip to content

Commit 4bab12a

Browse files
author
dcb9
committed
Update release tool
1 parent 8aab270 commit 4bab12a

File tree

5 files changed

+59
-10
lines changed

5 files changed

+59
-10
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@
1717

1818
.idea/
1919
/vendor
20+
/build
21+
/.DS_Store
22+
/curl2httpie
23+
/curl2httpie-*.zip

Makefile

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,53 @@ travis-pages :
44
go test ./...
55
cd web && gopherjs build -m -o curl2httpie.js && rm main.go .gitignore
66

7-
# $ dest=~/Downloads/curl2httpie/ v=v1.x make release
8-
release :
9-
cd cmd/curl2httpie/ && goxc -pv="$(v)" -d="$(dest)"
10-
117
generateOptions :
128
go run cmd/generateOptions/main.go -path="$(path)"
139
go-bindata -ignore .gitignore -pkg curl -o ./curl/bindata.go data/
1410

1511
initGithooks:
16-
git config core.hooksPath .githooks
12+
git config core.hooksPath .githooks
13+
14+
NAME := curl2httpie
15+
PACKAGE_NAME := github.com/dcb9/curl2httpie
16+
VERSION := `git describe --dirty`
17+
COMMIT := `git rev-parse HEAD`
18+
19+
PLATFORM := linux
20+
BUILD_DIR := build
21+
VAR_SETTING := -X $(PACKAGE_NAME)/constant.Version=$(VERSION) -X $(PACKAGE_NAME)/constant.Commit=$(COMMIT)
22+
GOBUILD = go build -ldflags="-s -w $(VAR_SETTING)" -trimpath -o $(BUILD_DIR)
23+
24+
release: clean darwin-amd64.zip linux-amd64.zip freebsd-amd64.zip windows-amd64.zip
25+
26+
clean:
27+
rm -rf $(BUILD_DIR)
28+
rm -f curl2httpie
29+
rm -f curl2httpie-*.zip
30+
31+
test:
32+
go test ./...
33+
34+
curl2httpie:
35+
mkdir -p $(BUILD_DIR)
36+
$(GOBUILD)
37+
38+
%.zip: %
39+
@zip -du $(NAME)-$@ -j $(BUILD_DIR)/$</*
40+
@echo "<<< ---- $(NAME)-$@"
41+
42+
darwin-amd64:
43+
mkdir -p $(BUILD_DIR)/$@
44+
GOARCH=amd64 GOOS=darwin $(GOBUILD)/$@
45+
46+
linux-amd64:
47+
mkdir -p $(BUILD_DIR)/$@
48+
GOARCH=amd64 GOOS=linux $(GOBUILD)/$@
49+
50+
freebsd-amd64:
51+
mkdir -p $(BUILD_DIR)/$@
52+
GOARCH=amd64 GOOS=freebsd $(GOBUILD)/$@
53+
54+
windows-amd64:
55+
mkdir -p $(BUILD_DIR)/$@
56+
GOARCH=amd64 GOOS=windows $(GOBUILD)/$@

cmd/curl2httpie/.goxc.local.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

constant/constant.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package constant
2+
3+
var Version = "v0.0.0"
4+
var Commit = "00000"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
"github.com/dcb9/curl2httpie/constant"
56
"log"
67
"os"
78

@@ -11,6 +12,11 @@ import (
1112
var errLogger = log.New(os.Stderr, "", 0)
1213

1314
func main() {
15+
if os.Args[1] == "-v" || os.Args[1] == "--version" || os.Args[1] == "version" {
16+
fmt.Printf("curl2httpie version: %s commit %s\n", constant.Version, constant.Commit)
17+
return
18+
}
19+
1420
cmdStr, warningMessages, err := connector.Convert(os.Args[1:])
1521
if len(warningMessages) > 0 {
1622
errLogger.Println("warnings:")

0 commit comments

Comments
 (0)