From 395f6700d753a4dcde09737e2743a504bac89d9b Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 13 Aug 2015 16:14:56 +0200 Subject: [PATCH] Switch to goxc --- .gitignore | 1 + .goxc.json | 49 +++++++++++++++++++++++++++++++ Dockerfile | 38 ------------------------ Makefile | 42 +++++++++++++++++++-------- README.md | 51 +++++++++++++++++++++++++++++---- contrib/builder/homebrew/scw.rb | 6 ++-- dist/.dockerignore | 8 ++---- dist/Dockerfile | 4 +-- downloads.tpl | 17 +++++++++++ 9 files changed, 151 insertions(+), 65 deletions(-) create mode 100644 .goxc.json delete mode 100644 Dockerfile create mode 100644 downloads.tpl diff --git a/.gitignore b/.gitignore index bea63b5237..aeda8ae9ea 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ dist/ profile.cov profile.out .vendor +.goxc.local.json diff --git a/.goxc.json b/.goxc.json new file mode 100644 index 0000000000..2f92aed9a4 --- /dev/null +++ b/.goxc.json @@ -0,0 +1,49 @@ +{ + "AppName": "scw", + "ArtifactsDest": "dist", + "OutPath": "{{.Dest}}{{.PS}}{{.Version}}{{.PS}}{{.Os}}_{{.Arch}}{{.PS}}{{.ExeName}}{{.Ext}}", + "Tasks": [ + "default", + "deb-source", + "downloads-page" + ], + "TasksExclude": [ + "go-test", + "bintray", + "go-vet", + "rmbin", + "publish-github" + ], + "BuildConstraints": "darwin linux windows freebsd netbsd", + "ResourcesExclude": "*.go .goxc-temp", + "MainDirsExclude": "vendor,Godeps,testdata", + "PackageVersion": "v1.4.0-rc1", + "TaskSettings": { + "bintray": { + "downloadspage": "bintray.md", + "package": "scaleway-cli", + "repository": "utils", + "subject": "scaleway" + }, + "codesign": { + "id": "scaleway-cli" + }, + "downloads-page": { + "filename": "index.md", + "templateFile": "downloads.tpl" + }, + "publish-github": { + "owner": "scaleway", + "prerelease": false, + "repository": "scaleway-cli" + } + }, + "ConfigVersion": "0.9", + "BuildSettings": { + "LdFlags": "-s", + "LdFlagsXVars": { + "TimeNow": "main.BUILD_DATE", + "Version": "main.VERSION" + } + } +} diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4ebc7d4a21..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -FROM golang:cross - -ENV CGO_ENABLED 0 - -# Recompile the standard library without CGO -RUN go install -a std - -RUN apt-get install -y -q git - -# Declare the maintainer -MAINTAINER Scaleway Team (@scaleway) - -# For convenience, set an env variable with the path of the code -ENV APP_DIR /go/src/github.com/scaleway/scaleway-cli -WORKDIR $APP_DIR - -ADD . /go/src/github.com/scaleway/scaleway-cli - - -# Compile the binary and statically link -RUN GOOS=darwin GOARCH=amd64 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Darwin-x86_64 -RUN GOOS=darwin GOARCH=386 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Darwin-i386 -RUN GOOS=linux GOARCH=386 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Linux-i386 -#RUN GOOS=linux GOARCH=amd64 go build -a -v -ldflags '-w -s' -o /go/bin/scw-Linux-x86_64 -RUN cp /go/bin/scw-Linux-i386 /go/bin/scw-Linux-x86_64 -RUN GOOS=linux GOARCH=arm GOARM=5 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Linux-arm -RUN GOOS=linux GOARCH=arm GOARM=6 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Linux-armv6 -RUN GOOS=linux GOARCH=arm GOARM=7 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Linux-armv7 -RUN cp /go/bin/scw-Linux-armv7 /go/bin/scw-Linux-armv7l -RUN GOOS=freebsd GOARCH=amd64 go build -a -v -ldflags '-w -s' -o /go/bin/scw-Freebsd-x86_64 -RUN GOOS=freebsd GOARCH=386 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Freebsd-i386 -RUN GOOS=freebsd GOARCH=arm GOARM=5 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Freebsd-arm -#RUN GOOS=openbsd GOARCH=amd64 go build -a -v -ldflags '-w -s' -o /go/bin/scw-Openbsd-x86_64 -#RUN GOOS=openbsd GOARCH=386 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Openbsd-i386 -#RUN GOOS=openbsd GOARCH=arm GOARM=5 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Openbsd-arm -RUN GOOS=windows GOARCH=amd64 go build -a -v -ldflags '-w -s' -o /go/bin/scw-Windows-x86_64.exe -#RUN GOOS=windows GOARCH=386 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Windows-i386 -#RUN GOOS=windows GOARCH=arm GOARM=5 go build -a -v -ldflags '-d -w -s' -o /go/bin/scw-Windows-arm diff --git a/Makefile b/Makefile index 54b2b6ce4d..d9b43fd413 100644 --- a/Makefile +++ b/Makefile @@ -83,23 +83,41 @@ $(FMT_LIST): %_fmt: $(GOFMT) ./$* -cross: pkg/scwversion/version.go - docker build -t $(BUILDER) . - @docker rm scaleway-cli-builer 2>/dev/null || true - mkdir -p dist - docker run --name=$(BUILDER) $(BUILDER) tar -cf - /etc/ssl > dist/ssl.tar - docker cp $(BUILDER):/go/bin tmp - docker rm $(BUILDER) - touch tmp/bin/* - mv tmp/bin/* dist/ - rm -rf tmp +release-docker: + docker push scaleway/cli -release-docker: +goxc: pkg/scwversion/version.go + rm -rf dist/$(shell cat .goxc.json| jq -r .PackageVersion) + mkdir -p dist/$(shell cat .goxc.json| jq -r .PackageVersion) + ln -s -f $(shell cat .goxc.json| jq -r .PackageVersion) dist/latest + + goxc + + mv dist/latest/darwin_386/scw dist/latest/scw-Darwin-i386 + mv dist/latest/darwin_amd64/scw dist/latest/scw-Darwin-amd64 + mv dist/latest/freebsd_386/scw dist/latest/scw-Freebsd-i386 + mv dist/latest/freebsd_amd64/scw dist/latest/scw-Freebsd-x86_64 + mv dist/latest/freebsd_arm/scw dist/latest/scw-Freebsd-arm + mv dist/latest/linux_386/scw dist/latest/scw-Linux-i386 + mv dist/latest/linux_amd64/scw dist/latest/scw-Linux-x86_64 + mv dist/latest/linux_arm/scw dist/latest/scw-Linux-arm + mv dist/latest/netbsd_386/scw dist/latest/scw-Netbsd-i386 + mv dist/latest/netbsd_amd64/scw dist/latest/scw-Netbsd-x86_64 + mv dist/latest/netbsd_arm/scw dist/latest/scw-Netbsd-arm + mv dist/latest/windows_386/scw.exe dist/latest/scw-Windows-i386.exe + mv dist/latest/windows_amd64/scw.exe dist/latest/scw-Windows-x86_64.exe + + cp dist/latest/scw-Linux-arm dist/latest/scw-Linux-armv7l + + @rmdir dist/latest/* || true + + docker run --rm golang tar -cf - /etc/ssl > dist/latest/ssl.tar docker build -t scaleway/cli dist docker run scaleway/cli version docker tag -f scaleway/cli:latest scaleway/cli:$(TAG) - @echo " Now you can run 'docker push scaleway/cli'" + + @echo "Now you can run 'goxc publish-github', 'goxc bintray' and 'make release-docker'" packages: diff --git a/README.md b/README.md index df5c87b3ce..67c645afa5 100644 --- a/README.md +++ b/README.md @@ -65,19 +65,59 @@ For node version, check out [scaleway-cli-node](https://github.com/moul/scaleway ## Setup -To install Scaleway CLI 1.3.0, run the following commands: +We recommend to use the latest version, using: + +```shell +go get -u github.com/scaleway/scaleway-cli/cmd/scw +``` + +or + +```shell +brew install "https://raw.githubusercontent.com/scaleway/scaleway-cli/master/contrib/builder/homebrew/scw.rb" --HEAD +``` + +--- + +To install a release, checkout the [latest release page](https://github.com/scaleway/scaleway-cli/releases/latest). + +Install the latest stable release on Mac OS X using [Homebrew](http://brew.sh): ```bash -curl -L https://github.com/scaleway/scaleway-cli/releases/download/v1.3.0/scw-`uname -s`-`uname -m` > /usr/local/bin/scw -chmod +x /usr/local/bin/scw +brew install scw ``` -To install Scaleway CLI master git, run the following command: +Install the latest stable release on Mac OS X manually: ```bash -go get github.com/scaleway/scaleway-cli/... +# prepare for forst install and upgrade +mkdir -p /usr/local/bin +mv /usr/local/bin/scw /tmp/scw.old + +# get latest release +export VERSION=v1.4.0-rc1 +wget "https://github.com/scaleway/scaleway-cli/releases/download/${VERSION}/scw_${VERSION}_darwin_amd64.zip" -O /tmp/scw.zip +unzip /tmp/scw.zip \*/scw -d /tmp +mv /tmp/scw_*/scw /usr/local/bin +rm -rf /tmp/scw.zip /tmp/scw_*_darwin_amd64 + +# test +scw version ``` +Install the latest release on Linux: + +```bash +# get latest release +export ARCH=amd64 # can be 'i386', 'amd64' or 'arm' +wget "https://github.com/scaleway/scaleway-cli/releases/download/v1.4.0-rc1/scw_v1.4.0-rc1_${ARCH}.deb" -O /tmp/scw.deb +dpkg -i /tmp/scw.deb && rm -f /tmp/scw.deb + +# test +scw version +``` + + ### Requirements By using the [static-compiled release binaries](https://github.com/scaleway/scaleway-cli/releases/latest), you only needs to have one of the following platform+architecture : @@ -1056,6 +1096,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address' * Sorting cache search by Levenshtein distance ([#87](https://github.com/scaleway/scaleway-cli/issues/87)) * Allow set up api endpoint using the environment variable $scaleway_api_endpoint * Use TLS and verify can now be disabled using `SCALEWAY_TLSVERIFY=0` env var ([#115](https://github.com/scaleway/scaleway-cli/issues/115)) +* Switched to `goxc` for releases #### Fixes diff --git a/contrib/builder/homebrew/scw.rb b/contrib/builder/homebrew/scw.rb index 5b6526d538..2283ad6564 100644 --- a/contrib/builder/homebrew/scw.rb +++ b/contrib/builder/homebrew/scw.rb @@ -3,8 +3,8 @@ class Scw < Formula desc "Manage BareMetal Servers from Command Line (as easily as with Docker)" homepage "https://github.com/scaleway/scaleway-cli" - url "https://github.com/scaleway/scaleway-cli/archive/v1.3.0.tar.gz" - sha256 "b02ed007f831b9ffd79be0b670c6c1bfa59a87ba87ac54dea48005cfb305f5c7" + url "https://github.com/scaleway/scaleway-cli/archive/v1.4.0-rc1.tar.gz" + sha256 "2356191ef6c6e4f541aa2a516ec710f964b914e2976098174f68009d17aa110d" head "https://github.com/scaleway/scaleway-cli.git" @@ -19,7 +19,7 @@ def install ln_s buildpath, buildpath/"src/github.com/scaleway/scaleway-cli" Language::Go.stage_deps resources, buildpath/"src" - system "go", "build", "-o", "scw", "." + system "go", "build", "-o", "scw", "./cmd/scw" bin.install "scw" bash_completion.install "contrib/completion/bash/scw" diff --git a/dist/.dockerignore b/dist/.dockerignore index 56ad21e68e..89f019f582 100644 --- a/dist/.dockerignore +++ b/dist/.dockerignore @@ -1,7 +1,5 @@ -scw-Darwin-* -scw-Windows-* -scw-Freebsd-* -scw-Linux-arm* -scw-Linux-x86* +*.zip +*.tar.gz +*.deb Dockerfile .dockerignore diff --git a/dist/Dockerfile b/dist/Dockerfile index ead8e1752c..358b68fd17 100644 --- a/dist/Dockerfile +++ b/dist/Dockerfile @@ -1,6 +1,6 @@ FROM scratch MAINTAINER Scaleway (@scaleway) -ADD ssl.tar / -COPY scw-Linux-i386 /bin/scw +ADD latest/ssl.tar / +COPY latest/scw-Linux-i386 /bin/scw VOLUME /root/ ENTRYPOINT ["/bin/scw"] diff --git a/downloads.tpl b/downloads.tpl new file mode 100644 index 0000000000..b85bbf7b3b --- /dev/null +++ b/downloads.tpl @@ -0,0 +1,17 @@ +--- +layout: default +title: Downloads +--- + +NOTE: You can get latest version of scaleway-cli using `go get -u github.com/scaleway/scaleway-cli/cmd/scw`. + +{{.AppName}} downloads (version {{.Version}}) + +{{range $k, $v := .Categories}}### {{$k}} + +{{range $v}} * [{{.Text}}]({{.RelativeLink}}) +{{end}} +{{end}} + +--- +{{.ExtraVars.footer}}