Skip to content

Commit

Permalink
Merge 2c6b7db into 3fde63a
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu authored Dec 25, 2017
2 parents 3fde63a + 2c6b7db commit ce530eb
Show file tree
Hide file tree
Showing 19 changed files with 890 additions and 50 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.*
!.gitignore
!.travis.yml
goxz/
vendor/
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: go
go:
- tip
script:
- make lint
- make test
after_script:
- make cover
51 changes: 51 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
name = "github.com/mholt/archiver"
version = "2.0.0"

[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.0"

[[constraint]]
branch = "master"
name = "golang.org/x/sync"
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
CURRENT_REVISION = $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS = "-X github.com/Songmu/goxz.revision=$(CURRENT_REVISION)"
ifdef update
u=-u
endif

deps:
go get ${u} github.com/golang/dep/cmd/dep
dep ensure

devel-deps: deps
go get ${u} github.com/golang/lint/golint
go get ${u} github.com/mattn/goveralls
go get ${u} github.com/motemen/gobump
go get ${u} github.com/Songmu/goxz
go get ${u} github.com/Songmu/ghch
go get ${u} github.com/tcnksm/ghr

test: deps
go test

lint: devel-deps
go vet
golint -set_exit_status

cover: devel-deps
goveralls

build: deps
go build -ldflags=$(BUILD_LDFLAGS) ./cmd/goxz

crossbuild: devel-deps
goxz -pv=v$(shell gobump show -r) -build-ldflags=$(BUILD_LDFLAGS) \
-d=./dist/v$(shell gobump show -r)

release:
_tools/releng
_tools/upload_artifacts

.PHONY: test deps devel-deps lint cover crossbuild release
69 changes: 65 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
goxz (WIP)
goxz
=======

[![Build Status](https://travis-ci.org/Songmu/goxz.png?branch=master)][travis]
Expand All @@ -10,17 +10,78 @@ goxz (WIP)
[license]: https://github.com/Songmu/goxz/blob/master/LICENSE
[godoc]: https://godoc.org/github.com/Songmu/goxz

## Description (UNDER CONSTRUCTION)
## Description

cross build and zipper for go tools
Just do cross building and archiving go tools conventionally

## Installation (UNDER CONSTRUCTION)
## Installation

% go get github.com/Songmu/goxz/cmd/goxz

Built binaries are available on gihub releases.
<https://github.com/Songmu/goxz/releases>

## Concept

- Simple and Lightweight
- Provides `goxc` subset
- only provides cross building and archiving
- No older Go support
- No complicated configuration and behaivors
- convention over configuration

## Synopsis

```console
# in your repository
% gozx -v 0.0.1 -os=linux,darwin -arch=amd64 ./cmd/mytool [...]

# archives are built into `./goxz` directory
% tree ./goxz
goxz/
├── yourapp_0.0.1_darwin_amd64.zip
└── ...
```

## Included resources

following files are included to archives automatically.

- `LICENSE*`
- `README*`
- `INSTALL*`
- `CREDIT*`

Custumizable file gathering rules may be provided in future.

## Archive naming specification

`{{Package}}_{{Version}}_{{OS}}_{{Arch}}.{{Ext}}`
or
`{{Package}}_{{OS}}_{{Arch}}.{{Ext}}`

- `{{Package}}`
- directory name of the project by default
- you can specify it with `-n` option
- `{{Version}}`
- When the version is specified by `-pv` option, that is contained in archive name
- `{{Ext}}`
- `.zip` is by default on "windows" and "darwin", `.tar.gz` is by default on other os.
- use `-z` option to use zip always to compress.
- No file naming notations are available yet
- ref. goxc: `{{.ExeName}}_{{.Version}}_{{.Os}}_{{.Arch}}{{.Ext}}`

## Options

- `os`
- os: linux,darwin and windows by default
- `arch`
- arc: arm64 only by default
- `-pv` for version specification
- `-build-ldflags` / `-build-tags`
- `-o` output filename
- not compatible with multiple package building

## Author

[Songmu](https://github.com/Songmu)
100 changes: 54 additions & 46 deletions SKETCH.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,66 @@
## goxz

Goのツールをパラレルクロスビルドして必要なファイルを抽出してarchiveに詰めてくれる君
Just do cross building and archiving go tools conventionally

- goxcから必要機能を抜き出して軽量にしたもの
- 古いGoのケアも不要
- デフォルトで良い感じになっているように
- provides `goxc` subset
- only provides cross building and archiving
- no older Go support
- no complicated configuration and behaivors
- convention over configuration

## usage

```console
% gozx -d ./dist \
-build-ldflags=... -os=linux,darwin,windows -arch=amd64 \
./cmd/{{exename}} [...]
# in your repository
% gozx -v 0.0.1 -os=linux,darwin -arch=amd64 ./cmd/mytool [...]

% tree dist
dist/
├── {{Package}}_{{Version}}_{{GOOS}}_{{GOARCH}}.zip
# archives are built into `./goxz` directory
% tree ./goxz
goxz/
├── yourapp_0.0.1_darwin_amd64.zip
└── ...
```

## 同梱物
- `LICENSE(?:.*)`
- `README(?:.*)`
- `INSTALL(?:.*)`
- `CREDIT(?:.*)`

## ファイル名の仕様
{{Package}}_{{Version}}_{{OS}}_{{Arch}}.zip

- Package(AppName?)はデフォルトでリポジトリ名
- 複数実行ファイルを同梱するかもしれないので
- {{Version}} は入れるか否か
- 入れるほうが好みだけど
- 入れるのがデフォルトで、入れないオプションつくる?
- バージョン指定ない場合は入れないとか(goxcもそうか)
- linuxのみ(BSD系も?)tar.gzにするのがデフォルトで、zipに統一するオプションを別途作るのが良い?
- goxcはデフォではlinuxのみtar.gz
- テンプレート記法(最初はなくて良さそう)
- goxc: {{.ExeName}}_{{.Version}}_{{.Os}}_{{.Arch}}{{.Ext}}
- 同梱物指定 (FileGatheringRule)
- ゆくゆく

## その他オプション
- `os` and `arch`
- osはdefault linux/darwin/win のみ(案)
- archはdefault arm64 のみ(案)
- `-bc`
- os/arch と bc それぞれは独立して動くで良い?
- 良さそう
- bc指定がされていて、 os/arch 設定が明にされていない場合は、デフォルトビルドはおこなわない
- `-pv` でバージョン指定
- `-build-ldflags` 実装は必須
- `-build-tags` はあっても良いかもなぁ
- `-o` オプションは作ってもよい?
- あっても良いけど複数コマンドビルドとの食い合せが悪い
- `go build` と同じ挙動で良さそうか (同じファイルを上書きする)
## Included resources

following files are included to archives automatically.

- `LICENSE*`
- `README*`
- `INSTALL*`
- `CREDIT*`

Custumizable file gathering rules may be provided in future.

## Archive naming specification

`{{Package}}_{{Version}}_{{OS}}_{{Arch}}.{{Ext}}`
or
`{{Package}}_{{OS}}_{{Arch}}.{{Ext}}`

- `{{Package}}`
- directory name of the project by default
- you can specify it with `-n` option
- `{{Version}}`
- When the version is specified by `-pv` option, that is contained in archive name
- `{{Ext}}`
- `.zip` is by default on "windows" and "darwin", `.tar.gz` is by default on other os.
- use `-z` option to use zip always to compress.
- No file naming notations are available yet
- ref. goxc: `{{.ExeName}}_{{.Version}}_{{.Os}}_{{.Arch}}{{.Ext}}`

## Options
- `os`
- os: linux,darwin and windows by default
- `arch`
- arc: arm64 only by default
- `-pv` for version specification
- `-build-ldflags` / `-build-tags`
- `-o` output filename
- not compatible with multiple package building
- `-build` (not implemented)
- specify build constarints
- os/arch と build はそれぞれは独立して動くで良い?
- 良さそう(ダメかも)
- もしくは両方指定できない?
- buildが指定がされていて、 os/arch 設定が明にされていない場合は、デフォルトビルドはおこなわない
12 changes: 12 additions & 0 deletions _tools/releng
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set -e

echo current version: $(gobump show -r)
read -p "input next version: " next_version

gobump set $next_version -w
ghch -w -N v$next_version

git ci -am "Checking in changes prior to tagging of version v$next_version"
git tag v$next_version
git push && git push --tags
6 changes: 6 additions & 0 deletions _tools/upload_artifacts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
set -e

ver=v$(gobump show -r)
make crossbuild
ghr $ver dist/$ver
9 changes: 9 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "{build}"
clone_folder: c:\gopath\src\github.com\Songmu\goxz
environment:
GOPATH: c:\gopath
build: false
test_script:
- go get -d -v -t ./...
- go tool vet -all .
- go test ./...
Loading

0 comments on commit ce530eb

Please sign in to comment.